@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,18 @@
|
|
|
1
|
+
import type { NuxtModule } from "@nuxt/schema";
|
|
2
|
+
/**
|
|
3
|
+
* The options of the Nuxt module, set under `uiSdk` in `nuxt.config.ts`.
|
|
4
|
+
* @experimental
|
|
5
|
+
*/
|
|
6
|
+
interface ModuleOptions {
|
|
7
|
+
/** Prepended to every component's name, so `"U"` registers `<UDialogTrigger>`. Empty by default. */
|
|
8
|
+
prefix?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The Nuxt module: every part of every entry becomes an auto-imported
|
|
12
|
+
* component, and the controllers and helpers become auto-imports in `<script>`.
|
|
13
|
+
* Add `"@ui-sdk/vue"` to `modules` in `nuxt.config.ts`.
|
|
14
|
+
* @experimental
|
|
15
|
+
*/
|
|
16
|
+
declare const uiSdk: NuxtModule<ModuleOptions>;
|
|
17
|
+
export type { ModuleOptions };
|
|
18
|
+
export default uiSdk;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// nuxt/module.ts
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { addComponent, addImportsSources, defineNuxtModule } from "@nuxt/kit";
|
|
4
|
+
import { nuxtRegistrations } from "./registrations.js";
|
|
5
|
+
var uiSdk = defineNuxtModule({
|
|
6
|
+
meta: {
|
|
7
|
+
name: "@ui-sdk/vue",
|
|
8
|
+
configKey: "uiSdk",
|
|
9
|
+
compatibility: { nuxt: "^4.0.0 || ^5.0.0-0" }
|
|
10
|
+
},
|
|
11
|
+
defaults: { prefix: "" },
|
|
12
|
+
setup(options) {
|
|
13
|
+
const { components, imports } = nuxtRegistrations(
|
|
14
|
+
readEntries(),
|
|
15
|
+
options.prefix ?? ""
|
|
16
|
+
);
|
|
17
|
+
for (const component of components) {
|
|
18
|
+
addComponent(component);
|
|
19
|
+
}
|
|
20
|
+
addImportsSources(imports);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function readEntries() {
|
|
24
|
+
const built = new URL("./entries.json", import.meta.url);
|
|
25
|
+
const file = existsSync(built) ? built : new URL("../dist/nuxt/entries.json", import.meta.url);
|
|
26
|
+
return JSON.parse(readFileSync(file, "utf8"));
|
|
27
|
+
}
|
|
28
|
+
var module_default = uiSdk;
|
|
29
|
+
export {
|
|
30
|
+
module_default as default
|
|
31
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** What one entry of `@ui-sdk/vue` gives a Nuxt app, as the build lists it in `entries.json`. */
|
|
2
|
+
interface NuxtEntry {
|
|
3
|
+
/** The entry's specifier, like `@ui-sdk/vue/dialog`. */
|
|
4
|
+
from: string;
|
|
5
|
+
/** The components the entry exports, like `DialogTrigger`. */
|
|
6
|
+
components: string[];
|
|
7
|
+
/** The other values the entry exports, like `createDialogController`. */
|
|
8
|
+
imports: string[];
|
|
9
|
+
}
|
|
10
|
+
declare function nuxtRegistrations(entries: NuxtEntry[], prefix: string): {
|
|
11
|
+
components: {
|
|
12
|
+
name: string;
|
|
13
|
+
export: string;
|
|
14
|
+
filePath: string;
|
|
15
|
+
}[];
|
|
16
|
+
imports: {
|
|
17
|
+
from: string;
|
|
18
|
+
imports: string[];
|
|
19
|
+
priority: number;
|
|
20
|
+
}[];
|
|
21
|
+
};
|
|
22
|
+
export { type NuxtEntry, nuxtRegistrations };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// nuxt/registrations.ts
|
|
2
|
+
function nuxtRegistrations(entries, prefix) {
|
|
3
|
+
return {
|
|
4
|
+
components: entries.flatMap(
|
|
5
|
+
({ from, components }) => components.map((name) => ({
|
|
6
|
+
name: `${prefix}${name}`,
|
|
7
|
+
export: name,
|
|
8
|
+
filePath: from
|
|
9
|
+
}))
|
|
10
|
+
),
|
|
11
|
+
// Below the app's own imports and every layer's (0, -1, -2…), so their
|
|
12
|
+
// `utils/` win over a ui-sdk name like `clamp` instead of losing silently.
|
|
13
|
+
imports: entries.filter(({ imports }) => imports.length).map(({ from, imports }) => ({
|
|
14
|
+
from,
|
|
15
|
+
imports,
|
|
16
|
+
priority: Number.MIN_SAFE_INTEGER
|
|
17
|
+
}))
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
nuxtRegistrations
|
|
22
|
+
};
|
package/dist/observe.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { ChangeDetails, CommitDetails } from "@ui-sdk/core";
|
|
2
|
+
import { type OTPInputController, type OTPInputOptions, type OTPInputPattern, type OTPInputValueChangeReason } from "@ui-sdk/core/otp-input";
|
|
3
|
+
import { type PropType } from "vue";
|
|
4
|
+
import { type PartSlots } from "./use-primitive.js";
|
|
5
|
+
/**
|
|
6
|
+
* The root: the slots, and the one real input over them. `id`, `autofocus`
|
|
7
|
+
* and the `aria-*` naming attributes go to that input.
|
|
8
|
+
* @stable
|
|
9
|
+
*/
|
|
10
|
+
declare const OTPInput: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
11
|
+
value: {
|
|
12
|
+
type: StringConstructor;
|
|
13
|
+
default: undefined;
|
|
14
|
+
};
|
|
15
|
+
modelValue: {
|
|
16
|
+
type: StringConstructor;
|
|
17
|
+
default: undefined;
|
|
18
|
+
};
|
|
19
|
+
defaultValue: {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
default: undefined;
|
|
22
|
+
};
|
|
23
|
+
maxLength: NumberConstructor;
|
|
24
|
+
pattern: PropType<OTPInputPattern>;
|
|
25
|
+
inputMode: PropType<OTPInputOptions["inputMode"]>;
|
|
26
|
+
textAlign: PropType<OTPInputOptions["textAlign"]>;
|
|
27
|
+
autoComplete: StringConstructor;
|
|
28
|
+
disabled: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
default: undefined;
|
|
31
|
+
};
|
|
32
|
+
readOnly: {
|
|
33
|
+
type: BooleanConstructor;
|
|
34
|
+
default: undefined;
|
|
35
|
+
};
|
|
36
|
+
required: {
|
|
37
|
+
type: BooleanConstructor;
|
|
38
|
+
default: undefined;
|
|
39
|
+
};
|
|
40
|
+
name: StringConstructor;
|
|
41
|
+
form: StringConstructor;
|
|
42
|
+
controller: PropType<OTPInputController>;
|
|
43
|
+
debug: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
default: undefined;
|
|
46
|
+
};
|
|
47
|
+
}>, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}>[] | null) & {
|
|
52
|
+
state: NoInfer<import("@ui-sdk/core/otp-input").OTPInputState>;
|
|
53
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
54
|
+
"update:value": (_value: string) => true;
|
|
55
|
+
"update:modelValue": (_value: string) => true;
|
|
56
|
+
valueChange: (_value: string, _details: ChangeDetails<OTPInputValueChangeReason>) => true;
|
|
57
|
+
valueCommit: (_value: string, _details: CommitDetails<OTPInputValueChangeReason>) => true;
|
|
58
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
59
|
+
value: {
|
|
60
|
+
type: StringConstructor;
|
|
61
|
+
default: undefined;
|
|
62
|
+
};
|
|
63
|
+
modelValue: {
|
|
64
|
+
type: StringConstructor;
|
|
65
|
+
default: undefined;
|
|
66
|
+
};
|
|
67
|
+
defaultValue: {
|
|
68
|
+
type: StringConstructor;
|
|
69
|
+
default: undefined;
|
|
70
|
+
};
|
|
71
|
+
maxLength: NumberConstructor;
|
|
72
|
+
pattern: PropType<OTPInputPattern>;
|
|
73
|
+
inputMode: PropType<OTPInputOptions["inputMode"]>;
|
|
74
|
+
textAlign: PropType<OTPInputOptions["textAlign"]>;
|
|
75
|
+
autoComplete: StringConstructor;
|
|
76
|
+
disabled: {
|
|
77
|
+
type: BooleanConstructor;
|
|
78
|
+
default: undefined;
|
|
79
|
+
};
|
|
80
|
+
readOnly: {
|
|
81
|
+
type: BooleanConstructor;
|
|
82
|
+
default: undefined;
|
|
83
|
+
};
|
|
84
|
+
required: {
|
|
85
|
+
type: BooleanConstructor;
|
|
86
|
+
default: undefined;
|
|
87
|
+
};
|
|
88
|
+
name: StringConstructor;
|
|
89
|
+
form: StringConstructor;
|
|
90
|
+
controller: PropType<OTPInputController>;
|
|
91
|
+
debug: {
|
|
92
|
+
type: BooleanConstructor;
|
|
93
|
+
default: undefined;
|
|
94
|
+
};
|
|
95
|
+
}>> & Readonly<{
|
|
96
|
+
"onUpdate:modelValue"?: ((_value: string) => any) | undefined;
|
|
97
|
+
"onUpdate:value"?: ((_value: string) => any) | undefined;
|
|
98
|
+
onValueChange?: ((_value: string, _details: ChangeDetails<OTPInputValueChangeReason>) => any) | undefined;
|
|
99
|
+
onValueCommit?: ((_value: string, _details: CommitDetails<OTPInputValueChangeReason>) => any) | undefined;
|
|
100
|
+
}>, {
|
|
101
|
+
value: string;
|
|
102
|
+
disabled: boolean;
|
|
103
|
+
debug: boolean;
|
|
104
|
+
defaultValue: string;
|
|
105
|
+
required: boolean;
|
|
106
|
+
readOnly: boolean;
|
|
107
|
+
modelValue: string;
|
|
108
|
+
}, PartSlots<import("@ui-sdk/core/otp-input").OtpInputPrimitive, "root">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "div">;
|
|
109
|
+
/**
|
|
110
|
+
* Lays out a run of slots.
|
|
111
|
+
* @stable
|
|
112
|
+
*/
|
|
113
|
+
declare const OTPInputGroup: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/otp-input").OTPInputState>>>, 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/otp-input").OTPInputState>>>, "div">;
|
|
114
|
+
/**
|
|
115
|
+
* Drawn between groups, like a dash.
|
|
116
|
+
* @stable
|
|
117
|
+
*/
|
|
118
|
+
declare const OTPInputSeparator: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/otp-input").OTPInputState>>>, 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/otp-input").OTPInputState>>>, "div">;
|
|
119
|
+
/**
|
|
120
|
+
* One character of the code. Without content, it shows the character.
|
|
121
|
+
* @stable
|
|
122
|
+
*/
|
|
123
|
+
declare const OTPInputSlot: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
124
|
+
index: {
|
|
125
|
+
type: NumberConstructor;
|
|
126
|
+
required: true;
|
|
127
|
+
};
|
|
128
|
+
}>, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
129
|
+
[key: string]: any;
|
|
130
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
131
|
+
[key: string]: any;
|
|
132
|
+
}>[] | null) & {
|
|
133
|
+
state: NoInfer<import("@ui-sdk/core/otp-input").OTPInputSlotState>;
|
|
134
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
135
|
+
index: {
|
|
136
|
+
type: NumberConstructor;
|
|
137
|
+
required: true;
|
|
138
|
+
};
|
|
139
|
+
}>> & Readonly<{}>, {}, PartSlots<import("@ui-sdk/core/otp-input").OtpInputPrimitive, "slot">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "div">;
|
|
140
|
+
export { createOTPInputController } from "@ui-sdk/core/otp-input";
|
|
141
|
+
export type { OTPInputApi, OTPInputChangeOptions, OTPInputController, OTPInputOptions, OTPInputPattern, OTPInputSlotData, OTPInputSlotProps, OTPInputSlotState, OTPInputState, OTPInputValueChangeReason, OtpInputPrimitive, } from "@ui-sdk/core/otp-input";
|
|
142
|
+
export { OTPInput, OTPInputGroup, OTPInputSeparator, OTPInputSlot };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// src/otp-input.ts
|
|
2
|
+
import {
|
|
3
|
+
otpInput as otpInputPrimitive
|
|
4
|
+
} from "@ui-sdk/core/otp-input";
|
|
5
|
+
import { defineComponent, h } from "vue";
|
|
6
|
+
import { slotContent } from "./children.js";
|
|
7
|
+
import { useFieldControl } from "./field-context.js";
|
|
8
|
+
import { createParts, withElement } from "./create-parts.js";
|
|
9
|
+
import {
|
|
10
|
+
optionalBoolean,
|
|
11
|
+
orModel,
|
|
12
|
+
useHandle,
|
|
13
|
+
usePart,
|
|
14
|
+
usePrimitive
|
|
15
|
+
} from "./use-primitive.js";
|
|
16
|
+
import { readOnlyOf } from "./text-control.js";
|
|
17
|
+
import { createOTPInputController } from "@ui-sdk/core/otp-input";
|
|
18
|
+
var parts = createParts(otpInputPrimitive, { group: "div", separator: "div" });
|
|
19
|
+
var inputAttributes = [
|
|
20
|
+
"id",
|
|
21
|
+
"autofocus",
|
|
22
|
+
"aria-label",
|
|
23
|
+
"aria-labelledby",
|
|
24
|
+
"aria-describedby",
|
|
25
|
+
"aria-invalid"
|
|
26
|
+
];
|
|
27
|
+
var OTPInput = withElement(
|
|
28
|
+
"div",
|
|
29
|
+
defineComponent({
|
|
30
|
+
name: "OTPInput",
|
|
31
|
+
inheritAttrs: false,
|
|
32
|
+
props: {
|
|
33
|
+
value: { type: String, default: void 0 },
|
|
34
|
+
modelValue: { type: String, default: void 0 },
|
|
35
|
+
defaultValue: { type: String, default: void 0 },
|
|
36
|
+
maxLength: Number,
|
|
37
|
+
pattern: [String, RegExp],
|
|
38
|
+
inputMode: String,
|
|
39
|
+
textAlign: String,
|
|
40
|
+
autoComplete: String,
|
|
41
|
+
disabled: optionalBoolean,
|
|
42
|
+
readOnly: optionalBoolean,
|
|
43
|
+
required: optionalBoolean,
|
|
44
|
+
name: String,
|
|
45
|
+
form: String,
|
|
46
|
+
controller: Object,
|
|
47
|
+
debug: optionalBoolean
|
|
48
|
+
},
|
|
49
|
+
emits: {
|
|
50
|
+
"update:value": (_value) => true,
|
|
51
|
+
"update:modelValue": (_value) => true,
|
|
52
|
+
valueChange: (_value, _details) => true,
|
|
53
|
+
valueCommit: (_value, _details) => true
|
|
54
|
+
},
|
|
55
|
+
slots: Object,
|
|
56
|
+
setup(props, { slots, attrs, emit }) {
|
|
57
|
+
const field = useFieldControl();
|
|
58
|
+
const otp = usePrimitive(otpInputPrimitive, () => ({
|
|
59
|
+
value: orModel(props.value, props.modelValue),
|
|
60
|
+
defaultValue: props.defaultValue,
|
|
61
|
+
maxLength: props.maxLength,
|
|
62
|
+
pattern: props.pattern,
|
|
63
|
+
inputMode: props.inputMode,
|
|
64
|
+
textAlign: props.textAlign,
|
|
65
|
+
autoComplete: props.autoComplete,
|
|
66
|
+
disabled: props.disabled || field?.disabled(),
|
|
67
|
+
readOnly: readOnlyOf(props, attrs),
|
|
68
|
+
required: props.required,
|
|
69
|
+
name: props.name ?? field?.name(),
|
|
70
|
+
form: props.form,
|
|
71
|
+
controller: props.controller,
|
|
72
|
+
debug: props.debug,
|
|
73
|
+
onValueChange: (value, details) => {
|
|
74
|
+
emit("valueChange", value, details);
|
|
75
|
+
if (details.canceled) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
emit("update:value", value);
|
|
79
|
+
emit("update:modelValue", value);
|
|
80
|
+
},
|
|
81
|
+
onValueCommit: (value, details) => emit("valueCommit", value, details)
|
|
82
|
+
}));
|
|
83
|
+
let named = {};
|
|
84
|
+
const own = () => {
|
|
85
|
+
const rest = {};
|
|
86
|
+
named = {};
|
|
87
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
88
|
+
;
|
|
89
|
+
(inputAttributes.includes(key) ? named : rest)[key] = value;
|
|
90
|
+
}
|
|
91
|
+
return rest;
|
|
92
|
+
};
|
|
93
|
+
return usePart(otp, "root", void 0, own, {
|
|
94
|
+
tag: "div",
|
|
95
|
+
children: (state) => {
|
|
96
|
+
const input = otp.slot("control", {}, named);
|
|
97
|
+
return [
|
|
98
|
+
slots.default?.({ state }),
|
|
99
|
+
h("input", field ? field.props(input) : input)
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
);
|
|
106
|
+
var OTPInputGroup = parts.Group;
|
|
107
|
+
var OTPInputSeparator = parts.Separator;
|
|
108
|
+
var OTPInputSlot = withElement(
|
|
109
|
+
"div",
|
|
110
|
+
defineComponent({
|
|
111
|
+
name: "OTPInputSlot",
|
|
112
|
+
inheritAttrs: false,
|
|
113
|
+
props: { index: { type: Number, required: true } },
|
|
114
|
+
slots: Object,
|
|
115
|
+
setup(props, { slots }) {
|
|
116
|
+
const part = () => ({ index: props.index, id: String(props.index) });
|
|
117
|
+
return usePart(useHandle(otpInputPrimitive), "slot", part, void 0, {
|
|
118
|
+
tag: "div",
|
|
119
|
+
children: (state) => slotContent(slots.default, { state }) ?? state.char
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
export {
|
|
125
|
+
OTPInput,
|
|
126
|
+
OTPInputGroup,
|
|
127
|
+
OTPInputSeparator,
|
|
128
|
+
OTPInputSlot,
|
|
129
|
+
createOTPInputController
|
|
130
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Overlays } from "@ui-sdk/core/overlays";
|
|
2
|
+
import type { ToastItem } from "@ui-sdk/core/toast";
|
|
3
|
+
import { type PropType, type SlotsType, type VNode } from "vue";
|
|
4
|
+
import { type ToastContent } from "./toast-parts.js";
|
|
5
|
+
/**
|
|
6
|
+
* Props for the toast regions the overlay host renders: the region's props and attributes, like `class`.
|
|
7
|
+
* @stable
|
|
8
|
+
*/
|
|
9
|
+
type OverlayHostToastProps = {
|
|
10
|
+
side?: "top" | "bottom";
|
|
11
|
+
align?: "start" | "center" | "end";
|
|
12
|
+
max?: number;
|
|
13
|
+
expanded?: boolean;
|
|
14
|
+
shortcut?: string | null;
|
|
15
|
+
[attribute: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Renders what `toast()` and `confirm()` open, from anywhere in the app.
|
|
19
|
+
* Mount it once, near the root. A `ToastRegion` you place yourself takes over
|
|
20
|
+
* its toaster.
|
|
21
|
+
* @stable
|
|
22
|
+
*/
|
|
23
|
+
declare const OverlayHost: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
24
|
+
overlays: PropType<Overlays>;
|
|
25
|
+
toast: PropType<OverlayHostToastProps>;
|
|
26
|
+
}>, () => (VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}> | null)[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
29
|
+
overlays: PropType<Overlays>;
|
|
30
|
+
toast: PropType<OverlayHostToastProps>;
|
|
31
|
+
}>> & Readonly<{}>, {}, SlotsType<{
|
|
32
|
+
/** Renders each toast of the regions it renders, like a `ToastRegion`'s default slot: `#toast="{ toast }"`. */
|
|
33
|
+
toast?: (scope: {
|
|
34
|
+
toast: ToastItem<ToastContent>["toast"];
|
|
35
|
+
item: ToastItem<ToastContent>;
|
|
36
|
+
}) => VNode[];
|
|
37
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
38
|
+
export { createOverlays, overlays } from "@ui-sdk/core/overlays";
|
|
39
|
+
export type { OverlayEntry, Overlays } from "@ui-sdk/core/overlays";
|
|
40
|
+
export { OverlayHost, type OverlayHostToastProps };
|
package/dist/overlays.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// src/overlays.ts
|
|
2
|
+
import { toasterInternals } from "@ui-sdk/core/renderer";
|
|
3
|
+
import {
|
|
4
|
+
overlays as sharedOverlays
|
|
5
|
+
} from "@ui-sdk/core/overlays";
|
|
6
|
+
import {
|
|
7
|
+
defineComponent,
|
|
8
|
+
h,
|
|
9
|
+
onBeforeUnmount,
|
|
10
|
+
onMounted,
|
|
11
|
+
onScopeDispose,
|
|
12
|
+
shallowRef
|
|
13
|
+
} from "vue";
|
|
14
|
+
import {
|
|
15
|
+
AlertDialog,
|
|
16
|
+
AlertDialogClose,
|
|
17
|
+
AlertDialogContent,
|
|
18
|
+
AlertDialogDescription,
|
|
19
|
+
AlertDialogTitle
|
|
20
|
+
} from "./alert-dialog.js";
|
|
21
|
+
import { HostedToastRegion } from "./toast-parts.js";
|
|
22
|
+
import { createOverlays, overlays } from "@ui-sdk/core/overlays";
|
|
23
|
+
var HostedToaster = defineComponent({
|
|
24
|
+
name: "HostedToaster",
|
|
25
|
+
props: {
|
|
26
|
+
toaster: { type: Function, required: true },
|
|
27
|
+
regionProps: Object,
|
|
28
|
+
renderToast: Function
|
|
29
|
+
},
|
|
30
|
+
setup(props) {
|
|
31
|
+
const placed = shallowRef(toasterInternals(props.toaster).hasPlacedRegion());
|
|
32
|
+
onScopeDispose(
|
|
33
|
+
props.toaster.subscribe(
|
|
34
|
+
() => placed.value = toasterInternals(props.toaster).hasPlacedRegion()
|
|
35
|
+
)
|
|
36
|
+
);
|
|
37
|
+
return () => placed.value ? null : h(
|
|
38
|
+
HostedToastRegion,
|
|
39
|
+
{ ...props.regionProps, toaster: props.toaster },
|
|
40
|
+
props.renderToast && { default: props.renderToast }
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
var HostedConfirm = defineComponent({
|
|
45
|
+
name: "HostedConfirm",
|
|
46
|
+
props: {
|
|
47
|
+
entry: { type: Object, required: true }
|
|
48
|
+
},
|
|
49
|
+
setup(props) {
|
|
50
|
+
onMounted(() => props.entry.open());
|
|
51
|
+
return () => {
|
|
52
|
+
const { entry } = props;
|
|
53
|
+
const question = entry.payload ?? {};
|
|
54
|
+
return h(
|
|
55
|
+
AlertDialog,
|
|
56
|
+
{
|
|
57
|
+
controller: entry.controller,
|
|
58
|
+
onOpenChangeComplete: (open) => !open && entry.done()
|
|
59
|
+
},
|
|
60
|
+
() => h(AlertDialogContent, null, () => [
|
|
61
|
+
h(AlertDialogTitle, null, () => question.title),
|
|
62
|
+
question.description ? h(AlertDialogDescription, null, () => question.description) : null,
|
|
63
|
+
h("div", [
|
|
64
|
+
h(AlertDialogClose, null, () => question.cancelLabel ?? "Cancel"),
|
|
65
|
+
h(
|
|
66
|
+
AlertDialogClose,
|
|
67
|
+
{ value: "confirm" },
|
|
68
|
+
() => question.confirmLabel ?? "Continue"
|
|
69
|
+
)
|
|
70
|
+
])
|
|
71
|
+
])
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
var OverlayHost = defineComponent({
|
|
77
|
+
name: "OverlayHost",
|
|
78
|
+
props: {
|
|
79
|
+
// The registry it renders. Defaults to the shared `overlays`, which toast() and confirm() open into.
|
|
80
|
+
overlays: Object,
|
|
81
|
+
// Props for the toast regions it renders, like `side` and `class`.
|
|
82
|
+
toast: Object
|
|
83
|
+
},
|
|
84
|
+
slots: Object,
|
|
85
|
+
setup(props, { slots }) {
|
|
86
|
+
const registry = props.overlays ?? sharedOverlays;
|
|
87
|
+
const entries = shallowRef(registry.entries());
|
|
88
|
+
onScopeDispose(
|
|
89
|
+
registry.subscribe(() => entries.value = registry.entries())
|
|
90
|
+
);
|
|
91
|
+
let release = () => {
|
|
92
|
+
};
|
|
93
|
+
onMounted(() => release = registry.attachHost());
|
|
94
|
+
onBeforeUnmount(() => release());
|
|
95
|
+
return () => entries.value.map((entry) => {
|
|
96
|
+
if (entry.type === "toaster") {
|
|
97
|
+
return h(HostedToaster, {
|
|
98
|
+
key: entry.id,
|
|
99
|
+
toaster: entry.data.toaster,
|
|
100
|
+
regionProps: props.toast,
|
|
101
|
+
renderToast: slots.toast
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (entry.type === "confirm") {
|
|
105
|
+
return h(HostedConfirm, {
|
|
106
|
+
key: entry.id,
|
|
107
|
+
entry: entry.data
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
export {
|
|
115
|
+
OverlayHost,
|
|
116
|
+
createOverlays,
|
|
117
|
+
overlays
|
|
118
|
+
};
|