@ui-sdk/vue 0.0.0-stage → 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +10 -2
- package/dist/accordion.d.ts +561 -0
- package/dist/accordion.js +24 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +7 -0
- package/dist/alert-dialog.d.ts +231 -0
- package/dist/alert-dialog.js +33 -0
- package/dist/async-options.d.ts +18 -0
- package/dist/async-options.js +40 -0
- package/dist/autocomplete.d.ts +384 -0
- package/dist/autocomplete.js +344 -0
- package/dist/avatar.d.ts +40 -0
- package/dist/avatar.js +28 -0
- package/dist/button.d.ts +52 -0
- package/dist/button.js +43 -0
- package/dist/calendar-context.d.ts +10 -0
- package/dist/calendar-context.js +7 -0
- package/dist/calendar.d.ts +311 -0
- package/dist/calendar.js +349 -0
- package/dist/carousel.d.ts +236 -0
- package/dist/carousel.js +204 -0
- package/dist/checkbox.d.ts +211 -0
- package/dist/checkbox.js +151 -0
- package/dist/children.d.ts +41 -0
- package/dist/children.js +135 -0
- package/dist/collapsible.d.ts +54 -0
- package/dist/collapsible.js +18 -0
- package/dist/color-picker.d.ts +187 -0
- package/dist/color-picker.js +158 -0
- package/dist/color.d.ts +2 -0
- package/dist/color.js +21 -0
- package/dist/combobox.d.ts +517 -0
- package/dist/combobox.js +531 -0
- package/dist/command.d.ts +322 -0
- package/dist/command.js +345 -0
- package/dist/controller-target.d.ts +49 -0
- package/dist/controller-target.js +112 -0
- package/dist/create-parts.d.ts +126 -0
- package/dist/create-parts.js +206 -0
- package/dist/date-input.d.ts +133 -0
- package/dist/date-input.js +31 -0
- package/dist/date-picker.d.ts +328 -0
- package/dist/date-picker.js +354 -0
- package/dist/date.d.ts +2 -0
- package/dist/date.js +59 -0
- package/dist/dialog-parts.d.ts +259 -0
- package/dist/dialog-parts.js +300 -0
- package/dist/dialog.d.ts +251 -0
- package/dist/dialog.js +25 -0
- package/dist/drawer.d.ts +304 -0
- package/dist/drawer.js +373 -0
- package/dist/editor-context.d.ts +4 -0
- package/dist/editor-context.js +5 -0
- package/dist/field-context.d.ts +26 -0
- package/dist/field-context.js +44 -0
- package/dist/field.d.ts +154 -0
- package/dist/field.js +240 -0
- package/dist/file-input.d.ts +212 -0
- package/dist/file-input.js +255 -0
- package/dist/form-inputs.d.ts +16 -0
- package/dist/form-inputs.js +25 -0
- package/dist/gesture.d.ts +1 -0
- package/dist/gesture.js +15 -0
- package/dist/history.d.ts +2 -0
- package/dist/history.js +11 -0
- package/dist/hover-card.d.ts +137 -0
- package/dist/hover-card.js +153 -0
- package/dist/image-cropper.d.ts +74 -0
- package/dist/image-cropper.js +36 -0
- package/dist/image.d.ts +2 -0
- package/dist/image.js +5 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +60 -0
- package/dist/input.d.ts +120 -0
- package/dist/input.js +73 -0
- package/dist/item-icon.d.ts +34 -0
- package/dist/item-icon.js +63 -0
- package/dist/label.d.ts +16 -0
- package/dist/label.js +8 -0
- package/dist/lifecycle.d.ts +11 -0
- package/dist/lifecycle.js +91 -0
- package/dist/list-items.d.ts +38 -0
- package/dist/list-items.js +59 -0
- package/dist/list-text.d.ts +7 -0
- package/dist/list-text.js +15 -0
- package/dist/listbox.d.ts +273 -0
- package/dist/listbox.js +126 -0
- package/dist/menu.d.ts +678 -0
- package/dist/menu.js +607 -0
- package/dist/menubar-context.d.ts +5 -0
- package/dist/menubar-context.js +5 -0
- package/dist/menubar.d.ts +61 -0
- package/dist/menubar.js +48 -0
- package/dist/meter.d.ts +41 -0
- package/dist/meter.js +37 -0
- package/dist/navigation-menu.d.ts +228 -0
- package/dist/navigation-menu.js +195 -0
- package/dist/number-input.d.ts +176 -0
- package/dist/number-input.js +231 -0
- package/dist/number.d.ts +2 -0
- package/dist/number.js +39 -0
- package/dist/nuxt/entries.json +977 -0
- package/dist/nuxt/module.d.ts +18 -0
- package/dist/nuxt/module.js +31 -0
- package/dist/nuxt/registrations.d.ts +22 -0
- package/dist/nuxt/registrations.js +22 -0
- package/dist/observe.d.ts +2 -0
- package/dist/observe.js +7 -0
- package/dist/otp-input.d.ts +142 -0
- package/dist/otp-input.js +130 -0
- package/dist/overlays.d.ts +40 -0
- package/dist/overlays.js +118 -0
- package/dist/pagination.d.ts +201 -0
- package/dist/pagination.js +146 -0
- package/dist/password-input.d.ts +144 -0
- package/dist/password-input.js +134 -0
- package/dist/popover.d.ts +211 -0
- package/dist/popover.js +258 -0
- package/dist/popup.d.ts +60 -0
- package/dist/popup.js +89 -0
- package/dist/preferences.d.ts +44 -0
- package/dist/preferences.js +102 -0
- package/dist/primitive.d.ts +2 -0
- package/dist/primitive.js +11 -0
- package/dist/progress.d.ts +41 -0
- package/dist/progress.js +37 -0
- package/dist/radio.d.ts +164 -0
- package/dist/radio.js +145 -0
- package/dist/rating.d.ts +149 -0
- package/dist/rating.js +146 -0
- package/dist/renderless.d.ts +4 -0
- package/dist/renderless.js +28 -0
- package/dist/resizable.d.ts +54 -0
- package/dist/resizable.js +22 -0
- package/dist/scroll-area.d.ts +72 -0
- package/dist/scroll-area.js +77 -0
- package/dist/segmented-control.d.ts +151 -0
- package/dist/segmented-control.js +110 -0
- package/dist/segmented-input.d.ts +76 -0
- package/dist/segmented-input.js +115 -0
- package/dist/select.d.ts +458 -0
- package/dist/select.js +468 -0
- package/dist/separator.d.ts +14 -0
- package/dist/separator.js +8 -0
- package/dist/shortcuts.d.ts +32 -0
- package/dist/shortcuts.js +56 -0
- package/dist/slider.d.ts +65 -0
- package/dist/slider.js +194 -0
- package/dist/switch.d.ts +103 -0
- package/dist/switch.js +71 -0
- package/dist/tabs.d.ts +338 -0
- package/dist/tabs.js +27 -0
- package/dist/text-control.d.ts +89 -0
- package/dist/text-control.js +51 -0
- package/dist/text-match.d.ts +2 -0
- package/dist/text-match.js +7 -0
- package/dist/textarea.d.ts +106 -0
- package/dist/textarea.js +68 -0
- package/dist/time-input.d.ts +131 -0
- package/dist/time-input.js +32 -0
- package/dist/timeline.d.ts +81 -0
- package/dist/timeline.js +30 -0
- package/dist/toast-parts.d.ts +203 -0
- package/dist/toast-parts.js +270 -0
- package/dist/toast.d.ts +2 -0
- package/dist/toast.js +21 -0
- package/dist/toggle-props.d.ts +22 -0
- package/dist/toggle-props.js +14 -0
- package/dist/toggle.d.ts +199 -0
- package/dist/toggle.js +129 -0
- package/dist/token-input.d.ts +136 -0
- package/dist/token-input.js +214 -0
- package/dist/toolbar-context.d.ts +7 -0
- package/dist/toolbar-context.js +20 -0
- package/dist/toolbar.d.ts +120 -0
- package/dist/toolbar.js +77 -0
- package/dist/tooltip.d.ts +160 -0
- package/dist/tooltip.js +224 -0
- package/dist/tree.d.ts +300 -0
- package/dist/tree.js +209 -0
- package/dist/trigger-menu.d.ts +452 -0
- package/dist/trigger-menu.js +254 -0
- package/dist/use-primitive.d.ts +132 -0
- package/dist/use-primitive.js +462 -0
- package/dist/waterfall.d.ts +201 -0
- package/dist/waterfall.js +171 -0
- package/docs/README.md +89 -0
- package/docs/agents.md +1523 -0
- package/docs/components/accordion.md +1369 -0
- package/docs/components/alert-dialog.md +799 -0
- package/docs/components/autocomplete.md +1857 -0
- package/docs/components/avatar.md +272 -0
- package/docs/components/button.md +435 -0
- package/docs/components/calendar.md +1589 -0
- package/docs/components/carousel.md +1171 -0
- package/docs/components/checkbox.md +1008 -0
- package/docs/components/collapsible.md +536 -0
- package/docs/components/color-picker.md +706 -0
- package/docs/components/combobox.md +3504 -0
- package/docs/components/command.md +1481 -0
- package/docs/components/date-input.md +536 -0
- package/docs/components/date-picker.md +1244 -0
- package/docs/components/dialog.md +1397 -0
- package/docs/components/drawer.md +1166 -0
- package/docs/components/field.md +538 -0
- package/docs/components/file-input.md +611 -0
- package/docs/components/hover-card.md +505 -0
- package/docs/components/image-cropper.md +556 -0
- package/docs/components/input.md +306 -0
- package/docs/components/label.md +203 -0
- package/docs/components/listbox.md +1004 -0
- package/docs/components/menu.md +1229 -0
- package/docs/components/menubar.md +443 -0
- package/docs/components/meter.md +315 -0
- package/docs/components/navigation-menu.md +1523 -0
- package/docs/components/number-input.md +1029 -0
- package/docs/components/otp-input.md +512 -0
- package/docs/components/pagination.md +613 -0
- package/docs/components/password-input.md +649 -0
- package/docs/components/popover.md +1448 -0
- package/docs/components/preferences.md +208 -0
- package/docs/components/progress.md +423 -0
- package/docs/components/radio.md +785 -0
- package/docs/components/rating.md +416 -0
- package/docs/components/resizable.md +910 -0
- package/docs/components/scroll-area.md +915 -0
- package/docs/components/segmented-control.md +435 -0
- package/docs/components/select.md +2015 -0
- package/docs/components/separator.md +229 -0
- package/docs/components/slider.md +1084 -0
- package/docs/components/switch.md +565 -0
- package/docs/components/tabs.md +944 -0
- package/docs/components/textarea.md +299 -0
- package/docs/components/time-input.md +224 -0
- package/docs/components/timeline.md +654 -0
- package/docs/components/toast.md +1224 -0
- package/docs/components/toggle.md +500 -0
- package/docs/components/token-input.md +953 -0
- package/docs/components/toolbar.md +739 -0
- package/docs/components/tooltip.md +818 -0
- package/docs/components/tree.md +1306 -0
- package/docs/components/trigger-menu.md +1223 -0
- package/docs/components/waterfall.md +717 -0
- package/docs/controllers.md +71 -0
- package/docs/core.md +8027 -0
- package/docs/custom-parts.md +89 -0
- package/docs/first-component.md +83 -0
- package/docs/forms.md +122 -0
- package/docs/installation.md +72 -0
- package/docs/introduction.md +32 -0
- package/docs/lists-and-menus.md +122 -0
- package/docs/llms.txt +1502 -0
- package/docs/parts-and-composition.md +85 -0
- package/docs/popups.md +108 -0
- package/docs/rendering.md +56 -0
- package/docs/server-rendering.md +180 -0
- package/docs/state-and-events.md +100 -0
- package/docs/styling-and-animation.md +148 -0
- package/docs/utilities/async-options.md +348 -0
- package/docs/utilities/shortcuts.md +159 -0
- package/package.json +352 -3
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { ChangeDetails } from "@ui-sdk/core";
|
|
2
|
+
import { type UndoStackOptions, type Token, type TokenCodec, type TokenDeletion, type TokenInputController, type TokenInputSubmitDetails, type TokenInputValue, type TokenInputValueChangeReason } from "@ui-sdk/core/token-input";
|
|
3
|
+
import { type PropType, type SlotsType, type VNode } from "vue";
|
|
4
|
+
import { type PartSlots } from "./use-primitive.js";
|
|
5
|
+
type ValueDetails = ChangeDetails<TokenInputValueChangeReason> & {
|
|
6
|
+
inputType?: string;
|
|
7
|
+
removed: Token[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A text field with atomic tokens. A TriggerMenu inside it suggests into it. The `token` slot renders each token's content.
|
|
11
|
+
* @stable
|
|
12
|
+
*/
|
|
13
|
+
declare const TokenInput: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
14
|
+
value: PropType<TokenInputValue>;
|
|
15
|
+
modelValue: PropType<TokenInputValue>;
|
|
16
|
+
defaultValue: PropType<TokenInputValue>;
|
|
17
|
+
submitShortcut: PropType<"enter" | "mod+enter">;
|
|
18
|
+
tokenDeletion: PropType<TokenDeletion>;
|
|
19
|
+
copy: PropType<"codec" | "label">;
|
|
20
|
+
codec: PropType<TokenCodec>;
|
|
21
|
+
getTokenDescription: PropType<(token: Token) => string>;
|
|
22
|
+
history: PropType<UndoStackOptions>;
|
|
23
|
+
disabled: {
|
|
24
|
+
type: BooleanConstructor;
|
|
25
|
+
default: undefined;
|
|
26
|
+
};
|
|
27
|
+
readOnly: {
|
|
28
|
+
type: BooleanConstructor;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
required: {
|
|
32
|
+
type: BooleanConstructor;
|
|
33
|
+
default: undefined;
|
|
34
|
+
};
|
|
35
|
+
name: StringConstructor;
|
|
36
|
+
form: StringConstructor;
|
|
37
|
+
controller: PropType<TokenInputController>;
|
|
38
|
+
debug: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
default: undefined;
|
|
41
|
+
};
|
|
42
|
+
onSubmit: PropType<(value: TokenInputValue, details: TokenInputSubmitDetails) => void>;
|
|
43
|
+
}>, () => (VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
}> | VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
}>[] | undefined)[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
48
|
+
"update:value": (_value: TokenInputValue) => true;
|
|
49
|
+
"update:modelValue": (_value: TokenInputValue) => true;
|
|
50
|
+
valueChange: (_value: TokenInputValue, _details: ValueDetails) => true;
|
|
51
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
52
|
+
value: PropType<TokenInputValue>;
|
|
53
|
+
modelValue: PropType<TokenInputValue>;
|
|
54
|
+
defaultValue: PropType<TokenInputValue>;
|
|
55
|
+
submitShortcut: PropType<"enter" | "mod+enter">;
|
|
56
|
+
tokenDeletion: PropType<TokenDeletion>;
|
|
57
|
+
copy: PropType<"codec" | "label">;
|
|
58
|
+
codec: PropType<TokenCodec>;
|
|
59
|
+
getTokenDescription: PropType<(token: Token) => string>;
|
|
60
|
+
history: PropType<UndoStackOptions>;
|
|
61
|
+
disabled: {
|
|
62
|
+
type: BooleanConstructor;
|
|
63
|
+
default: undefined;
|
|
64
|
+
};
|
|
65
|
+
readOnly: {
|
|
66
|
+
type: BooleanConstructor;
|
|
67
|
+
default: undefined;
|
|
68
|
+
};
|
|
69
|
+
required: {
|
|
70
|
+
type: BooleanConstructor;
|
|
71
|
+
default: undefined;
|
|
72
|
+
};
|
|
73
|
+
name: StringConstructor;
|
|
74
|
+
form: StringConstructor;
|
|
75
|
+
controller: PropType<TokenInputController>;
|
|
76
|
+
debug: {
|
|
77
|
+
type: BooleanConstructor;
|
|
78
|
+
default: undefined;
|
|
79
|
+
};
|
|
80
|
+
onSubmit: PropType<(value: TokenInputValue, details: TokenInputSubmitDetails) => void>;
|
|
81
|
+
}>> & Readonly<{
|
|
82
|
+
"onUpdate:modelValue"?: ((_value: TokenInputValue) => any) | undefined;
|
|
83
|
+
"onUpdate:value"?: ((_value: TokenInputValue) => any) | undefined;
|
|
84
|
+
onValueChange?: ((_value: TokenInputValue, _details: ValueDetails) => any) | undefined;
|
|
85
|
+
}>, {
|
|
86
|
+
disabled: boolean;
|
|
87
|
+
debug: boolean;
|
|
88
|
+
required: boolean;
|
|
89
|
+
readOnly: boolean;
|
|
90
|
+
}, SlotsType<{
|
|
91
|
+
default?: () => VNode[];
|
|
92
|
+
/** Renders each token's content: `#token="{ token }"`. */
|
|
93
|
+
token?: (scope: {
|
|
94
|
+
token: Token;
|
|
95
|
+
}) => VNode[];
|
|
96
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
97
|
+
/**
|
|
98
|
+
* The editable text. The core owns its content; style it, and show the placeholder with `data-empty`.
|
|
99
|
+
* @stable
|
|
100
|
+
*/
|
|
101
|
+
declare const TokenInputEditor: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
102
|
+
placeholder: StringConstructor;
|
|
103
|
+
}>, (() => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
104
|
+
[key: string]: any;
|
|
105
|
+
}> | VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
106
|
+
[key: string]: any;
|
|
107
|
+
}>[] | null) & {
|
|
108
|
+
state: NoInfer<import("@ui-sdk/core/token-input").TokenInputEditorState>;
|
|
109
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
110
|
+
placeholder: StringConstructor;
|
|
111
|
+
}>> & Readonly<{}>, {}, PartSlots<import("@ui-sdk/core/token-input").TokenInputPrimitive, "editor">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "div">;
|
|
112
|
+
/**
|
|
113
|
+
* A token's content, inside the `token` slot, with its state for styling.
|
|
114
|
+
* @stable
|
|
115
|
+
*/
|
|
116
|
+
declare const TokenInputToken: import("./create-parts.js").ElementPart<import("vue").DefineComponent<{}, (() => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
117
|
+
[key: string]: any;
|
|
118
|
+
}> | VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
119
|
+
[key: string]: any;
|
|
120
|
+
}>[] | null) & {
|
|
121
|
+
state: NoInfer<import("@ui-sdk/core/token-input").TokenInputTokenState>;
|
|
122
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, PartSlots<import("@ui-sdk/core/token-input").TokenInputPrimitive, "token">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "span">;
|
|
123
|
+
/**
|
|
124
|
+
* Removes its token when pressed. Hidden from assistive technology: the keyboard's way is Backspace.
|
|
125
|
+
* @stable
|
|
126
|
+
*/
|
|
127
|
+
declare const TokenInputTokenRemove: import("./create-parts.js").ElementPart<import("vue").DefineComponent<{}, (() => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
128
|
+
[key: string]: any;
|
|
129
|
+
}> | VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
130
|
+
[key: string]: any;
|
|
131
|
+
}>[] | null) & {
|
|
132
|
+
state: {};
|
|
133
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, PartSlots<import("@ui-sdk/core/token-input").TokenInputPrimitive, "token-remove">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "span">;
|
|
134
|
+
export { createTokenInputController, defaultCodec, fromText, toLabel, toText, } from "@ui-sdk/core/token-input";
|
|
135
|
+
export type { UndoStackOptions, TextEditorAdapter, TextRange, Token, TokenCodec, TokenDeletion, TokenInputApi, TokenInputChangeOptions, TokenInputController, TokenInputEditorProps, TokenInputEditorState, TokenInputOptions, TokenInputPrimitive, TokenInputTokenProps, TokenInputTokenState, TokenInputValue, TokenInputSubmitDetails, TokenInputValueChangeDetails, TokenInputValueChangeReason, TokenInsert, } from "@ui-sdk/core/token-input";
|
|
136
|
+
export { TokenInput, TokenInputEditor, TokenInputToken, TokenInputTokenRemove };
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// src/token-input.ts
|
|
2
|
+
import {
|
|
3
|
+
tokenInput as tokenInputPrimitive
|
|
4
|
+
} from "@ui-sdk/core/token-input";
|
|
5
|
+
import { renderStaticHtml, renderVersion } from "@ui-sdk/core/renderer";
|
|
6
|
+
import {
|
|
7
|
+
defineComponent,
|
|
8
|
+
h,
|
|
9
|
+
inject,
|
|
10
|
+
provide,
|
|
11
|
+
shallowRef,
|
|
12
|
+
onBeforeUpdate,
|
|
13
|
+
onScopeDispose,
|
|
14
|
+
Teleport,
|
|
15
|
+
toRaw
|
|
16
|
+
} from "vue";
|
|
17
|
+
import { withElement } from "./create-parts.js";
|
|
18
|
+
import { EditorKey } from "./editor-context.js";
|
|
19
|
+
import { useFieldControl } from "./field-context.js";
|
|
20
|
+
import {
|
|
21
|
+
optionalBoolean,
|
|
22
|
+
orModel,
|
|
23
|
+
useHandle,
|
|
24
|
+
usePart,
|
|
25
|
+
usePrimitive
|
|
26
|
+
} from "./use-primitive.js";
|
|
27
|
+
import { renderless } from "./renderless.js";
|
|
28
|
+
import { readOnlyOf } from "./text-control.js";
|
|
29
|
+
import {
|
|
30
|
+
createTokenInputController,
|
|
31
|
+
defaultCodec,
|
|
32
|
+
fromText,
|
|
33
|
+
toLabel,
|
|
34
|
+
toText
|
|
35
|
+
} from "@ui-sdk/core/token-input";
|
|
36
|
+
var TokenKey = /* @__PURE__ */ Symbol("token-input-token");
|
|
37
|
+
var useTokenInput = () => useHandle(tokenInputPrimitive);
|
|
38
|
+
function given(list) {
|
|
39
|
+
list?.forEach(() => {
|
|
40
|
+
});
|
|
41
|
+
return list && toRaw(list);
|
|
42
|
+
}
|
|
43
|
+
function useTokenId(part) {
|
|
44
|
+
const id = inject(TokenKey, null);
|
|
45
|
+
if (!id) {
|
|
46
|
+
throw new Error(`<${part}> must be used inside the token slot.`);
|
|
47
|
+
}
|
|
48
|
+
return id;
|
|
49
|
+
}
|
|
50
|
+
var TokenInput = /* @__PURE__ */ renderless(
|
|
51
|
+
defineComponent({
|
|
52
|
+
name: "TokenInput",
|
|
53
|
+
props: {
|
|
54
|
+
value: Array,
|
|
55
|
+
modelValue: Array,
|
|
56
|
+
defaultValue: Array,
|
|
57
|
+
submitShortcut: String,
|
|
58
|
+
tokenDeletion: String,
|
|
59
|
+
copy: String,
|
|
60
|
+
codec: Object,
|
|
61
|
+
getTokenDescription: Function,
|
|
62
|
+
history: Object,
|
|
63
|
+
disabled: optionalBoolean,
|
|
64
|
+
readOnly: optionalBoolean,
|
|
65
|
+
required: optionalBoolean,
|
|
66
|
+
name: String,
|
|
67
|
+
form: String,
|
|
68
|
+
controller: Object,
|
|
69
|
+
debug: optionalBoolean,
|
|
70
|
+
// A function prop, so `@submit` binds to it, and without one the shortcut submits the form.
|
|
71
|
+
onSubmit: Function
|
|
72
|
+
},
|
|
73
|
+
emits: {
|
|
74
|
+
"update:value": (_value) => true,
|
|
75
|
+
"update:modelValue": (_value) => true,
|
|
76
|
+
valueChange: (_value, _details) => true
|
|
77
|
+
},
|
|
78
|
+
slots: Object,
|
|
79
|
+
setup(props, { slots, attrs, emit }) {
|
|
80
|
+
const field = useFieldControl();
|
|
81
|
+
const input = usePrimitive(tokenInputPrimitive, () => ({
|
|
82
|
+
...props,
|
|
83
|
+
value: given(orModel(props.value, props.modelValue)),
|
|
84
|
+
defaultValue: props.defaultValue && toRaw(props.defaultValue),
|
|
85
|
+
name: props.name ?? field?.name(),
|
|
86
|
+
disabled: props.disabled || field?.disabled(),
|
|
87
|
+
readOnly: readOnlyOf(props, attrs),
|
|
88
|
+
onValueChange: (value, details) => {
|
|
89
|
+
emit("valueChange", value, details);
|
|
90
|
+
if (details.canceled) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
emit("update:value", value);
|
|
94
|
+
emit("update:modelValue", value);
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
97
|
+
provide(EditorKey, () => input.api.editor);
|
|
98
|
+
const version = shallowRef(renderVersion(input.instance));
|
|
99
|
+
onScopeDispose(
|
|
100
|
+
input.instance.subscribe(
|
|
101
|
+
() => version.value = renderVersion(input.instance)
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
input.api.internal.setCustom(!!slots.token);
|
|
105
|
+
onBeforeUpdate(() => input.api.internal.setCustom(!!slots.token));
|
|
106
|
+
return () => {
|
|
107
|
+
version.value;
|
|
108
|
+
return [
|
|
109
|
+
slots.default?.(),
|
|
110
|
+
slots.token && input.api.internal.hosts().map(
|
|
111
|
+
({ id, token, host }) => h(Teleport, { key: id, to: host }, [
|
|
112
|
+
h(TokenScope, { id }, () => slots.token({ token }))
|
|
113
|
+
])
|
|
114
|
+
),
|
|
115
|
+
h(FormInput)
|
|
116
|
+
];
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
var TokenScope = defineComponent({
|
|
122
|
+
name: "TokenInputTokenScope",
|
|
123
|
+
props: { id: { type: String, required: true } },
|
|
124
|
+
setup(props, { slots }) {
|
|
125
|
+
provide(TokenKey, props.id);
|
|
126
|
+
return () => slots.default?.();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
var FormInput = defineComponent({
|
|
130
|
+
name: "TokenInputFormInput",
|
|
131
|
+
setup() {
|
|
132
|
+
const input = useTokenInput();
|
|
133
|
+
return () => input.state.name ? h("textarea", input.slot("form-input")) : null;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
var TokenInputEditor = withElement(
|
|
137
|
+
"div",
|
|
138
|
+
defineComponent({
|
|
139
|
+
name: "TokenInputEditor",
|
|
140
|
+
inheritAttrs: false,
|
|
141
|
+
props: { placeholder: String },
|
|
142
|
+
slots: Object,
|
|
143
|
+
setup(props, { attrs }) {
|
|
144
|
+
const input = useTokenInput();
|
|
145
|
+
const field = useFieldControl(attrs);
|
|
146
|
+
const html = renderStaticHtml(
|
|
147
|
+
input.api.getValue(),
|
|
148
|
+
input.api.internal.describe
|
|
149
|
+
);
|
|
150
|
+
return usePart(
|
|
151
|
+
input,
|
|
152
|
+
"editor",
|
|
153
|
+
() => ({ placeholder: props.placeholder }),
|
|
154
|
+
void 0,
|
|
155
|
+
{
|
|
156
|
+
tag: "div",
|
|
157
|
+
// The core owns the content.
|
|
158
|
+
children: () => void 0,
|
|
159
|
+
extend: (editor) => {
|
|
160
|
+
const own = { ...editor, innerHTML: html };
|
|
161
|
+
return field ? field.props(own) : own;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
);
|
|
168
|
+
var TokenInputToken = withElement(
|
|
169
|
+
"span",
|
|
170
|
+
defineComponent({
|
|
171
|
+
name: "TokenInputToken",
|
|
172
|
+
inheritAttrs: false,
|
|
173
|
+
slots: Object,
|
|
174
|
+
setup() {
|
|
175
|
+
const id = useTokenId("TokenInputToken");
|
|
176
|
+
return usePart(
|
|
177
|
+
useTokenInput(),
|
|
178
|
+
"token",
|
|
179
|
+
() => ({ id, token: id }),
|
|
180
|
+
void 0,
|
|
181
|
+
"span"
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
);
|
|
186
|
+
var TokenInputTokenRemove = withElement(
|
|
187
|
+
"span",
|
|
188
|
+
defineComponent({
|
|
189
|
+
name: "TokenInputTokenRemove",
|
|
190
|
+
inheritAttrs: false,
|
|
191
|
+
slots: Object,
|
|
192
|
+
setup() {
|
|
193
|
+
const id = useTokenId("TokenInputTokenRemove");
|
|
194
|
+
return usePart(
|
|
195
|
+
useTokenInput(),
|
|
196
|
+
"token-remove",
|
|
197
|
+
() => ({ id, token: id }),
|
|
198
|
+
void 0,
|
|
199
|
+
"span"
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
);
|
|
204
|
+
export {
|
|
205
|
+
TokenInput,
|
|
206
|
+
TokenInputEditor,
|
|
207
|
+
TokenInputToken,
|
|
208
|
+
TokenInputTokenRemove,
|
|
209
|
+
createTokenInputController,
|
|
210
|
+
defaultCodec,
|
|
211
|
+
fromText,
|
|
212
|
+
toLabel,
|
|
213
|
+
toText
|
|
214
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { toolbar } from "@ui-sdk/core/toolbar";
|
|
2
|
+
import { type InjectionKey } from "vue";
|
|
3
|
+
import type { PrimitiveHandle } from "./use-primitive.js";
|
|
4
|
+
declare const ToolbarKey: InjectionKey<PrimitiveHandle<typeof toolbar>>;
|
|
5
|
+
declare const ToolbarGroupKey: InjectionKey<() => boolean>;
|
|
6
|
+
declare function useToolbarScope(): import("vue").ComputedRef<(() => import("@ui-sdk/core/renderer").RovingScope) | undefined>;
|
|
7
|
+
export { ToolbarGroupKey, ToolbarKey, useToolbarScope };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/toolbar-context.ts
|
|
2
|
+
import { computed, inject } from "vue";
|
|
3
|
+
var ToolbarKey = /* @__PURE__ */ Symbol("toolbar");
|
|
4
|
+
var ToolbarGroupKey = /* @__PURE__ */ Symbol("toolbar-group");
|
|
5
|
+
function useToolbarScope() {
|
|
6
|
+
const toolbar = inject(ToolbarKey, null);
|
|
7
|
+
const groupDisabled = inject(ToolbarGroupKey, () => false);
|
|
8
|
+
return computed(() => {
|
|
9
|
+
if (!toolbar) {
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
const disabled = groupDisabled();
|
|
13
|
+
return () => toolbar.api.internal.scopeIn(disabled);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
ToolbarGroupKey,
|
|
18
|
+
ToolbarKey,
|
|
19
|
+
useToolbarScope
|
|
20
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type ToolbarController, type ToolbarOrientation } from "@ui-sdk/core/toolbar";
|
|
2
|
+
import { type PropType } from "vue";
|
|
3
|
+
import { type PartSlots } from "./use-primitive.js";
|
|
4
|
+
/**
|
|
5
|
+
* A row of controls with one tab stop and arrow keys between them. Toggles and
|
|
6
|
+
* toggle groups inside join it. Render menu and select triggers through
|
|
7
|
+
* `ToolbarButton`, and fields through `ToolbarInput`, with the `render` slot.
|
|
8
|
+
* @stable
|
|
9
|
+
*/
|
|
10
|
+
declare const Toolbar: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
11
|
+
orientation: PropType<ToolbarOrientation>;
|
|
12
|
+
loop: {
|
|
13
|
+
type: BooleanConstructor;
|
|
14
|
+
default: undefined;
|
|
15
|
+
};
|
|
16
|
+
disabled: {
|
|
17
|
+
type: BooleanConstructor;
|
|
18
|
+
default: undefined;
|
|
19
|
+
};
|
|
20
|
+
controller: PropType<ToolbarController>;
|
|
21
|
+
debug: {
|
|
22
|
+
type: BooleanConstructor;
|
|
23
|
+
default: undefined;
|
|
24
|
+
};
|
|
25
|
+
}>, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}>[] | null) & {
|
|
30
|
+
state: NoInfer<import("@ui-sdk/core/toolbar").ToolbarState>;
|
|
31
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
32
|
+
orientation: PropType<ToolbarOrientation>;
|
|
33
|
+
loop: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
default: undefined;
|
|
36
|
+
};
|
|
37
|
+
disabled: {
|
|
38
|
+
type: BooleanConstructor;
|
|
39
|
+
default: undefined;
|
|
40
|
+
};
|
|
41
|
+
controller: PropType<ToolbarController>;
|
|
42
|
+
debug: {
|
|
43
|
+
type: BooleanConstructor;
|
|
44
|
+
default: undefined;
|
|
45
|
+
};
|
|
46
|
+
}>> & Readonly<{}>, {
|
|
47
|
+
disabled: boolean;
|
|
48
|
+
debug: boolean;
|
|
49
|
+
loop: boolean;
|
|
50
|
+
}, PartSlots<import("@ui-sdk/core/toolbar").ToolbarPrimitive, "root">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "div">;
|
|
51
|
+
/**
|
|
52
|
+
* A button in the toolbar. Arrow keys move between it and the toolbar's other items.
|
|
53
|
+
* @stable
|
|
54
|
+
*/
|
|
55
|
+
declare const ToolbarButton: Pick<import("vue").DefineSetupFnComponent<Omit<NoInfer<{
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
focusableWhenDisabled?: boolean;
|
|
58
|
+
groupDisabled?: boolean;
|
|
59
|
+
}> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/toolbar").ToolbarButtonState>>>, never> & import("./create-parts.js").ElementConstructor<import("vue").DefineSetupFnComponent<Omit<NoInfer<{
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
focusableWhenDisabled?: boolean;
|
|
62
|
+
groupDisabled?: boolean;
|
|
63
|
+
}> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/toolbar").ToolbarButtonState>>>, "button">;
|
|
64
|
+
/**
|
|
65
|
+
* A text field. Arrows move its caret, and leave it only from the end they point at.
|
|
66
|
+
* @stable
|
|
67
|
+
*/
|
|
68
|
+
declare const ToolbarInput: Pick<import("vue").DefineSetupFnComponent<Omit<NoInfer<{
|
|
69
|
+
disabled?: boolean;
|
|
70
|
+
focusableWhenDisabled?: boolean;
|
|
71
|
+
groupDisabled?: boolean;
|
|
72
|
+
}> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/toolbar").ToolbarButtonState>>>, never> & import("./create-parts.js").ElementConstructor<import("vue").DefineSetupFnComponent<Omit<NoInfer<{
|
|
73
|
+
disabled?: boolean;
|
|
74
|
+
focusableWhenDisabled?: boolean;
|
|
75
|
+
groupDisabled?: boolean;
|
|
76
|
+
}> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/toolbar").ToolbarButtonState>>>, "input">;
|
|
77
|
+
/**
|
|
78
|
+
* A link in the toolbar. Arrow keys move between it and the toolbar's other items.
|
|
79
|
+
* @stable
|
|
80
|
+
*/
|
|
81
|
+
declare const ToolbarLink: Pick<import("vue").DefineSetupFnComponent<Omit<NoInfer<Pick<{
|
|
82
|
+
disabled?: boolean;
|
|
83
|
+
focusableWhenDisabled?: boolean;
|
|
84
|
+
groupDisabled?: boolean;
|
|
85
|
+
}, "groupDisabled">> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/toolbar").ToolbarLinkState>>>, never> & import("./create-parts.js").ElementConstructor<import("vue").DefineSetupFnComponent<Omit<NoInfer<Pick<{
|
|
86
|
+
disabled?: boolean;
|
|
87
|
+
focusableWhenDisabled?: boolean;
|
|
88
|
+
groupDisabled?: boolean;
|
|
89
|
+
}, "groupDisabled">> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/toolbar").ToolbarLinkState>>>, "a">;
|
|
90
|
+
/**
|
|
91
|
+
* A group of related items in the toolbar. `disabled` disables every item in it.
|
|
92
|
+
* @stable
|
|
93
|
+
*/
|
|
94
|
+
declare const ToolbarGroup: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
95
|
+
disabled: {
|
|
96
|
+
type: BooleanConstructor;
|
|
97
|
+
default: undefined;
|
|
98
|
+
};
|
|
99
|
+
}>, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
100
|
+
[key: string]: any;
|
|
101
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
}>[] | null) & {
|
|
104
|
+
state: NoInfer<import("@ui-sdk/core/toolbar").ToolbarGroupState>;
|
|
105
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
106
|
+
disabled: {
|
|
107
|
+
type: BooleanConstructor;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
}>> & Readonly<{}>, {
|
|
111
|
+
disabled: boolean;
|
|
112
|
+
}, PartSlots<import("@ui-sdk/core/toolbar").ToolbarPrimitive, "group">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "div">;
|
|
113
|
+
/**
|
|
114
|
+
* A line between groups of items.
|
|
115
|
+
* @stable
|
|
116
|
+
*/
|
|
117
|
+
declare const ToolbarSeparator: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/toolbar").ToolbarSeparatorState>>>, never> & import("./create-parts.js").ElementConstructor<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/toolbar").ToolbarSeparatorState>>>, "div">;
|
|
118
|
+
export { createToolbarController } from "@ui-sdk/core/toolbar";
|
|
119
|
+
export type { ToolbarApi, ToolbarButtonProps, ToolbarButtonState, ToolbarController, ToolbarGroupProps, ToolbarGroupState, ToolbarInputProps, ToolbarInputState, ToolbarLinkState, ToolbarOptions, ToolbarOrientation, ToolbarPrimitive, ToolbarState, ToolbarSeparatorState, } from "@ui-sdk/core/toolbar";
|
|
120
|
+
export { Toolbar, ToolbarButton, ToolbarGroup, ToolbarInput, ToolbarLink, ToolbarSeparator, };
|
package/dist/toolbar.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/toolbar.ts
|
|
2
|
+
import {
|
|
3
|
+
toolbar as toolbarPrimitive
|
|
4
|
+
} from "@ui-sdk/core/toolbar";
|
|
5
|
+
import { computed, defineComponent, provide, useId } from "vue";
|
|
6
|
+
import { ToolbarGroupKey, ToolbarKey } from "./toolbar-context.js";
|
|
7
|
+
import { createParts, withElement } from "./create-parts.js";
|
|
8
|
+
import {
|
|
9
|
+
optionalBoolean,
|
|
10
|
+
provideProps,
|
|
11
|
+
usePart,
|
|
12
|
+
usePrimitive
|
|
13
|
+
} from "./use-primitive.js";
|
|
14
|
+
import { createToolbarController } from "@ui-sdk/core/toolbar";
|
|
15
|
+
var parts = createParts(toolbarPrimitive, {
|
|
16
|
+
button: "button",
|
|
17
|
+
input: "input",
|
|
18
|
+
link: "a",
|
|
19
|
+
separator: "div"
|
|
20
|
+
});
|
|
21
|
+
var Toolbar = withElement(
|
|
22
|
+
"div",
|
|
23
|
+
defineComponent({
|
|
24
|
+
name: "Toolbar",
|
|
25
|
+
inheritAttrs: false,
|
|
26
|
+
props: {
|
|
27
|
+
orientation: String,
|
|
28
|
+
loop: optionalBoolean,
|
|
29
|
+
disabled: optionalBoolean,
|
|
30
|
+
controller: Object,
|
|
31
|
+
debug: optionalBoolean
|
|
32
|
+
},
|
|
33
|
+
slots: Object,
|
|
34
|
+
setup(props) {
|
|
35
|
+
const toolbar = usePrimitive(toolbarPrimitive, () => ({
|
|
36
|
+
orientation: props.orientation,
|
|
37
|
+
loop: props.loop,
|
|
38
|
+
disabled: props.disabled,
|
|
39
|
+
controller: props.controller,
|
|
40
|
+
debug: props.debug
|
|
41
|
+
}));
|
|
42
|
+
provide(ToolbarKey, toolbar);
|
|
43
|
+
return usePart(toolbar, "root", void 0, void 0, "div");
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
var ToolbarButton = parts.Button;
|
|
48
|
+
var ToolbarInput = parts.Input;
|
|
49
|
+
var ToolbarLink = parts.Link;
|
|
50
|
+
var ToolbarGroup = withElement(
|
|
51
|
+
"div",
|
|
52
|
+
defineComponent({
|
|
53
|
+
name: "ToolbarGroup",
|
|
54
|
+
inheritAttrs: false,
|
|
55
|
+
props: { disabled: optionalBoolean },
|
|
56
|
+
slots: Object,
|
|
57
|
+
setup(props) {
|
|
58
|
+
const id = useId();
|
|
59
|
+
const group = () => ({ id, disabled: props.disabled });
|
|
60
|
+
provideProps(toolbarPrimitive, "group", group);
|
|
61
|
+
const part = usePart(toolbarPrimitive, "group", group);
|
|
62
|
+
const disabled = computed(() => part.state.disabled);
|
|
63
|
+
provide(ToolbarGroupKey, () => disabled.value);
|
|
64
|
+
return part;
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
var ToolbarSeparator = parts.Separator;
|
|
69
|
+
export {
|
|
70
|
+
Toolbar,
|
|
71
|
+
ToolbarButton,
|
|
72
|
+
ToolbarGroup,
|
|
73
|
+
ToolbarInput,
|
|
74
|
+
ToolbarLink,
|
|
75
|
+
ToolbarSeparator,
|
|
76
|
+
createToolbarController
|
|
77
|
+
};
|