@shwfed/nuxt 0.7.8 → 0.7.10
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/dist/module.json +1 -1
- package/dist/runtime/components/app.d.vue.ts +7 -58
- package/dist/runtime/components/app.vue +18 -411
- package/dist/runtime/components/app.vue.d.ts +7 -58
- package/dist/runtime/components/fields.d.vue.ts +177 -0
- package/dist/runtime/components/fields.vue +47 -0
- package/dist/runtime/components/fields.vue.d.ts +177 -0
- package/dist/runtime/components/table.d.vue.ts +63 -59
- package/dist/runtime/components/table.vue +52 -617
- package/dist/runtime/components/table.vue.d.ts +63 -59
- package/dist/runtime/components/ui/app/App.d.vue.ts +86 -0
- package/dist/runtime/components/ui/app/App.vue +414 -0
- package/dist/runtime/components/ui/app/App.vue.d.ts +86 -0
- package/dist/runtime/components/ui/button-group/ButtonGroupSeparator.vue +1 -1
- package/dist/runtime/components/ui/button-group/ButtonGroupText.vue +1 -1
- package/dist/runtime/components/ui/calendar/Calendar.d.vue.ts +5 -12
- package/dist/runtime/components/ui/calendar/Calendar.vue +77 -92
- package/dist/runtime/components/ui/calendar/Calendar.vue.d.ts +5 -12
- package/dist/runtime/components/ui/calendar/CalendarCellTrigger.vue +1 -1
- package/dist/runtime/components/ui/calendar/index.d.ts +1 -1
- package/dist/runtime/components/ui/checkbox/Checkbox.vue +6 -2
- package/dist/runtime/components/ui/command/CommandGroup.vue +4 -0
- package/dist/runtime/components/ui/dialog/DialogOverlay.vue +1 -1
- package/dist/runtime/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +1 -1
- package/dist/runtime/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
- package/dist/runtime/components/ui/expression-editor/ExpressionEditor.d.vue.ts +30 -0
- package/dist/runtime/components/ui/expression-editor/ExpressionEditor.vue +87 -0
- package/dist/runtime/components/ui/expression-editor/ExpressionEditor.vue.d.ts +30 -0
- package/dist/runtime/components/ui/expression-editor/index.d.ts +1 -0
- package/dist/runtime/components/ui/expression-editor/index.js +1 -0
- package/dist/runtime/components/ui/field/FieldContent.vue +1 -1
- package/dist/runtime/components/ui/field/FieldDescription.vue +1 -1
- package/dist/runtime/components/ui/field/FieldError.vue +2 -2
- package/dist/runtime/components/ui/field/FieldLabel.vue +1 -1
- package/dist/runtime/components/ui/field/FieldSeparator.vue +1 -1
- package/dist/runtime/components/ui/field/index.js +7 -5
- package/dist/runtime/components/ui/fields/Fields.d.vue.ts +376 -0
- package/dist/runtime/components/ui/fields/Fields.vue +441 -0
- package/dist/runtime/components/ui/fields/Fields.vue.d.ts +376 -0
- package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.d.vue.ts +163 -0
- package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.vue +363 -0
- package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.vue.d.ts +163 -0
- package/dist/runtime/components/ui/input/Input.d.vue.ts +1 -0
- package/dist/runtime/components/ui/input/Input.vue +3 -1
- package/dist/runtime/components/ui/input/Input.vue.d.ts +1 -0
- package/dist/runtime/components/ui/input-group/InputGroup.vue +3 -0
- package/dist/runtime/components/ui/input-group/InputGroupAddon.vue +4 -1
- package/dist/runtime/components/ui/input-group/InputGroupCombobox.d.vue.ts +11 -3
- package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue +16 -5
- package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue.d.ts +11 -3
- package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.d.vue.ts +8 -1
- package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.vue +12 -1
- package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.vue.d.ts +8 -1
- package/dist/runtime/components/ui/input-group/InputGroupInput.vue +1 -1
- package/dist/runtime/components/ui/input-group/InputGroupNumberField.d.vue.ts +5 -2
- package/dist/runtime/components/ui/input-group/InputGroupNumberField.vue +10 -4
- package/dist/runtime/components/ui/input-group/InputGroupNumberField.vue.d.ts +5 -2
- package/dist/runtime/components/ui/input-group/InputGroupText.vue +1 -1
- package/dist/runtime/components/ui/input-group/InputGroupTextarea.vue +1 -1
- package/dist/runtime/components/ui/input-group/index.js +2 -2
- package/dist/runtime/components/ui/label/Label.vue +1 -1
- package/dist/runtime/components/ui/locale/Locale.d.vue.ts +20 -0
- package/dist/runtime/components/ui/locale/Locale.vue +291 -0
- package/dist/runtime/components/ui/locale/Locale.vue.d.ts +20 -0
- package/dist/runtime/components/ui/locale/index.d.ts +1 -0
- package/dist/runtime/components/ui/locale/index.js +1 -0
- package/dist/runtime/components/ui/native-select/NativeSelect.vue +3 -3
- package/dist/runtime/components/ui/native-select/NativeSelectOption.d.vue.ts +1 -0
- package/dist/runtime/components/ui/native-select/NativeSelectOption.vue +4 -1
- package/dist/runtime/components/ui/native-select/NativeSelectOption.vue.d.ts +1 -0
- package/dist/runtime/components/ui/navigation-menu/NavigationMenuLink.vue +1 -1
- package/dist/runtime/components/ui/navigation-menu/NavigationMenuViewport.vue +1 -1
- package/dist/runtime/components/ui/number-field/NumberFieldInput.vue +1 -1
- package/dist/runtime/components/ui/range-calendar/RangeCalendarCell.vue +1 -1
- package/dist/runtime/components/ui/range-calendar/RangeCalendarCellTrigger.vue +1 -1
- package/dist/runtime/components/ui/sheet/SheetOverlay.vue +1 -1
- package/dist/runtime/components/ui/switch/Switch.d.vue.ts +24 -0
- package/dist/runtime/components/ui/switch/Switch.vue +46 -0
- package/dist/runtime/components/ui/switch/Switch.vue.d.ts +24 -0
- package/dist/runtime/components/ui/switch/index.d.ts +1 -0
- package/dist/runtime/components/ui/switch/index.js +1 -0
- package/dist/runtime/components/ui/table/Table.d.vue.ts +81 -0
- package/dist/runtime/components/ui/table/Table.vue +792 -0
- package/dist/runtime/components/ui/table/Table.vue.d.ts +81 -0
- package/dist/runtime/components/ui/table/schema.d.ts +48 -0
- package/dist/runtime/components/ui/table/schema.js +126 -0
- package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.d.vue.ts +62 -0
- package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.vue +2233 -0
- package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.vue.d.ts +62 -0
- package/dist/runtime/components/ui/table-configurator/menu.d.ts +37 -0
- package/dist/runtime/components/ui/table-configurator/menu.js +227 -0
- package/dist/runtime/components/ui/tabs/Tabs.d.vue.ts +24 -0
- package/dist/runtime/components/ui/tabs/Tabs.vue +30 -0
- package/dist/runtime/components/ui/tabs/Tabs.vue.d.ts +24 -0
- package/dist/runtime/components/ui/tabs/TabsContent.d.vue.ts +18 -0
- package/dist/runtime/components/ui/tabs/TabsContent.vue +23 -0
- package/dist/runtime/components/ui/tabs/TabsContent.vue.d.ts +18 -0
- package/dist/runtime/components/ui/tabs/TabsList.d.vue.ts +18 -0
- package/dist/runtime/components/ui/tabs/TabsList.vue +25 -0
- package/dist/runtime/components/ui/tabs/TabsList.vue.d.ts +18 -0
- package/dist/runtime/components/ui/tabs/TabsTrigger.d.vue.ts +18 -0
- package/dist/runtime/components/ui/tabs/TabsTrigger.vue +27 -0
- package/dist/runtime/components/ui/tabs/TabsTrigger.vue.d.ts +18 -0
- package/dist/runtime/components/ui/tabs/index.d.ts +4 -0
- package/dist/runtime/components/ui/tabs/index.js +4 -0
- package/dist/runtime/components/ui/textarea/Textarea.d.vue.ts +1 -0
- package/dist/runtime/components/ui/textarea/Textarea.vue +4 -2
- package/dist/runtime/components/ui/textarea/Textarea.vue.d.ts +1 -0
- package/dist/runtime/components/ui/toggle/Toggle.d.vue.ts +34 -0
- package/dist/runtime/components/ui/toggle/Toggle.vue +32 -0
- package/dist/runtime/components/ui/toggle/Toggle.vue.d.ts +34 -0
- package/dist/runtime/components/ui/toggle/index.d.ts +7 -0
- package/dist/runtime/components/ui/toggle/index.js +22 -0
- package/dist/runtime/composables/useTableRenderers.d.ts +2 -1
- package/dist/runtime/composables/useTableRenderers.js +2 -1
- package/dist/runtime/plugins/cel/env.d.ts +2 -2
- package/dist/runtime/plugins/cel/env.js +5 -4
- package/dist/runtime/plugins/cel/index.d.ts +3 -3
- package/dist/runtime/plugins/cel/index.js +7 -3
- package/dist/runtime/plugins/markdown/index.d.ts +1 -1
- package/dist/runtime/style.css +1 -1
- package/dist/runtime/table-renderers/builtins.js +213 -98
- package/dist/runtime/table-renderers/registry.d.ts +1 -0
- package/dist/runtime/table-renderers/registry.js +3 -0
- package/dist/runtime/utils/coders.d.ts +32 -0
- package/dist/runtime/utils/coders.js +64 -0
- package/dist/runtime/vendor/cel/index.d.ts +17 -0
- package/dist/runtime/vendor/cel/index.js +10 -0
- package/dist/runtime/vendor/cel-js/LICENSE +21 -0
- package/dist/runtime/vendor/cel-js/UPSTREAM.md +17 -0
- package/dist/runtime/vendor/cel-js/lib/errors.d.ts +21 -0
- package/dist/runtime/vendor/cel-js/lib/errors.js +97 -0
- package/dist/runtime/vendor/cel-js/lib/evaluator.d.ts +4 -0
- package/dist/runtime/vendor/cel-js/lib/evaluator.js +192 -0
- package/dist/runtime/vendor/cel-js/lib/functions.d.ts +53 -0
- package/dist/runtime/vendor/cel-js/lib/functions.js +513 -0
- package/dist/runtime/vendor/cel-js/lib/globals.d.ts +27 -0
- package/dist/runtime/vendor/cel-js/lib/globals.js +33 -0
- package/dist/runtime/vendor/cel-js/lib/index.d.ts +469 -0
- package/dist/runtime/vendor/cel-js/lib/index.js +18 -0
- package/dist/runtime/vendor/cel-js/lib/macros.d.ts +1 -0
- package/dist/runtime/vendor/cel-js/lib/macros.js +230 -0
- package/dist/runtime/vendor/cel-js/lib/operators.d.ts +117 -0
- package/dist/runtime/vendor/cel-js/lib/operators.js +739 -0
- package/dist/runtime/vendor/cel-js/lib/optional.d.ts +14 -0
- package/dist/runtime/vendor/cel-js/lib/optional.js +161 -0
- package/dist/runtime/vendor/cel-js/lib/options.d.ts +23 -0
- package/dist/runtime/vendor/cel-js/lib/options.js +47 -0
- package/dist/runtime/vendor/cel-js/lib/overloads.d.ts +1 -0
- package/dist/runtime/vendor/cel-js/lib/overloads.js +214 -0
- package/dist/runtime/vendor/cel-js/lib/parser.d.ts +56 -0
- package/dist/runtime/vendor/cel-js/lib/parser.js +827 -0
- package/dist/runtime/vendor/cel-js/lib/registry.d.ts +279 -0
- package/dist/runtime/vendor/cel-js/lib/registry.js +1596 -0
- package/dist/runtime/vendor/cel-js/lib/serialize.d.ts +1 -0
- package/dist/runtime/vendor/cel-js/lib/serialize.js +259 -0
- package/dist/runtime/vendor/cel-js/lib/type-checker.d.ts +26 -0
- package/dist/runtime/vendor/cel-js/lib/type-checker.js +81 -0
- package/package.json +9 -4
- package/dist/runtime/components/locale.d.vue.ts +0 -14
- package/dist/runtime/components/locale.vue +0 -89
- package/dist/runtime/components/locale.vue.d.ts +0 -14
- package/dist/runtime/components/query.d.vue.ts +0 -30
- package/dist/runtime/components/query.vue +0 -266
- package/dist/runtime/components/query.vue.d.ts +0 -30
- package/dist/runtime/utilities/query-config/global.d.ts +0 -4
- package/dist/runtime/utilities/query-config/global.js +0 -18
- package/dist/runtime/utilities/query-config/index.d.ts +0 -3
- package/dist/runtime/utilities/query-config/index.js +0 -14
- package/dist/runtime/utilities/query-config/schema.d.ts +0 -96
- package/dist/runtime/utilities/query-config/schema.js +0 -51
- /package/dist/runtime/components/{logo.d.vue.ts → ui/logo/Logo.d.vue.ts} +0 -0
- /package/dist/runtime/components/{logo.vue → ui/logo/Logo.vue} +0 -0
- /package/dist/runtime/components/{logo.vue.d.ts → ui/logo/Logo.vue.d.ts} +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Scope } from 'effect';
|
|
2
|
+
import { Effect } from 'effect';
|
|
3
|
+
import { type Sidebar as SidebarType } from '../../../composables/useNavigationTabs.js';
|
|
4
|
+
type ProfileCommandInputItem = Readonly<{
|
|
5
|
+
id: string | number;
|
|
6
|
+
title: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
hidden?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
effect?: Effect.Effect<void>;
|
|
11
|
+
keywords?: Array<string>;
|
|
12
|
+
}>;
|
|
13
|
+
type ProfileCommandInputGroup = Readonly<{
|
|
14
|
+
id: string | number;
|
|
15
|
+
title: string;
|
|
16
|
+
icon?: string;
|
|
17
|
+
children: Array<ProfileCommandInputItem>;
|
|
18
|
+
}>;
|
|
19
|
+
type __VLS_Props = {
|
|
20
|
+
/**
|
|
21
|
+
* 应用的全局 DSL(CEL)执行上下文。传入一个 Effect,在应用启动时运行一次;
|
|
22
|
+
* 其解析结果(一个 record)会被永久设为全局上下文,供后续所有 CEL 求值(如 `$dsl.evaluate`)使用。
|
|
23
|
+
*
|
|
24
|
+
* 应用会等待该 effect 解析完成后才渲染;在整个应用生命周期内只会执行一次。
|
|
25
|
+
* 若未传入 `dsl`,全局上下文将被设为 `{}`。
|
|
26
|
+
*
|
|
27
|
+
* 适用于需要在首屏前就确定的、会话级稳定数据,例如:当前用户信息、用户所属组、
|
|
28
|
+
* 用户菜单列表、用户权限(或权限模块)等。此处加载的数据在整个应用内可通过 CEL 访问
|
|
29
|
+
*(如 `user`、`menu`、`permissions`)。强调「会话级」稳定即可,不必永久不变。
|
|
30
|
+
*
|
|
31
|
+
* 重要约束:
|
|
32
|
+
* - 加载时间至关重要:在该 effect 解析前,整应用不会加载,用户会看到白屏,因此必须保持非常快
|
|
33
|
+
* (如减少请求、缓存或并行拉取)。
|
|
34
|
+
* - 这是有意为之的权衡:菜单、用户等关键数据必须在此加载,否则可能出现空菜单、无用户等异常表现。
|
|
35
|
+
* - 该 effect 不得抛错(类型为 `never`):任何失败(如网络)应在 effect 内部处理,
|
|
36
|
+
* 返回空对象或安全默认值,保证应用仍能正常启动并得到一致的全局上下文。
|
|
37
|
+
*
|
|
38
|
+
* 返回的 `Record<string, unknown>` 会在通过 `$dsl.evaluate` 求值 CEL 表达式时,
|
|
39
|
+
* 与运行时上下文(如 `now`、`today` 及调用处传入的 context)合并使用。
|
|
40
|
+
*
|
|
41
|
+
* @example 最小示例:返回静态对象,键可在 CEL 中直接使用
|
|
42
|
+
* dsl: Effect.succeed({ hello: 'world' })
|
|
43
|
+
* // 之后在模板或逻辑中:$dsl.evaluate`hello`() 得到 'world'
|
|
44
|
+
*
|
|
45
|
+
* @example 实际场景:拉取会话数据(用户、菜单、权限)并返回,供 CEL 使用
|
|
46
|
+
* dsl: Effect.gen(function* () {
|
|
47
|
+
* const [user, menu, permissions] = yield* Effect.all([
|
|
48
|
+
* fetchUser().pipe(Effect.catchAll(() => Effect.succeed({ name: '', id: '' }))),
|
|
49
|
+
* fetchMenu().pipe(Effect.catchAll(() => Effect.succeed([]))),
|
|
50
|
+
* fetchPermissions().pipe(Effect.catchAll(() => Effect.succeed({ canEdit: false }))),
|
|
51
|
+
* ])
|
|
52
|
+
* return { user, menu, permissions }
|
|
53
|
+
* })
|
|
54
|
+
* // CEL 中可访问 user.name、permissions.canEdit 等;失败时在 effect 内兜底,不抛错
|
|
55
|
+
*/
|
|
56
|
+
dsl?: Effect.Effect<Record<string, unknown>, never, Scope.Scope>;
|
|
57
|
+
/**
|
|
58
|
+
* Sidebar config.
|
|
59
|
+
*
|
|
60
|
+
* `menus` is structured navigation data.
|
|
61
|
+
*/
|
|
62
|
+
sidebar?: SidebarType;
|
|
63
|
+
/**
|
|
64
|
+
* Profile command config.
|
|
65
|
+
*
|
|
66
|
+
* Structured command entries for profile menu and command palette.
|
|
67
|
+
*/
|
|
68
|
+
commands?: Array<ProfileCommandInputItem | ProfileCommandInputGroup>;
|
|
69
|
+
};
|
|
70
|
+
declare var __VLS_108: {}, __VLS_124: {}, __VLS_347: {};
|
|
71
|
+
type __VLS_Slots = {} & {
|
|
72
|
+
menu?: (props: typeof __VLS_108) => any;
|
|
73
|
+
} & {
|
|
74
|
+
profile?: (props: typeof __VLS_124) => any;
|
|
75
|
+
} & {
|
|
76
|
+
default?: (props: typeof __VLS_347) => any;
|
|
77
|
+
};
|
|
78
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
79
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
80
|
+
declare const _default: typeof __VLS_export;
|
|
81
|
+
export default _default;
|
|
82
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
83
|
+
new (): {
|
|
84
|
+
$slots: S;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
@@ -18,7 +18,7 @@ const delegatedProps = reactiveOmit(props, "class");
|
|
|
18
18
|
v-bind="delegatedProps"
|
|
19
19
|
:orientation="props.orientation"
|
|
20
20
|
:class="cn(
|
|
21
|
-
'bg-
|
|
21
|
+
'bg-zinc-200 relative m-0! self-stretch data-[orientation=vertical]:h-auto',
|
|
22
22
|
props.class
|
|
23
23
|
)"
|
|
24
24
|
/>
|
|
@@ -16,7 +16,7 @@ const props = defineProps({
|
|
|
16
16
|
:data-orientation="props.orientation"
|
|
17
17
|
:as="as"
|
|
18
18
|
:as-child="asChild"
|
|
19
|
-
:class="cn('bg-
|
|
19
|
+
:class="cn('bg-zinc-100 flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*=\'size-\'])]:size-4', props.class)"
|
|
20
20
|
>
|
|
21
21
|
<slot />
|
|
22
22
|
</Primitive>
|
|
@@ -4,23 +4,16 @@ import type { LayoutTypes } from '.';
|
|
|
4
4
|
type __VLS_Props = CalendarRootProps & {
|
|
5
5
|
class?: HTMLAttributes['class'];
|
|
6
6
|
layout?: LayoutTypes;
|
|
7
|
-
yearRange?: DateValue[];
|
|
8
7
|
};
|
|
9
|
-
declare var
|
|
8
|
+
declare var __VLS_20: {}, __VLS_28: {}, __VLS_30: {
|
|
10
9
|
date: DateValue;
|
|
11
|
-
month: import("@vueuse/core").ReuseTemplateComponent<{
|
|
12
|
-
date: DateValue;
|
|
13
|
-
}, Record<"default", undefined>>;
|
|
14
|
-
year: import("@vueuse/core").ReuseTemplateComponent<{
|
|
15
|
-
date: DateValue;
|
|
16
|
-
}, Record<"default", undefined>>;
|
|
17
10
|
};
|
|
18
11
|
type __VLS_Slots = {} & {
|
|
19
|
-
'calendar-prev-icon'?: (props: typeof
|
|
12
|
+
'calendar-prev-icon'?: (props: typeof __VLS_20) => any;
|
|
20
13
|
} & {
|
|
21
|
-
'calendar-next-icon'?: (props: typeof
|
|
14
|
+
'calendar-next-icon'?: (props: typeof __VLS_28) => any;
|
|
22
15
|
} & {
|
|
23
|
-
'calendar-heading'?: (props: typeof
|
|
16
|
+
'calendar-heading'?: (props: typeof __VLS_30) => any;
|
|
24
17
|
};
|
|
25
18
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
26
19
|
"update:modelValue": (date: DateValue | undefined) => any;
|
|
@@ -30,7 +23,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
30
23
|
"onUpdate:placeholder"?: ((date: DateValue) => any) | undefined;
|
|
31
24
|
}>, {
|
|
32
25
|
modelValue: DateValue | DateValue[];
|
|
33
|
-
layout:
|
|
26
|
+
layout: LayoutTypes;
|
|
34
27
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
28
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
36
29
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { getLocalTimeZone, today } from "@internationalized/date";
|
|
3
|
-
import {
|
|
2
|
+
import { CalendarDate, getLocalTimeZone, today } from "@internationalized/date";
|
|
3
|
+
import { reactiveOmit, useNavigatorLanguage, useVModel } from "@vueuse/core";
|
|
4
4
|
import { CalendarRoot, useDateFormatter, useForwardPropsEmits } from "reka-ui";
|
|
5
|
-
import {
|
|
6
|
-
import { computed
|
|
5
|
+
import { toDate } from "reka-ui/date";
|
|
6
|
+
import { computed } from "vue";
|
|
7
7
|
import { cn } from "../../../utils/cn";
|
|
8
|
-
import {
|
|
8
|
+
import { buttonVariants } from "../button";
|
|
9
9
|
import { CalendarCell, CalendarCellTrigger, CalendarGrid, CalendarGridBody, CalendarGridHead, CalendarGridRow, CalendarHeadCell, CalendarHeader, CalendarHeading, CalendarNextButton, CalendarPrevButton } from ".";
|
|
10
10
|
const props = defineProps({
|
|
11
11
|
defaultValue: { type: null, required: false },
|
|
@@ -35,8 +35,7 @@ const props = defineProps({
|
|
|
35
35
|
asChild: { type: Boolean, required: false },
|
|
36
36
|
as: { type: null, required: false },
|
|
37
37
|
class: { type: null, required: false },
|
|
38
|
-
layout: { type:
|
|
39
|
-
yearRange: { type: Array, required: false }
|
|
38
|
+
layout: { type: String, required: false, default: void 0 }
|
|
40
39
|
});
|
|
41
40
|
const emits = defineEmits(["update:modelValue", "update:placeholder"]);
|
|
42
41
|
const delegatedProps = reactiveOmit(props, "class", "layout", "placeholder");
|
|
@@ -45,14 +44,6 @@ const placeholder = useVModel(props, "placeholder", emits, {
|
|
|
45
44
|
defaultValue: props.defaultPlaceholder ?? today(getLocalTimeZone())
|
|
46
45
|
});
|
|
47
46
|
const formatter = useDateFormatter(props.locale ?? "en");
|
|
48
|
-
const yearRange = computed(() => {
|
|
49
|
-
return props.yearRange ?? createYearRange({
|
|
50
|
-
start: props?.minValue ?? (toRaw(props.placeholder) ?? props.defaultPlaceholder ?? today(getLocalTimeZone())).cycle("year", -100),
|
|
51
|
-
end: props?.maxValue ?? (toRaw(props.placeholder) ?? props.defaultPlaceholder ?? today(getLocalTimeZone())).cycle("year", 10)
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
const [DefineMonthTemplate, ReuseMonthTemplate] = createReusableTemplate();
|
|
55
|
-
const [DefineYearTemplate, ReuseYearTemplate] = createReusableTemplate();
|
|
56
47
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
57
48
|
const locale = useNavigatorLanguage();
|
|
58
49
|
const weekStartsOn = computed(() => {
|
|
@@ -63,77 +54,34 @@ const weekStartsOn = computed(() => {
|
|
|
63
54
|
}
|
|
64
55
|
return void 0;
|
|
65
56
|
});
|
|
57
|
+
const yearGridStart = computed(() => Math.floor(placeholder.value.year / 12) * 12);
|
|
58
|
+
function isPickerDateDisabled(date) {
|
|
59
|
+
const fn = props.isDateDisabled;
|
|
60
|
+
if (typeof fn !== "function") return false;
|
|
61
|
+
return fn(date);
|
|
62
|
+
}
|
|
66
63
|
</script>
|
|
67
64
|
|
|
68
65
|
<template>
|
|
69
|
-
<DefineMonthTemplate v-slot="{ date }">
|
|
70
|
-
<div class="**:data-[slot=native-select-icon]:right-1">
|
|
71
|
-
<div class="relative">
|
|
72
|
-
<div class="absolute inset-0 flex h-full items-center text-sm pl-2 pointer-events-none">
|
|
73
|
-
{{ formatter.custom(toDate(date), { month: "short" }) }}
|
|
74
|
-
</div>
|
|
75
|
-
<NativeSelect
|
|
76
|
-
class="text-xs h-8 pr-6 pl-2 text-transparent relative"
|
|
77
|
-
@change="(e) => {
|
|
78
|
-
placeholder = placeholder.set({
|
|
79
|
-
month: Number(e?.target?.value)
|
|
80
|
-
});
|
|
81
|
-
}"
|
|
82
|
-
>
|
|
83
|
-
<NativeSelectOption
|
|
84
|
-
v-for="(month) in createYear({ dateObj: date })"
|
|
85
|
-
:key="month.toString()"
|
|
86
|
-
:value="month.month"
|
|
87
|
-
:selected="date.month === month.month"
|
|
88
|
-
>
|
|
89
|
-
{{ formatter.custom(toDate(month), { month: "short" }) }}
|
|
90
|
-
</NativeSelectOption>
|
|
91
|
-
</NativeSelect>
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
</DefineMonthTemplate>
|
|
95
|
-
|
|
96
|
-
<DefineYearTemplate v-slot="{ date }">
|
|
97
|
-
<div class="**:data-[slot=native-select-icon]:right-1">
|
|
98
|
-
<div class="relative">
|
|
99
|
-
<div class="absolute inset-0 flex h-full items-center text-sm pl-2 pointer-events-none">
|
|
100
|
-
{{ formatter.custom(toDate(date), { year: "numeric" }) }}
|
|
101
|
-
</div>
|
|
102
|
-
<NativeSelect
|
|
103
|
-
class="text-xs h-8 pr-6 pl-2 text-transparent relative"
|
|
104
|
-
@change="(e) => {
|
|
105
|
-
placeholder = placeholder.set({
|
|
106
|
-
year: Number(e?.target?.value)
|
|
107
|
-
});
|
|
108
|
-
}"
|
|
109
|
-
>
|
|
110
|
-
<NativeSelectOption
|
|
111
|
-
v-for="(year) in yearRange"
|
|
112
|
-
:key="year.toString()"
|
|
113
|
-
:value="year.year"
|
|
114
|
-
:selected="date.year === year.year"
|
|
115
|
-
>
|
|
116
|
-
{{ formatter.custom(toDate(year), { year: "numeric" }) }}
|
|
117
|
-
</NativeSelectOption>
|
|
118
|
-
</NativeSelect>
|
|
119
|
-
</div>
|
|
120
|
-
</div>
|
|
121
|
-
</DefineYearTemplate>
|
|
122
|
-
|
|
123
66
|
<CalendarRoot
|
|
124
67
|
v-slot="{ grid, weekDays, date }"
|
|
125
68
|
v-bind="forwarded"
|
|
126
69
|
v-model:placeholder="placeholder"
|
|
127
70
|
data-slot="calendar"
|
|
128
71
|
:week-starts-on="weekStartsOn"
|
|
72
|
+
fixed-weeks
|
|
129
73
|
:class="cn('p-3', props.class)"
|
|
130
74
|
>
|
|
131
|
-
<CalendarHeader class="pt-0">
|
|
132
|
-
<nav class="w-full flex items-center gap-1 absolute top-1/2 -translate-y-1/2 transform-gpu inset-x-0 justify-between">
|
|
133
|
-
<CalendarPrevButton
|
|
75
|
+
<CalendarHeader :class="layout === 'year' ? 'pt-2 pb-2' : 'pt-0'">
|
|
76
|
+
<nav class="w-full flex items-center gap-1 absolute top-1/2 -translate-y-1/2 transform-gpu inset-x-0 justify-between z-10">
|
|
77
|
+
<CalendarPrevButton
|
|
78
|
+
:prev-page="layout === 'year' ? (d) => d.subtract({ years: 12 }) : layout === 'month' ? (d) => d.subtract({ years: 1 }) : void 0"
|
|
79
|
+
>
|
|
134
80
|
<slot name="calendar-prev-icon" />
|
|
135
81
|
</CalendarPrevButton>
|
|
136
|
-
<CalendarNextButton
|
|
82
|
+
<CalendarNextButton
|
|
83
|
+
:next-page="layout === 'year' ? (d) => d.add({ years: 12 }) : layout === 'month' ? (d) => d.add({ years: 1 }) : void 0"
|
|
84
|
+
>
|
|
137
85
|
<slot name="calendar-next-icon" />
|
|
138
86
|
</CalendarNextButton>
|
|
139
87
|
</nav>
|
|
@@ -141,34 +89,71 @@ const weekStartsOn = computed(() => {
|
|
|
141
89
|
<slot
|
|
142
90
|
name="calendar-heading"
|
|
143
91
|
:date="date"
|
|
144
|
-
:month="ReuseMonthTemplate"
|
|
145
|
-
:year="ReuseYearTemplate"
|
|
146
92
|
>
|
|
147
|
-
<template v-if="layout === 'month
|
|
148
|
-
<
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
</template>
|
|
153
|
-
<template v-else-if="layout === 'month-only'">
|
|
154
|
-
<div class="flex items-center justify-center gap-1">
|
|
155
|
-
<ReuseMonthTemplate :date="date" />
|
|
93
|
+
<template v-if="layout === 'month'">
|
|
94
|
+
<span
|
|
95
|
+
class="text-sm font-medium"
|
|
96
|
+
style="text-autospace: normal"
|
|
97
|
+
>
|
|
156
98
|
{{ formatter.custom(toDate(date), { year: "numeric" }) }}
|
|
157
|
-
</
|
|
158
|
-
</template>
|
|
159
|
-
<template v-else-if="layout === 'year-only'">
|
|
160
|
-
<div class="flex items-center justify-center gap-1">
|
|
161
|
-
{{ formatter.custom(toDate(date), { month: "short" }) }}
|
|
162
|
-
<ReuseYearTemplate :date="date" />
|
|
163
|
-
</div>
|
|
99
|
+
</span>
|
|
164
100
|
</template>
|
|
101
|
+
<template v-else-if="layout === 'year'" />
|
|
165
102
|
<template v-else>
|
|
166
103
|
<CalendarHeading />
|
|
167
104
|
</template>
|
|
168
105
|
</slot>
|
|
169
106
|
</CalendarHeader>
|
|
170
107
|
|
|
171
|
-
|
|
108
|
+
<!-- Month picker grid (month-only / month-and-year) -->
|
|
109
|
+
<div
|
|
110
|
+
v-if="layout === 'month'"
|
|
111
|
+
class="grid grid-cols-4 gap-1 mt-4"
|
|
112
|
+
>
|
|
113
|
+
<button
|
|
114
|
+
v-for="m in 12"
|
|
115
|
+
:key="m"
|
|
116
|
+
type="button"
|
|
117
|
+
:disabled="isPickerDateDisabled(new CalendarDate(placeholder.year, m, 1))"
|
|
118
|
+
:class="cn(
|
|
119
|
+
buttonVariants({ variant: 'ghost' }),
|
|
120
|
+
'h-9 w-full rounded-md font-normal',
|
|
121
|
+
modelValue && !Array.isArray(modelValue) && modelValue.year === placeholder.year && modelValue.month === m ? 'bg-[color-mix(in_srgb,var(--primary)_20%,white)] text-(--primary)' : '',
|
|
122
|
+
isPickerDateDisabled(new CalendarDate(placeholder.year, m, 1)) ? 'text-zinc-500 opacity-50 cursor-default' : 'cursor-pointer'
|
|
123
|
+
)"
|
|
124
|
+
@click="emits('update:modelValue', new CalendarDate(placeholder.year, m, 1))"
|
|
125
|
+
>
|
|
126
|
+
{{ formatter.custom(toDate(new CalendarDate(placeholder.year, m, 1)), { month: "short" }) }}
|
|
127
|
+
</button>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<!-- Year picker grid -->
|
|
131
|
+
<div
|
|
132
|
+
v-else-if="layout === 'year'"
|
|
133
|
+
class="grid grid-cols-4 gap-1 mt-4"
|
|
134
|
+
>
|
|
135
|
+
<button
|
|
136
|
+
v-for="i in 12"
|
|
137
|
+
:key="i"
|
|
138
|
+
type="button"
|
|
139
|
+
:disabled="isPickerDateDisabled(new CalendarDate(yearGridStart + i - 1, 1, 1))"
|
|
140
|
+
:class="cn(
|
|
141
|
+
buttonVariants({ variant: 'ghost' }),
|
|
142
|
+
'h-9 w-full rounded-md font-normal',
|
|
143
|
+
modelValue && !Array.isArray(modelValue) && modelValue.year === yearGridStart + i - 1 ? 'bg-[color-mix(in_srgb,var(--primary)_20%,white)] text-(--primary)' : '',
|
|
144
|
+
isPickerDateDisabled(new CalendarDate(yearGridStart + i - 1, 1, 1)) ? 'text-zinc-500 opacity-50 cursor-default' : 'cursor-pointer'
|
|
145
|
+
)"
|
|
146
|
+
@click="emits('update:modelValue', new CalendarDate(yearGridStart + i - 1, 1, 1))"
|
|
147
|
+
>
|
|
148
|
+
{{ yearGridStart + i - 1 }}
|
|
149
|
+
</button>
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
<!-- Default: day grid -->
|
|
153
|
+
<div
|
|
154
|
+
v-else
|
|
155
|
+
class="flex flex-col gap-y-4 mt-4 sm:flex-row sm:gap-x-4 sm:gap-y-0"
|
|
156
|
+
>
|
|
172
157
|
<CalendarGrid
|
|
173
158
|
v-for="month in grid"
|
|
174
159
|
:key="month.value.toString()"
|
|
@@ -4,23 +4,16 @@ import type { LayoutTypes } from '.';
|
|
|
4
4
|
type __VLS_Props = CalendarRootProps & {
|
|
5
5
|
class?: HTMLAttributes['class'];
|
|
6
6
|
layout?: LayoutTypes;
|
|
7
|
-
yearRange?: DateValue[];
|
|
8
7
|
};
|
|
9
|
-
declare var
|
|
8
|
+
declare var __VLS_20: {}, __VLS_28: {}, __VLS_30: {
|
|
10
9
|
date: DateValue;
|
|
11
|
-
month: import("@vueuse/core").ReuseTemplateComponent<{
|
|
12
|
-
date: DateValue;
|
|
13
|
-
}, Record<"default", undefined>>;
|
|
14
|
-
year: import("@vueuse/core").ReuseTemplateComponent<{
|
|
15
|
-
date: DateValue;
|
|
16
|
-
}, Record<"default", undefined>>;
|
|
17
10
|
};
|
|
18
11
|
type __VLS_Slots = {} & {
|
|
19
|
-
'calendar-prev-icon'?: (props: typeof
|
|
12
|
+
'calendar-prev-icon'?: (props: typeof __VLS_20) => any;
|
|
20
13
|
} & {
|
|
21
|
-
'calendar-next-icon'?: (props: typeof
|
|
14
|
+
'calendar-next-icon'?: (props: typeof __VLS_28) => any;
|
|
22
15
|
} & {
|
|
23
|
-
'calendar-heading'?: (props: typeof
|
|
16
|
+
'calendar-heading'?: (props: typeof __VLS_30) => any;
|
|
24
17
|
};
|
|
25
18
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
26
19
|
"update:modelValue": (date: DateValue | undefined) => any;
|
|
@@ -30,7 +23,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
30
23
|
"onUpdate:placeholder"?: ((date: DateValue) => any) | undefined;
|
|
31
24
|
}>, {
|
|
32
25
|
modelValue: DateValue | DateValue[];
|
|
33
|
-
layout:
|
|
26
|
+
layout: LayoutTypes;
|
|
34
27
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
28
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
36
29
|
declare const _default: typeof __VLS_export;
|
|
@@ -24,7 +24,7 @@ const forwardedProps = useForwardProps(delegatedProps);
|
|
|
24
24
|
// Selected
|
|
25
25
|
'data-selected:bg-[color-mix(in_srgb,var(--primary)_20%,white)] data-selected:opacity-100 data-selected:text-(--primary)',
|
|
26
26
|
// Disabled
|
|
27
|
-
'data-disabled:text-zinc-500 data-disabled:opacity-50',
|
|
27
|
+
'data-disabled:text-zinc-500 data-disabled:opacity-50 data-disabled:cursor-not-allowed data-disabled:hover:bg-transparent data-disabled:hover:text-zinc-500',
|
|
28
28
|
// Unavailable
|
|
29
29
|
'data-unavailable:text-zinc-300 data-unavailable:line-through',
|
|
30
30
|
// Outside months
|
|
@@ -10,4 +10,4 @@ export { default as CalendarHeader } from './CalendarHeader.vue.js';
|
|
|
10
10
|
export { default as CalendarHeading } from './CalendarHeading.vue.js';
|
|
11
11
|
export { default as CalendarNextButton } from './CalendarNextButton.vue.js';
|
|
12
12
|
export { default as CalendarPrevButton } from './CalendarPrevButton.vue.js';
|
|
13
|
-
export type LayoutTypes = '
|
|
13
|
+
export type LayoutTypes = 'year' | 'month' | 'date';
|
|
@@ -27,7 +27,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
27
27
|
v-bind="forwarded"
|
|
28
28
|
:class="
|
|
29
29
|
cn(
|
|
30
|
-
'peer cursor-pointer flex items-center justify-center border-zinc-200 data-[state=checked]:bg-(--primary) data-[state=checked]:text-white data-[state=checked]:border-(--primary) aria-invalid:border-red-400 size-4 shrink-0 rounded border shadow-xs hover:shadow transition-shadow outline-none disabled:cursor-not-allowed disabled:opacity-50',
|
|
30
|
+
'peer cursor-pointer flex items-center justify-center border-zinc-200 data-[state=checked]:bg-(--primary) data-[state=checked]:text-white data-[state=checked]:border-(--primary) data-[state=indeterminate]:bg-(--primary) data-[state=indeterminate]:text-white data-[state=indeterminate]:border-(--primary) aria-invalid:border-red-400 size-4 shrink-0 rounded border shadow-xs hover:shadow transition-shadow outline-none disabled:cursor-not-allowed disabled:opacity-50',
|
|
31
31
|
props.class
|
|
32
32
|
)
|
|
33
33
|
"
|
|
@@ -38,9 +38,13 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
38
38
|
>
|
|
39
39
|
<slot v-bind="slotProps">
|
|
40
40
|
<Icon
|
|
41
|
-
v-if="
|
|
41
|
+
v-if="slotProps.state === true"
|
|
42
42
|
icon="fluent:checkmark-20-filled"
|
|
43
43
|
/>
|
|
44
|
+
<Icon
|
|
45
|
+
v-else-if="slotProps.state === 'indeterminate'"
|
|
46
|
+
icon="radix-icons:minus"
|
|
47
|
+
/>
|
|
44
48
|
</slot>
|
|
45
49
|
</CheckboxIndicator>
|
|
46
50
|
</CheckboxRoot>
|
|
@@ -15,7 +15,7 @@ const delegatedProps = reactiveOmit(props, "class");
|
|
|
15
15
|
<DialogOverlay
|
|
16
16
|
data-slot="dialog-overlay"
|
|
17
17
|
v-bind="delegatedProps"
|
|
18
|
-
:class="cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-
|
|
18
|
+
:class="cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-zinc-900/60', props.class)"
|
|
19
19
|
>
|
|
20
20
|
<slot />
|
|
21
21
|
</DialogOverlay>
|
|
@@ -25,7 +25,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
25
25
|
data-slot="dropdown-menu-checkbox-item"
|
|
26
26
|
v-bind="forwarded"
|
|
27
27
|
:class="cn(
|
|
28
|
-
'focus:bg-
|
|
28
|
+
'focus:bg-zinc-100 focus:text-zinc-700 relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4',
|
|
29
29
|
props.class
|
|
30
30
|
)"
|
|
31
31
|
>
|
|
@@ -24,7 +24,7 @@ const forwardedProps = useForwardProps(delegatedProps);
|
|
|
24
24
|
v-bind="forwardedProps"
|
|
25
25
|
:data-inset="inset ? '' : void 0"
|
|
26
26
|
:class="cn(
|
|
27
|
-
'focus:bg-zinc-100 focus:text-zinc-700 data-[state=open]:bg-zinc-100 data-[state=open]:text-zinc-700 relative flex cursor-pointer items-center gap-2 rounded-sm p-2 text-sm outline-hidden select-none data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4 data-[variant=destructive]:*:[svg]:text-
|
|
27
|
+
'focus:bg-zinc-100 focus:text-zinc-700 data-[state=open]:bg-zinc-100 data-[state=open]:text-zinc-700 relative flex cursor-pointer items-center gap-2 rounded-sm p-2 text-sm outline-hidden select-none data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4 data-[variant=destructive]:*:[svg]:text-red-600! [&_svg:not([class*=\'text-\'])]:text-zinc-400',
|
|
28
28
|
props.class
|
|
29
29
|
)"
|
|
30
30
|
>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'vue';
|
|
2
|
+
import type z from 'zod';
|
|
3
|
+
export type ExpressionEditorExposed = Readonly<{
|
|
4
|
+
clearValidation: () => void;
|
|
5
|
+
validate: () => boolean;
|
|
6
|
+
}>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<{
|
|
10
|
+
class?: HTMLAttributes["class"];
|
|
11
|
+
description?: string;
|
|
12
|
+
label: string;
|
|
13
|
+
modelValue?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
schema: z.ZodType<unknown>;
|
|
16
|
+
}, {
|
|
17
|
+
clearValidation: () => void;
|
|
18
|
+
validate: () => boolean;
|
|
19
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
+
"update:modelValue": (args_0: string | undefined) => any;
|
|
21
|
+
}, string, import("vue").PublicProps, Readonly<{
|
|
22
|
+
class?: HTMLAttributes["class"];
|
|
23
|
+
description?: string;
|
|
24
|
+
label: string;
|
|
25
|
+
modelValue?: string;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
schema: z.ZodType<unknown>;
|
|
28
|
+
}> & Readonly<{
|
|
29
|
+
"onUpdate:modelValue"?: ((args_0: string | undefined) => any) | undefined;
|
|
30
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import { cn } from "../../../utils/cn";
|
|
4
|
+
import { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from "../field";
|
|
5
|
+
import { Textarea } from "../textarea";
|
|
6
|
+
defineOptions({
|
|
7
|
+
inheritAttrs: false
|
|
8
|
+
});
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
class: { type: null, required: false },
|
|
11
|
+
description: { type: String, required: false },
|
|
12
|
+
label: { type: String, required: true },
|
|
13
|
+
modelValue: { type: String, required: false },
|
|
14
|
+
placeholder: { type: String, required: false },
|
|
15
|
+
schema: { type: null, required: true }
|
|
16
|
+
});
|
|
17
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
18
|
+
const validationError = ref();
|
|
19
|
+
function clearValidation() {
|
|
20
|
+
validationError.value = void 0;
|
|
21
|
+
}
|
|
22
|
+
function normalizeModelValue(value) {
|
|
23
|
+
const normalizedValue = String(value);
|
|
24
|
+
if (normalizedValue.trim().length === 0) {
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
return normalizedValue;
|
|
28
|
+
}
|
|
29
|
+
function handleModelValueUpdate(value) {
|
|
30
|
+
clearValidation();
|
|
31
|
+
emit("update:modelValue", normalizeModelValue(value));
|
|
32
|
+
}
|
|
33
|
+
function validate() {
|
|
34
|
+
const result = props.schema.safeParse(props.modelValue);
|
|
35
|
+
if (result.success) {
|
|
36
|
+
clearValidation();
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
validationError.value = result.error.issues[0]?.message ?? "Invalid value";
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
defineExpose({
|
|
43
|
+
clearValidation,
|
|
44
|
+
validate
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<script>
|
|
49
|
+
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<template>
|
|
53
|
+
<div
|
|
54
|
+
v-bind="$attrs"
|
|
55
|
+
data-slot="expression-editor"
|
|
56
|
+
:class="cn('w-full', props.class)"
|
|
57
|
+
>
|
|
58
|
+
<Field
|
|
59
|
+
orientation="vertical"
|
|
60
|
+
:data-invalid="validationError ? 'true' : void 0"
|
|
61
|
+
class="gap-2"
|
|
62
|
+
>
|
|
63
|
+
<FieldLabel>{{ props.label }}</FieldLabel>
|
|
64
|
+
|
|
65
|
+
<FieldContent>
|
|
66
|
+
<FieldDescription v-if="props.description">
|
|
67
|
+
{{ props.description }}
|
|
68
|
+
</FieldDescription>
|
|
69
|
+
|
|
70
|
+
<Textarea
|
|
71
|
+
class="min-h-28 font-mono text-sm"
|
|
72
|
+
:model-value="props.modelValue ?? ''"
|
|
73
|
+
:placeholder="props.placeholder"
|
|
74
|
+
spellcheck="false"
|
|
75
|
+
:aria-invalid="validationError ? 'true' : void 0"
|
|
76
|
+
@update:model-value="handleModelValueUpdate"
|
|
77
|
+
/>
|
|
78
|
+
|
|
79
|
+
<FieldError
|
|
80
|
+
v-if="validationError"
|
|
81
|
+
class="static pt-0"
|
|
82
|
+
:errors="[validationError]"
|
|
83
|
+
/>
|
|
84
|
+
</FieldContent>
|
|
85
|
+
</Field>
|
|
86
|
+
</div>
|
|
87
|
+
</template>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'vue';
|
|
2
|
+
import type z from 'zod';
|
|
3
|
+
export type ExpressionEditorExposed = Readonly<{
|
|
4
|
+
clearValidation: () => void;
|
|
5
|
+
validate: () => boolean;
|
|
6
|
+
}>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<{
|
|
10
|
+
class?: HTMLAttributes["class"];
|
|
11
|
+
description?: string;
|
|
12
|
+
label: string;
|
|
13
|
+
modelValue?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
schema: z.ZodType<unknown>;
|
|
16
|
+
}, {
|
|
17
|
+
clearValidation: () => void;
|
|
18
|
+
validate: () => boolean;
|
|
19
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
+
"update:modelValue": (args_0: string | undefined) => any;
|
|
21
|
+
}, string, import("vue").PublicProps, Readonly<{
|
|
22
|
+
class?: HTMLAttributes["class"];
|
|
23
|
+
description?: string;
|
|
24
|
+
label: string;
|
|
25
|
+
modelValue?: string;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
schema: z.ZodType<unknown>;
|
|
28
|
+
}> & Readonly<{
|
|
29
|
+
"onUpdate:modelValue"?: ((args_0: string | undefined) => any) | undefined;
|
|
30
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ExpressionEditor } from './ExpressionEditor.vue.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ExpressionEditor } from "./ExpressionEditor.vue";
|