feat: Phase 1 — extract the client (web SPA + desktop) to dtoro/oikos-web
Problem: the hexagonal refactor churns the backend tree for nine more phases; the UI delivery stack (web/ SPA, cmd/desktop Wails wrapper, compose/web image) must move to its own repo first so doc/layout rewrites land once on a backend-only tree. Change: - New repo git.hubris.network/dtoro/oikos-web (v0.33.0): web/, desktop/ (updateURL repointed to oikos-web releases), compose/, own CI (web + desktop jobs), own deploy script (CI-green gate, TOCTOU guard, version-tagged images, prune-to-3), own webhook receiver on :9798 + launchd unit, own compose project publishing the same 8091:80. - Cutover executed on mac-mini in order: oikos stack's web service stopped+removed, oikos-web project brought up on 8091; outer Caddy untouched (targets the published port) — serving + Authentik flow + /wails 404 quirk verified post-cutover. - Stripped from oikos: web/, cmd/desktop/, compose/web/, desktop CI workflow, ci.yml web job, Makefile ui/desktop/desktop-package/install targets, the compose web service, oikos-web from deploy.sh's fallback prune list; wails + go-keyring dropped from go.mod, vendor synced. - README / CONTRIBUTING / AGENTS.md / .agents dev+operations docs now point at the new repo; mbse + mascot design docs carry a path note. Risk: production SPA serving depends on the new pipeline now; rollback is versioned-image re-up of the old web service from a pre-split checkout (port 8091). Desktop builds installed before the split still check dtoro/oikos releases — one manual reinstall, noted in the oikos-web release notes. Verification: go vet, make test (race), make generate-check, golangci (no new findings; baseline down 400→365); post-cutover curls — localhost:8091 200, /wails/runtime.js 404, outer Caddy 302 Authentik.
This commit is contained in:
37
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-button.svelte
generated
vendored
Normal file
37
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-button.svelte
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<script lang="ts">
|
||||
import { boxWith, mergeProps } from "svelte-toolbelt";
|
||||
import type { ToolbarButtonProps } from "../types.js";
|
||||
import { ToolbarButtonState } from "../toolbar.svelte.js";
|
||||
import { createId } from "../../../internal/create-id.js";
|
||||
|
||||
const uid = $props.id();
|
||||
|
||||
let {
|
||||
child,
|
||||
children,
|
||||
disabled = false,
|
||||
type = "button",
|
||||
id = createId(uid),
|
||||
ref = $bindable(null),
|
||||
...restProps
|
||||
}: ToolbarButtonProps = $props();
|
||||
|
||||
const buttonState = ToolbarButtonState.create({
|
||||
id: boxWith(() => id),
|
||||
disabled: boxWith(() => disabled ?? false),
|
||||
ref: boxWith(
|
||||
() => ref,
|
||||
(v) => (ref = v)
|
||||
),
|
||||
});
|
||||
|
||||
const mergedProps = $derived(mergeProps(restProps, buttonState.props, { type }));
|
||||
</script>
|
||||
|
||||
{#if child}
|
||||
{@render child({ props: mergedProps })}
|
||||
{:else}
|
||||
<button {...mergedProps}>
|
||||
{@render children?.()}
|
||||
</button>
|
||||
{/if}
|
||||
4
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-button.svelte.d.ts
generated
vendored
Normal file
4
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-button.svelte.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { ToolbarButtonProps } from "../types.js";
|
||||
declare const ToolbarButton: import("svelte").Component<ToolbarButtonProps, {}, "ref">;
|
||||
type ToolbarButton = ReturnType<typeof ToolbarButton>;
|
||||
export default ToolbarButton;
|
||||
39
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-group-item.svelte
generated
vendored
Normal file
39
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-group-item.svelte
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<script lang="ts">
|
||||
import { boxWith, mergeProps } from "svelte-toolbelt";
|
||||
import type { ToolbarGroupItemProps } from "../types.js";
|
||||
import { ToolbarGroupItemState } from "../toolbar.svelte.js";
|
||||
import { createId } from "../../../internal/create-id.js";
|
||||
|
||||
const uid = $props.id();
|
||||
|
||||
let {
|
||||
child,
|
||||
children,
|
||||
value,
|
||||
disabled = false,
|
||||
type = "button",
|
||||
id = createId(uid),
|
||||
ref = $bindable(null),
|
||||
...restProps
|
||||
}: ToolbarGroupItemProps = $props();
|
||||
|
||||
const groupItemState = ToolbarGroupItemState.create({
|
||||
id: boxWith(() => id),
|
||||
value: boxWith(() => value),
|
||||
disabled: boxWith(() => disabled ?? false),
|
||||
ref: boxWith(
|
||||
() => ref,
|
||||
(v) => (ref = v)
|
||||
),
|
||||
});
|
||||
|
||||
const mergedProps = $derived(mergeProps(restProps, groupItemState.props, { type }));
|
||||
</script>
|
||||
|
||||
{#if child}
|
||||
{@render child({ props: mergedProps, pressed: groupItemState.isPressed })}
|
||||
{:else}
|
||||
<button {...mergedProps}>
|
||||
{@render children?.({ pressed: groupItemState.isPressed })}
|
||||
</button>
|
||||
{/if}
|
||||
3
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-group-item.svelte.d.ts
generated
vendored
Normal file
3
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-group-item.svelte.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare const ToolbarGroupItem: import("svelte").Component<import("../../toggle-group/types.js").ToggleGroupItemProps, {}, "ref">;
|
||||
type ToolbarGroupItem = ReturnType<typeof ToolbarGroupItem>;
|
||||
export default ToolbarGroupItem;
|
||||
66
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-group.svelte
generated
vendored
Normal file
66
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-group.svelte
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<script lang="ts">
|
||||
import { type WritableBox, boxWith } from "svelte-toolbelt";
|
||||
import { mergeProps } from "svelte-toolbelt";
|
||||
import type { ToolbarGroupProps } from "../types.js";
|
||||
import { ToolbarGroupState } from "../toolbar.svelte.js";
|
||||
import { createId } from "../../../internal/create-id.js";
|
||||
import { noop } from "../../../internal/noop.js";
|
||||
import { watch } from "runed";
|
||||
|
||||
const uid = $props.id();
|
||||
|
||||
let {
|
||||
id = createId(uid),
|
||||
ref = $bindable(null),
|
||||
value = $bindable(),
|
||||
onValueChange = noop,
|
||||
type,
|
||||
disabled = false,
|
||||
child,
|
||||
children,
|
||||
...restProps
|
||||
}: ToolbarGroupProps = $props();
|
||||
|
||||
function handleDefaultValue() {
|
||||
if (value !== undefined) return;
|
||||
value = type === "single" ? "" : [];
|
||||
}
|
||||
|
||||
// SSR
|
||||
handleDefaultValue();
|
||||
|
||||
watch.pre(
|
||||
() => value,
|
||||
() => {
|
||||
handleDefaultValue();
|
||||
}
|
||||
);
|
||||
|
||||
const groupState = ToolbarGroupState.create({
|
||||
id: boxWith(() => id),
|
||||
disabled: boxWith(() => disabled),
|
||||
type,
|
||||
value: boxWith(
|
||||
() => value!,
|
||||
(v) => {
|
||||
value = v;
|
||||
// @ts-expect-error - we know
|
||||
onValueChange(v);
|
||||
}
|
||||
) as WritableBox<string> | WritableBox<string[]>,
|
||||
ref: boxWith(
|
||||
() => ref,
|
||||
(v) => (ref = v)
|
||||
),
|
||||
});
|
||||
|
||||
const mergedProps = $derived(mergeProps(restProps, groupState.props));
|
||||
</script>
|
||||
|
||||
{#if child}
|
||||
{@render child({ props: mergedProps })}
|
||||
{:else}
|
||||
<div {...mergedProps}>
|
||||
{@render children?.()}
|
||||
</div>
|
||||
{/if}
|
||||
4
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-group.svelte.d.ts
generated
vendored
Normal file
4
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-group.svelte.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { ToolbarGroupProps } from "../types.js";
|
||||
declare const ToolbarGroup: import("svelte").Component<ToolbarGroupProps, {}, "value" | "ref">;
|
||||
type ToolbarGroup = ReturnType<typeof ToolbarGroup>;
|
||||
export default ToolbarGroup;
|
||||
35
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-link.svelte
generated
vendored
Normal file
35
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-link.svelte
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<script lang="ts">
|
||||
import { boxWith, mergeProps } from "svelte-toolbelt";
|
||||
import { ToolbarLinkState } from "../toolbar.svelte.js";
|
||||
import type { ToolbarLinkProps } from "../types.js";
|
||||
import { createId } from "../../../internal/create-id.js";
|
||||
|
||||
const uid = $props.id();
|
||||
|
||||
let {
|
||||
children,
|
||||
href,
|
||||
child,
|
||||
ref = $bindable(null),
|
||||
id = createId(uid),
|
||||
...restProps
|
||||
}: ToolbarLinkProps = $props();
|
||||
|
||||
const linkState = ToolbarLinkState.create({
|
||||
id: boxWith(() => id),
|
||||
ref: boxWith(
|
||||
() => ref,
|
||||
(v) => (ref = v)
|
||||
),
|
||||
});
|
||||
|
||||
const mergedProps = $derived(mergeProps(restProps, linkState.props));
|
||||
</script>
|
||||
|
||||
{#if child}
|
||||
{@render child({ props: mergedProps })}
|
||||
{:else}
|
||||
<a {href} {...mergedProps}>
|
||||
{@render children?.()}
|
||||
</a>
|
||||
{/if}
|
||||
4
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-link.svelte.d.ts
generated
vendored
Normal file
4
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar-link.svelte.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { ToolbarLinkProps } from "../types.js";
|
||||
declare const ToolbarLink: import("svelte").Component<ToolbarLinkProps, {}, "ref">;
|
||||
type ToolbarLink = ReturnType<typeof ToolbarLink>;
|
||||
export default ToolbarLink;
|
||||
38
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar.svelte
generated
vendored
Normal file
38
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar.svelte
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<script lang="ts">
|
||||
import { boxWith, mergeProps } from "svelte-toolbelt";
|
||||
import type { ToolbarRootProps } from "../types.js";
|
||||
import { ToolbarRootState } from "../toolbar.svelte.js";
|
||||
import { createId } from "../../../internal/create-id.js";
|
||||
|
||||
const uid = $props.id();
|
||||
|
||||
let {
|
||||
ref = $bindable(null),
|
||||
id = createId(uid),
|
||||
orientation = "horizontal",
|
||||
loop = true,
|
||||
child,
|
||||
children,
|
||||
...restProps
|
||||
}: ToolbarRootProps = $props();
|
||||
|
||||
const rootState = ToolbarRootState.create({
|
||||
id: boxWith(() => id),
|
||||
orientation: boxWith(() => orientation),
|
||||
loop: boxWith(() => loop),
|
||||
ref: boxWith(
|
||||
() => ref,
|
||||
(v) => (ref = v)
|
||||
),
|
||||
});
|
||||
|
||||
const mergedProps = $derived(mergeProps(restProps, rootState.props));
|
||||
</script>
|
||||
|
||||
{#if child}
|
||||
{@render child({ props: mergedProps })}
|
||||
{:else}
|
||||
<div {...mergedProps}>
|
||||
{@render children?.()}
|
||||
</div>
|
||||
{/if}
|
||||
4
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar.svelte.d.ts
generated
vendored
Normal file
4
web/node_modules/bits-ui/dist/bits/toolbar/components/toolbar.svelte.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { ToolbarRootProps } from "../types.js";
|
||||
declare const Toolbar: import("svelte").Component<ToolbarRootProps, {}, "ref">;
|
||||
type Toolbar = ReturnType<typeof Toolbar>;
|
||||
export default Toolbar;
|
||||
6
web/node_modules/bits-ui/dist/bits/toolbar/exports.d.ts
generated
vendored
Normal file
6
web/node_modules/bits-ui/dist/bits/toolbar/exports.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export { default as Root } from "./components/toolbar.svelte";
|
||||
export { default as Button } from "./components/toolbar-button.svelte";
|
||||
export { default as Link } from "./components/toolbar-link.svelte";
|
||||
export { default as Group } from "./components/toolbar-group.svelte";
|
||||
export { default as GroupItem } from "./components/toolbar-group-item.svelte";
|
||||
export type { ToolbarRootProps as RootProps, ToolbarButtonProps as ButtonProps, ToolbarLinkProps as LinkProps, ToolbarGroupProps as GroupProps, ToolbarGroupItemProps as GroupItemProps, } from "./types.js";
|
||||
5
web/node_modules/bits-ui/dist/bits/toolbar/exports.js
generated
vendored
Normal file
5
web/node_modules/bits-ui/dist/bits/toolbar/exports.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export { default as Root } from "./components/toolbar.svelte";
|
||||
export { default as Button } from "./components/toolbar-button.svelte";
|
||||
export { default as Link } from "./components/toolbar-link.svelte";
|
||||
export { default as Group } from "./components/toolbar-group.svelte";
|
||||
export { default as GroupItem } from "./components/toolbar-group-item.svelte";
|
||||
1
web/node_modules/bits-ui/dist/bits/toolbar/index.d.ts
generated
vendored
Normal file
1
web/node_modules/bits-ui/dist/bits/toolbar/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * as Toolbar from "./exports.js";
|
||||
1
web/node_modules/bits-ui/dist/bits/toolbar/index.js
generated
vendored
Normal file
1
web/node_modules/bits-ui/dist/bits/toolbar/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * as Toolbar from "./exports.js";
|
||||
146
web/node_modules/bits-ui/dist/bits/toolbar/toolbar.svelte.d.ts
generated
vendored
Normal file
146
web/node_modules/bits-ui/dist/bits/toolbar/toolbar.svelte.d.ts
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
import { type WritableBox, type WritableBoxedValues, type ReadableBoxedValues } from "svelte-toolbelt";
|
||||
import type { Orientation } from "../../shared/index.js";
|
||||
import type { BitsKeyboardEvent, BitsMouseEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
|
||||
import { RovingFocusGroup } from "../../internal/roving-focus-group.js";
|
||||
export declare const toolbarAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["root", "item", "group", "group-item", "link", "button"]>;
|
||||
interface ToolbarRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
||||
orientation: Orientation;
|
||||
loop: boolean;
|
||||
}> {
|
||||
}
|
||||
export declare class ToolbarRootState {
|
||||
static create(opts: ToolbarRootStateOpts): ToolbarRootState;
|
||||
readonly opts: ToolbarRootStateOpts;
|
||||
readonly rovingFocusGroup: RovingFocusGroup;
|
||||
readonly attachment: RefAttachment;
|
||||
constructor(opts: ToolbarRootStateOpts);
|
||||
readonly props: {
|
||||
readonly id: string;
|
||||
readonly role: "toolbar";
|
||||
readonly "data-orientation": Orientation;
|
||||
};
|
||||
}
|
||||
interface ToolbarGroupBaseStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
||||
disabled: boolean;
|
||||
}> {
|
||||
}
|
||||
declare abstract class ToolbarGroupBaseState {
|
||||
readonly opts: ToolbarGroupBaseStateOpts;
|
||||
readonly root: ToolbarRootState;
|
||||
readonly attachment: RefAttachment;
|
||||
constructor(opts: ToolbarGroupBaseStateOpts, root: ToolbarRootState);
|
||||
readonly props: {
|
||||
readonly id: string;
|
||||
readonly role: "group";
|
||||
readonly "data-orientation": Orientation;
|
||||
readonly "data-disabled": "" | undefined;
|
||||
};
|
||||
}
|
||||
interface ToolbarGroupSingleStateOpts extends ToolbarGroupBaseStateOpts, WritableBoxedValues<{
|
||||
value: string;
|
||||
}> {
|
||||
}
|
||||
declare class ToolbarGroupSingleState extends ToolbarGroupBaseState {
|
||||
readonly opts: ToolbarGroupSingleStateOpts;
|
||||
readonly root: ToolbarRootState;
|
||||
readonly isMulti: false;
|
||||
readonly anyPressed: boolean;
|
||||
constructor(opts: ToolbarGroupSingleStateOpts, root: ToolbarRootState);
|
||||
includesItem(item: string): boolean;
|
||||
toggleItem(item: string): void;
|
||||
}
|
||||
interface ToolbarGroupMultipleStateOpts extends ToolbarGroupBaseStateOpts, WritableBoxedValues<{
|
||||
value: string[];
|
||||
}> {
|
||||
}
|
||||
declare class ToolbarGroupMultipleState extends ToolbarGroupBaseState {
|
||||
readonly opts: ToolbarGroupMultipleStateOpts;
|
||||
readonly root: ToolbarRootState;
|
||||
readonly isMulti: true;
|
||||
readonly anyPressed: boolean;
|
||||
constructor(opts: ToolbarGroupMultipleStateOpts, root: ToolbarRootState);
|
||||
includesItem(item: string): boolean;
|
||||
toggleItem(item: string): void;
|
||||
}
|
||||
type ToolbarGroup = ToolbarGroupSingleState | ToolbarGroupMultipleState;
|
||||
interface ToolbarGroupRootOpts extends WithRefOpts, ReadableBoxedValues<{
|
||||
disabled: boolean;
|
||||
}> {
|
||||
type: "single" | "multiple";
|
||||
value: WritableBox<string> | WritableBox<string[]>;
|
||||
}
|
||||
export declare class ToolbarGroupState {
|
||||
static create(opts: ToolbarGroupRootOpts): ToolbarGroup;
|
||||
}
|
||||
interface ToolbarGroupItemStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
||||
value: string;
|
||||
disabled: boolean;
|
||||
}> {
|
||||
}
|
||||
export declare class ToolbarGroupItemState {
|
||||
#private;
|
||||
static create(opts: ToolbarGroupItemStateOpts): ToolbarGroupItemState;
|
||||
readonly opts: ToolbarGroupItemStateOpts;
|
||||
readonly group: ToolbarGroup;
|
||||
readonly root: ToolbarRootState;
|
||||
readonly attachment: RefAttachment;
|
||||
constructor(opts: ToolbarGroupItemStateOpts, group: ToolbarGroup, root: ToolbarRootState);
|
||||
onclick(_: BitsMouseEvent): void;
|
||||
onkeydown(e: BitsKeyboardEvent): void;
|
||||
readonly isPressed: boolean;
|
||||
readonly props: {
|
||||
readonly id: string;
|
||||
readonly role: "radio" | undefined;
|
||||
readonly tabindex: number;
|
||||
readonly "data-orientation": Orientation;
|
||||
readonly "data-disabled": "" | undefined;
|
||||
readonly "data-state": "off" | "on";
|
||||
readonly "data-value": string;
|
||||
readonly "aria-pressed": "true" | "false" | undefined;
|
||||
readonly "aria-checked": "true" | "false" | "mixed" | undefined;
|
||||
readonly disabled: true | undefined;
|
||||
readonly onclick: (_: BitsMouseEvent) => void;
|
||||
readonly onkeydown: (e: BitsKeyboardEvent) => void;
|
||||
};
|
||||
}
|
||||
interface ToolbarLinkStateOpts extends WithRefOpts {
|
||||
}
|
||||
export declare class ToolbarLinkState {
|
||||
#private;
|
||||
static create(opts: ToolbarLinkStateOpts): ToolbarLinkState;
|
||||
readonly opts: ToolbarLinkStateOpts;
|
||||
readonly root: ToolbarRootState;
|
||||
readonly attachment: RefAttachment;
|
||||
constructor(opts: ToolbarLinkStateOpts, root: ToolbarRootState);
|
||||
onkeydown(e: BitsKeyboardEvent): void;
|
||||
readonly props: {
|
||||
readonly id: string;
|
||||
readonly role: "link" | undefined;
|
||||
readonly tabindex: number;
|
||||
readonly "data-orientation": Orientation;
|
||||
readonly onkeydown: (e: BitsKeyboardEvent) => void;
|
||||
};
|
||||
}
|
||||
interface ToolbarButtonStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
||||
disabled: boolean;
|
||||
}> {
|
||||
}
|
||||
export declare class ToolbarButtonState {
|
||||
#private;
|
||||
static create(opts: ToolbarButtonStateOpts): ToolbarButtonState;
|
||||
readonly opts: ToolbarButtonStateOpts;
|
||||
readonly root: ToolbarRootState;
|
||||
readonly attachment: RefAttachment;
|
||||
constructor(opts: ToolbarButtonStateOpts, root: ToolbarRootState);
|
||||
onkeydown(e: BitsKeyboardEvent): void;
|
||||
readonly props: {
|
||||
readonly id: string;
|
||||
readonly role: "button" | undefined;
|
||||
readonly tabindex: number;
|
||||
readonly "data-disabled": "" | undefined;
|
||||
readonly "data-orientation": Orientation;
|
||||
readonly disabled: true | undefined;
|
||||
readonly onkeydown: (e: BitsKeyboardEvent) => void;
|
||||
};
|
||||
}
|
||||
export {};
|
||||
264
web/node_modules/bits-ui/dist/bits/toolbar/toolbar.svelte.js
generated
vendored
Normal file
264
web/node_modules/bits-ui/dist/bits/toolbar/toolbar.svelte.js
generated
vendored
Normal file
@@ -0,0 +1,264 @@
|
||||
import { attachRef, } from "svelte-toolbelt";
|
||||
import { Context } from "runed";
|
||||
import { createBitsAttrs, getAriaChecked, boolToStr, boolToEmptyStrOrUndef, boolToTrueOrUndef, } from "../../internal/attrs.js";
|
||||
import { kbd } from "../../internal/kbd.js";
|
||||
import { RovingFocusGroup } from "../../internal/roving-focus-group.js";
|
||||
export const toolbarAttrs = createBitsAttrs({
|
||||
component: "toolbar",
|
||||
parts: ["root", "item", "group", "group-item", "link", "button"],
|
||||
});
|
||||
const ToolbarRootContext = new Context("Toolbar.Root");
|
||||
const ToolbarGroupContext = new Context("Toolbar.Group");
|
||||
export class ToolbarRootState {
|
||||
static create(opts) {
|
||||
return ToolbarRootContext.set(new ToolbarRootState(opts));
|
||||
}
|
||||
opts;
|
||||
rovingFocusGroup;
|
||||
attachment;
|
||||
constructor(opts) {
|
||||
this.opts = opts;
|
||||
this.attachment = attachRef(this.opts.ref);
|
||||
this.rovingFocusGroup = new RovingFocusGroup({
|
||||
orientation: this.opts.orientation,
|
||||
loop: this.opts.loop,
|
||||
rootNode: this.opts.ref,
|
||||
candidateAttr: toolbarAttrs.item,
|
||||
});
|
||||
}
|
||||
props = $derived.by(() => ({
|
||||
id: this.opts.id.current,
|
||||
role: "toolbar",
|
||||
"data-orientation": this.opts.orientation.current,
|
||||
[toolbarAttrs.root]: "",
|
||||
...this.attachment,
|
||||
}));
|
||||
}
|
||||
class ToolbarGroupBaseState {
|
||||
opts;
|
||||
root;
|
||||
attachment;
|
||||
constructor(opts, root) {
|
||||
this.opts = opts;
|
||||
this.root = root;
|
||||
this.attachment = attachRef(this.opts.ref);
|
||||
}
|
||||
props = $derived.by(() => ({
|
||||
id: this.opts.id.current,
|
||||
[toolbarAttrs.group]: "",
|
||||
role: "group",
|
||||
"data-orientation": this.root.opts.orientation.current,
|
||||
"data-disabled": boolToEmptyStrOrUndef(this.opts.disabled.current),
|
||||
...this.attachment,
|
||||
}));
|
||||
}
|
||||
class ToolbarGroupSingleState extends ToolbarGroupBaseState {
|
||||
opts;
|
||||
root;
|
||||
isMulti = false;
|
||||
anyPressed = $derived.by(() => this.opts.value.current !== "");
|
||||
constructor(opts, root) {
|
||||
super(opts, root);
|
||||
this.opts = opts;
|
||||
this.root = root;
|
||||
}
|
||||
includesItem(item) {
|
||||
return this.opts.value.current === item;
|
||||
}
|
||||
toggleItem(item) {
|
||||
if (this.includesItem(item)) {
|
||||
this.opts.value.current = "";
|
||||
}
|
||||
else {
|
||||
this.opts.value.current = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
class ToolbarGroupMultipleState extends ToolbarGroupBaseState {
|
||||
opts;
|
||||
root;
|
||||
isMulti = true;
|
||||
anyPressed = $derived.by(() => this.opts.value.current.length > 0);
|
||||
constructor(opts, root) {
|
||||
super(opts, root);
|
||||
this.opts = opts;
|
||||
this.root = root;
|
||||
}
|
||||
includesItem(item) {
|
||||
return this.opts.value.current.includes(item);
|
||||
}
|
||||
toggleItem(item) {
|
||||
if (this.includesItem(item)) {
|
||||
this.opts.value.current = this.opts.value.current.filter((v) => v !== item);
|
||||
}
|
||||
else {
|
||||
this.opts.value.current = [...this.opts.value.current, item];
|
||||
}
|
||||
}
|
||||
}
|
||||
export class ToolbarGroupState {
|
||||
static create(opts) {
|
||||
const { type, ...rest } = opts;
|
||||
const rootState = ToolbarRootContext.get();
|
||||
const groupState = type === "single"
|
||||
? new ToolbarGroupSingleState(rest, rootState)
|
||||
: new ToolbarGroupMultipleState(rest, rootState);
|
||||
return ToolbarGroupContext.set(groupState);
|
||||
}
|
||||
}
|
||||
export class ToolbarGroupItemState {
|
||||
static create(opts) {
|
||||
const group = ToolbarGroupContext.get();
|
||||
return new ToolbarGroupItemState(opts, group, group.root);
|
||||
}
|
||||
opts;
|
||||
group;
|
||||
root;
|
||||
attachment;
|
||||
#isDisabled = $derived.by(() => this.opts.disabled.current || this.group.opts.disabled.current);
|
||||
constructor(opts, group, root) {
|
||||
this.opts = opts;
|
||||
this.group = group;
|
||||
this.root = root;
|
||||
this.attachment = attachRef(this.opts.ref);
|
||||
$effect(() => {
|
||||
this.#tabIndex = this.root.rovingFocusGroup.getTabIndex(this.opts.ref.current);
|
||||
});
|
||||
this.onclick = this.onclick.bind(this);
|
||||
this.onkeydown = this.onkeydown.bind(this);
|
||||
}
|
||||
#toggleItem() {
|
||||
if (this.#isDisabled)
|
||||
return;
|
||||
this.group.toggleItem(this.opts.value.current);
|
||||
}
|
||||
onclick(_) {
|
||||
if (this.#isDisabled)
|
||||
return;
|
||||
this.#toggleItem();
|
||||
}
|
||||
onkeydown(e) {
|
||||
if (this.#isDisabled)
|
||||
return;
|
||||
if (e.key === kbd.ENTER || e.key === kbd.SPACE) {
|
||||
e.preventDefault();
|
||||
this.#toggleItem();
|
||||
return;
|
||||
}
|
||||
this.root.rovingFocusGroup.handleKeydown(this.opts.ref.current, e);
|
||||
}
|
||||
isPressed = $derived.by(() => this.group.includesItem(this.opts.value.current));
|
||||
#ariaChecked = $derived.by(() => {
|
||||
return this.group.isMulti ? undefined : getAriaChecked(this.isPressed, false);
|
||||
});
|
||||
#ariaPressed = $derived.by(() => {
|
||||
return this.group.isMulti ? boolToStr(this.isPressed) : undefined;
|
||||
});
|
||||
#tabIndex = $state(0);
|
||||
props = $derived.by(() => ({
|
||||
id: this.opts.id.current,
|
||||
role: this.group.isMulti ? undefined : "radio",
|
||||
tabindex: this.#tabIndex,
|
||||
"data-orientation": this.root.opts.orientation.current,
|
||||
"data-disabled": boolToEmptyStrOrUndef(this.#isDisabled),
|
||||
"data-state": getToggleItemDataState(this.isPressed),
|
||||
"data-value": this.opts.value.current,
|
||||
"aria-pressed": this.#ariaPressed,
|
||||
"aria-checked": this.#ariaChecked,
|
||||
[toolbarAttrs.item]: "",
|
||||
[toolbarAttrs["group-item"]]: "",
|
||||
disabled: boolToTrueOrUndef(this.#isDisabled),
|
||||
//
|
||||
onclick: this.onclick,
|
||||
onkeydown: this.onkeydown,
|
||||
...this.attachment,
|
||||
}));
|
||||
}
|
||||
export class ToolbarLinkState {
|
||||
static create(opts) {
|
||||
return new ToolbarLinkState(opts, ToolbarRootContext.get());
|
||||
}
|
||||
opts;
|
||||
root;
|
||||
attachment;
|
||||
constructor(opts, root) {
|
||||
this.opts = opts;
|
||||
this.root = root;
|
||||
this.attachment = attachRef(this.opts.ref);
|
||||
$effect(() => {
|
||||
this.#tabIndex = this.root.rovingFocusGroup.getTabIndex(this.opts.ref.current);
|
||||
});
|
||||
this.onkeydown = this.onkeydown.bind(this);
|
||||
}
|
||||
onkeydown(e) {
|
||||
this.root.rovingFocusGroup.handleKeydown(this.opts.ref.current, e);
|
||||
}
|
||||
#role = $derived.by(() => {
|
||||
if (!this.opts.ref.current)
|
||||
return undefined;
|
||||
const tagName = this.opts.ref.current.tagName;
|
||||
if (tagName !== "A")
|
||||
return "link";
|
||||
return undefined;
|
||||
});
|
||||
#tabIndex = $state(0);
|
||||
props = $derived.by(() => ({
|
||||
id: this.opts.id.current,
|
||||
[toolbarAttrs.link]: "",
|
||||
[toolbarAttrs.item]: "",
|
||||
role: this.#role,
|
||||
tabindex: this.#tabIndex,
|
||||
"data-orientation": this.root.opts.orientation.current,
|
||||
//
|
||||
onkeydown: this.onkeydown,
|
||||
...this.attachment,
|
||||
}));
|
||||
}
|
||||
export class ToolbarButtonState {
|
||||
static create(opts) {
|
||||
return new ToolbarButtonState(opts, ToolbarRootContext.get());
|
||||
}
|
||||
opts;
|
||||
root;
|
||||
attachment;
|
||||
constructor(opts, root) {
|
||||
this.opts = opts;
|
||||
this.root = root;
|
||||
this.attachment = attachRef(this.opts.ref);
|
||||
$effect(() => {
|
||||
this.#tabIndex = this.root.rovingFocusGroup.getTabIndex(this.opts.ref.current);
|
||||
});
|
||||
this.onkeydown = this.onkeydown.bind(this);
|
||||
}
|
||||
onkeydown(e) {
|
||||
this.root.rovingFocusGroup.handleKeydown(this.opts.ref.current, e);
|
||||
}
|
||||
#tabIndex = $state(0);
|
||||
#role = $derived.by(() => {
|
||||
if (!this.opts.ref.current)
|
||||
return undefined;
|
||||
const tagName = this.opts.ref.current.tagName;
|
||||
if (tagName !== "BUTTON")
|
||||
return "button";
|
||||
return undefined;
|
||||
});
|
||||
props = $derived.by(() => ({
|
||||
id: this.opts.id.current,
|
||||
[toolbarAttrs.item]: "",
|
||||
[toolbarAttrs.button]: "",
|
||||
role: this.#role,
|
||||
tabindex: this.#tabIndex,
|
||||
"data-disabled": boolToEmptyStrOrUndef(this.opts.disabled.current),
|
||||
"data-orientation": this.root.opts.orientation.current,
|
||||
disabled: boolToTrueOrUndef(this.opts.disabled.current),
|
||||
//
|
||||
onkeydown: this.onkeydown,
|
||||
...this.attachment,
|
||||
}));
|
||||
}
|
||||
//
|
||||
// HELPERS
|
||||
//
|
||||
function getToggleItemDataState(condition) {
|
||||
return condition ? "on" : "off";
|
||||
}
|
||||
34
web/node_modules/bits-ui/dist/bits/toolbar/types.d.ts
generated
vendored
Normal file
34
web/node_modules/bits-ui/dist/bits/toolbar/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { ToggleGroupItemProps, ToggleGroupItemPropsWithoutHTML, ToggleGroupRootPropsWithoutHTML } from "../toggle-group/types.js";
|
||||
import type { Orientation } from "../../shared/index.js";
|
||||
import type { WithChild, Without } from "../../internal/types.js";
|
||||
import type { BitsPrimitiveAnchorAttributes, BitsPrimitiveButtonAttributes, BitsPrimitiveDivAttributes } from "../../shared/attributes.js";
|
||||
export type ToolbarRootPropsWithoutHTML = WithChild<{
|
||||
/**
|
||||
* The orientation of the toolbar. This determines how keyboard navigation
|
||||
* will work within the toolbar.
|
||||
*
|
||||
* @defaultValue "horizontal"
|
||||
*/
|
||||
orientation?: Orientation;
|
||||
/**
|
||||
* Whether or not to loop through the toolbar items when navigating with the
|
||||
* keyboard.
|
||||
*
|
||||
* @defaultValue true
|
||||
*/
|
||||
loop?: boolean;
|
||||
}>;
|
||||
export type ToolbarRootProps = ToolbarRootPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, ToolbarRootPropsWithoutHTML>;
|
||||
export type ToolbarGroupPropsWithoutHTML = Omit<ToggleGroupRootPropsWithoutHTML, "orientation" | "loop" | "rovingFocus">;
|
||||
export type ToolbarGroupProps = ToolbarGroupPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, ToolbarGroupPropsWithoutHTML>;
|
||||
export type ToolbarGroupItemPropsWithoutHTML = ToggleGroupItemPropsWithoutHTML;
|
||||
export type ToolbarGroupItemProps = ToggleGroupItemProps;
|
||||
export type ToolbarButtonPropsWithoutHTML = WithChild<{
|
||||
/**
|
||||
* Whether the button is disabled or not.
|
||||
*/
|
||||
disabled?: boolean | null | undefined;
|
||||
}>;
|
||||
export type ToolbarButtonProps = ToolbarButtonPropsWithoutHTML & Without<BitsPrimitiveButtonAttributes, ToolbarButtonPropsWithoutHTML>;
|
||||
export type ToolbarLinkPropsWithoutHTML = WithChild;
|
||||
export type ToolbarLinkProps = ToolbarLinkPropsWithoutHTML & Without<BitsPrimitiveAnchorAttributes, ToolbarLinkPropsWithoutHTML>;
|
||||
1
web/node_modules/bits-ui/dist/bits/toolbar/types.js
generated
vendored
Normal file
1
web/node_modules/bits-ui/dist/bits/toolbar/types.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user