toku-ui 4.1.0 → 4.3.0
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/components/TFileUpload/TFileUpload.stories.d.ts +13 -0
- package/dist/components/TFileUpload/TFileUpload.stories.d.ts.map +1 -0
- package/dist/components/TFileUpload/TFileUpload.vue.d.ts +155 -0
- package/dist/components/TFileUpload/TFileUpload.vue.d.ts.map +1 -0
- package/dist/components/TFileUpload/index.d.ts +3 -0
- package/dist/components/TFileUpload/index.d.ts.map +1 -0
- package/dist/components/TSwitch/TSwitch.stories.d.ts +124 -7
- package/dist/components/TSwitch/TSwitch.stories.d.ts.map +1 -1
- package/dist/components/TSwitch/TSwitch.vue.d.ts +95 -0
- package/dist/components/TSwitch/TSwitch.vue.d.ts.map +1 -0
- package/dist/components/TSwitch/index.d.ts +2 -2
- package/dist/components/TSwitch/index.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/composables/forwardedAttrs.d.ts +15 -0
- package/dist/composables/forwardedAttrs.d.ts.map +1 -0
- package/dist/index.es.js +1168 -1006
- package/dist/index.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +5 -2
- package/dist/components/TSwitch/TSwitch.d.ts +0 -22
- package/dist/components/TSwitch/TSwitch.d.ts.map +0 -1
- package/dist/components/TSwitch/TSwitch.styles.d.ts +0 -2
- package/dist/components/TSwitch/TSwitch.styles.d.ts.map +0 -1
- package/dist/components/TSwitch/TSwitch.types.d.ts +0 -9
- package/dist/components/TSwitch/TSwitch.types.d.ts.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import TFileUpload from './TFileUpload.vue';
|
|
3
|
+
declare const meta: Meta<typeof TFileUpload>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof TFileUpload>;
|
|
6
|
+
export declare const playground: Story;
|
|
7
|
+
export declare const empty: Story;
|
|
8
|
+
export declare const hover: Story;
|
|
9
|
+
export declare const focus: Story;
|
|
10
|
+
export declare const loading: Story;
|
|
11
|
+
export declare const loaded: Story;
|
|
12
|
+
export declare const primaryFlow: Story;
|
|
13
|
+
//# sourceMappingURL=TFileUpload.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TFileUpload.stories.d.ts","sourceRoot":"","sources":["../../../src/components/TFileUpload/TFileUpload.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,WAAW,CAaC,CAAC;AAErC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,WAAW,CAAC,CAAC;AAE1C,eAAO,MAAM,UAAU,EAAE,KAaxB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAUnB,CAAC;AASF,eAAO,MAAM,KAAK,EAAE,KAUnB,CAAC;AAYF,eAAO,MAAM,KAAK,EAAE,KAUnB,CAAC;AAaF,eAAO,MAAM,OAAO,EAAE,KAUrB,CAAC;AASF,eAAO,MAAM,MAAM,EAAE,KAapB,CAAC;AAUF,eAAO,MAAM,WAAW,EAAE,KA6BzB,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { AsTag } from 'reka-ui';
|
|
2
|
+
/**
|
|
3
|
+
* Reason emitted with the `'error'` event when an uploaded file fails internal
|
|
4
|
+
* validation against the `accept` extension list or `maxSizeBytes` size cap.
|
|
5
|
+
*
|
|
6
|
+
* - `'bad-format'`: the file's extension is not in the `accept` list.
|
|
7
|
+
* - `'too-large'`: the file's size exceeds `maxSizeBytes`.
|
|
8
|
+
*/
|
|
9
|
+
export type TFileUploadErrorReason = 'bad-format' | 'too-large';
|
|
10
|
+
/**
|
|
11
|
+
* Props for the `TFileUpload` component.
|
|
12
|
+
*
|
|
13
|
+
* `TFileUpload` is a single-file upload control with three visual states
|
|
14
|
+
* (empty / loading / loaded) and built-in validation against an allow-list of
|
|
15
|
+
* extensions and an optional maximum size in bytes. The selected `File` (or
|
|
16
|
+
* `null`) is exposed via `v-model`; validation failures emit `'error'`
|
|
17
|
+
* **instead of** updating the model.
|
|
18
|
+
*
|
|
19
|
+
* All user-facing strings are passed in as props so the consumer owns i18n;
|
|
20
|
+
* the component does not import a translation function.
|
|
21
|
+
*/
|
|
22
|
+
export interface TFileUploadProps {
|
|
23
|
+
/**
|
|
24
|
+
* Label shown above the upload box (e.g. `"Adjuntar archivo"`).
|
|
25
|
+
* When omitted, the label slot/element is not rendered.
|
|
26
|
+
*/
|
|
27
|
+
label?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Call-to-action text rendered inside the box while no file is attached
|
|
30
|
+
* (e.g. `"Subir archivo"`).
|
|
31
|
+
* @defaultValue 'Subir archivo'
|
|
32
|
+
*/
|
|
33
|
+
ctaText?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Text rendered inside the box while `loading` is `true`
|
|
36
|
+
* (e.g. `"Cargando archivo"`).
|
|
37
|
+
* @defaultValue 'Cargando archivo'
|
|
38
|
+
*/
|
|
39
|
+
loadingText?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Accessible label for the remove button shown in the loaded state.
|
|
42
|
+
* @defaultValue 'Quitar archivo'
|
|
43
|
+
*/
|
|
44
|
+
removeLabel?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Hint displayed beneath the box (bottom-left) listing accepted formats.
|
|
47
|
+
* Hidden in the loaded state.
|
|
48
|
+
*/
|
|
49
|
+
formatsHint?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Hint displayed beneath the box (bottom-right) describing the size limit.
|
|
52
|
+
* Hidden in the loaded state.
|
|
53
|
+
*/
|
|
54
|
+
maxSizeHint?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Accepted file extensions without the leading dot (e.g. `['csv', 'pdf']`).
|
|
57
|
+
* Used to build the native `accept` attribute and to validate the selected
|
|
58
|
+
* file. When omitted, no extension validation runs.
|
|
59
|
+
*/
|
|
60
|
+
accept?: string[];
|
|
61
|
+
/**
|
|
62
|
+
* Maximum file size in bytes. Files larger than this emit
|
|
63
|
+
* `'error'` with reason `'too-large'` and the model is not updated.
|
|
64
|
+
* When omitted, no size validation runs.
|
|
65
|
+
*/
|
|
66
|
+
maxSizeBytes?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Controlled loading flag. When `true` the box renders the loading visual
|
|
69
|
+
* and the underlying `<input type="file">` is disabled so the user cannot
|
|
70
|
+
* pick another file mid-upload.
|
|
71
|
+
* @defaultValue false
|
|
72
|
+
*/
|
|
73
|
+
loading?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Optional id forwarded to the underlying `<input type="file">`. When
|
|
76
|
+
* omitted a stable auto-generated id is used.
|
|
77
|
+
*/
|
|
78
|
+
id?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Form field name forwarded to the underlying `<input type="file">`.
|
|
81
|
+
* Required for native form submission (the file is sent under this key).
|
|
82
|
+
*/
|
|
83
|
+
name?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Marks the input as required for native HTML5 form validation.
|
|
86
|
+
* @defaultValue false
|
|
87
|
+
*/
|
|
88
|
+
required?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Disables the picker. The native `<input>` is disabled and the box
|
|
91
|
+
* renders in a non-interactive visual state.
|
|
92
|
+
* @defaultValue false
|
|
93
|
+
*/
|
|
94
|
+
disabled?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* `id` of the `<form>` this input belongs to. Use when the component
|
|
97
|
+
* lives outside the target form in the DOM.
|
|
98
|
+
*/
|
|
99
|
+
form?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Element the outer wrapper renders as. Useful for semantic nesting
|
|
102
|
+
* (e.g. `'li'` inside a `<ul>`).
|
|
103
|
+
* @defaultValue 'div'
|
|
104
|
+
*/
|
|
105
|
+
as?: AsTag;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Events emitted by `TFileUpload`.
|
|
109
|
+
*/
|
|
110
|
+
export interface TFileUploadEmits {
|
|
111
|
+
/**
|
|
112
|
+
* Fired when the selected file fails internal validation. The model is
|
|
113
|
+
* **not** updated in this case — consumers can surface the reason as they
|
|
114
|
+
* wish.
|
|
115
|
+
*/
|
|
116
|
+
error: [reason: TFileUploadErrorReason];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Slots exposed by `TFileUpload`. Each slot defaults to rendering its
|
|
120
|
+
* matching text prop, so most consumers will not need them; provide a slot
|
|
121
|
+
* only when richer content (icons, formatting) is required.
|
|
122
|
+
*/
|
|
123
|
+
export interface TFileUploadSlots {
|
|
124
|
+
/** Overrides the `label` prop. */
|
|
125
|
+
label: () => unknown;
|
|
126
|
+
/** Overrides the `ctaText` prop in the empty state. */
|
|
127
|
+
cta: () => unknown;
|
|
128
|
+
/** Overrides the `loadingText` prop in the loading state. */
|
|
129
|
+
loading: () => unknown;
|
|
130
|
+
/** Overrides the filename rendering in the loaded state. */
|
|
131
|
+
file: (props: {
|
|
132
|
+
file: File;
|
|
133
|
+
}) => unknown;
|
|
134
|
+
}
|
|
135
|
+
declare const _default: typeof __VLS_export;
|
|
136
|
+
export default _default;
|
|
137
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<TFileUploadProps & {
|
|
138
|
+
modelValue?: File | null;
|
|
139
|
+
}, {
|
|
140
|
+
inputRef: import("vue").Ref<HTMLInputElement | null, HTMLInputElement | null>;
|
|
141
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
142
|
+
error: (reason: TFileUploadErrorReason) => any;
|
|
143
|
+
"update:modelValue": (value: File | null) => any;
|
|
144
|
+
}, string, import("vue").PublicProps, Readonly<TFileUploadProps & {
|
|
145
|
+
modelValue?: File | null;
|
|
146
|
+
}> & Readonly<{
|
|
147
|
+
onError?: ((reason: TFileUploadErrorReason) => any) | undefined;
|
|
148
|
+
"onUpdate:modelValue"?: ((value: File | null) => any) | undefined;
|
|
149
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, TFileUploadSlots>;
|
|
150
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
151
|
+
new (): {
|
|
152
|
+
$slots: S;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=TFileUpload.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TFileUpload.vue.d.ts","sourceRoot":"","sources":["../../../src/components/TFileUpload/TFileUpload.vue"],"names":[],"mappings":"AAueA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAAG,YAAY,GAAG,WAAW,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,EAAE,CAAC,EAAE,KAAK,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,KAAK,EAAE,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;CACzC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,KAAK,EAAE,MAAM,OAAO,CAAC;IACrB,uDAAuD;IACvD,GAAG,EAAE,MAAM,OAAO,CAAC;IACnB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,4DAA4D;IAC5D,IAAI,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,KAAK,OAAO,CAAC;CAC1C;wBACoB,OAAO,YAAY;AAAxC,wBAAyC;AACzC,QAAA,MAAM,YAAY;iBA8HL,IAAI,GAAG,IAAI;;;;;;;iBAAX,IAAI,GAAG,IAAI;;;;qGAkUpB,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TFileUpload/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3D,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,9 +1,126 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: any;
|
|
5
|
+
tags: string[];
|
|
6
|
+
argTypes: {
|
|
7
|
+
label: {
|
|
8
|
+
control: "text";
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
labelPosition: {
|
|
12
|
+
control: {
|
|
13
|
+
type: "inline-radio";
|
|
14
|
+
};
|
|
15
|
+
options: string[];
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
disabled: {
|
|
19
|
+
control: "boolean";
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
modelValue: {
|
|
23
|
+
control: "boolean";
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
value: {
|
|
27
|
+
control: "boolean";
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
id: {
|
|
31
|
+
control: "text";
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
args: {
|
|
36
|
+
labelPosition: string;
|
|
37
|
+
disabled: boolean;
|
|
38
|
+
};
|
|
39
|
+
parameters: {
|
|
40
|
+
docs: {
|
|
41
|
+
description: {
|
|
42
|
+
component: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
4
47
|
export default meta;
|
|
5
|
-
type Story = StoryObj<typeof
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
48
|
+
type Story = StoryObj<typeof meta>;
|
|
49
|
+
/**
|
|
50
|
+
* Interactive playground — tweak any prop via the **Controls** panel below to see how it
|
|
51
|
+
* affects rendering. The switch is bound to a local `ref` so toggling persists during the
|
|
52
|
+
* story session.
|
|
53
|
+
*/
|
|
54
|
+
export declare const Playground: Story;
|
|
55
|
+
/**
|
|
56
|
+
* The most common shape: text label to the right of the switch. The label is rendered as
|
|
57
|
+
* a real `<label for>` element, so clicking the text toggles the switch — no `for`
|
|
58
|
+
* attribute juggling required.
|
|
59
|
+
*/
|
|
60
|
+
export declare const WithLabel: Story;
|
|
61
|
+
/**
|
|
62
|
+
* `labelPosition="left"` swaps the order. Use this in settings panels where labels are
|
|
63
|
+
* aligned to the right edge of the container — the switch ends up at the far right,
|
|
64
|
+
* matching the visual rhythm of right-aligned form rows.
|
|
65
|
+
*/
|
|
66
|
+
export declare const LabelLeft: Story;
|
|
67
|
+
/**
|
|
68
|
+
* Disabled in the off state. Both the native `disabled` attribute and `aria-disabled="true"`
|
|
69
|
+
* are applied — most browsers' built-in handling covers screen readers, but the explicit
|
|
70
|
+
* ARIA attribute is there for assistive tech that polls it. Visually the whole control
|
|
71
|
+
* fades via `opacity: var(--opacity-disabled)` and loses its hover/press affordances.
|
|
72
|
+
*/
|
|
73
|
+
export declare const Disabled: Story;
|
|
74
|
+
/**
|
|
75
|
+
* Disabled in the on state — for showing a setting that's enforced/locked by an admin or
|
|
76
|
+
* by an upstream constraint. The brand color still appears (the user shouldn't lose the
|
|
77
|
+
* affordance that this represents an "on" state), but interaction is blocked.
|
|
78
|
+
*/
|
|
79
|
+
export declare const DisabledChecked: Story;
|
|
80
|
+
/**
|
|
81
|
+
* Bare switch — no label rendered. Use this when the surrounding UI already provides the
|
|
82
|
+
* accessible name (e.g. inside a table cell where the column header acts as the label).
|
|
83
|
+
*
|
|
84
|
+
* If you go this route, **always** supply an accessible name via `aria-label` or
|
|
85
|
+
* `aria-labelledby` (passed through as native HTML attributes). A switch with no
|
|
86
|
+
* accessible name is an accessibility failure.
|
|
87
|
+
*/
|
|
88
|
+
export declare const NoLabel: Story;
|
|
89
|
+
/**
|
|
90
|
+
* Verifies the click + keyboard contract end-to-end via a Storybook `play` function
|
|
91
|
+
* (runs in a real browser, doubles as a Chromatic baseline for the intermediate states).
|
|
92
|
+
*
|
|
93
|
+
* The flow:
|
|
94
|
+
*
|
|
95
|
+
* 1. Initial render → `aria-checked="false"`.
|
|
96
|
+
* 2. Mouse click → toggles to `true`.
|
|
97
|
+
* 3. Mouse click again → toggles back to `false`.
|
|
98
|
+
* 4. Focus the switch and press `Space` → toggles to `true`.
|
|
99
|
+
* 5. Press `Enter` → toggles back to `false`.
|
|
100
|
+
*
|
|
101
|
+
* If you migrate this component or change its keyboard handling, this story will fail and
|
|
102
|
+
* tell you exactly which interaction broke.
|
|
103
|
+
*/
|
|
104
|
+
export declare const KeyboardInteraction: Story;
|
|
105
|
+
/**
|
|
106
|
+
* Three identical `<TSwitch>` instances inside three different `<TThemeProvider>` wrappers,
|
|
107
|
+
* each with a different tenant brand color. This demonstrates the runtime tenant theming
|
|
108
|
+
* pipeline end-to-end:
|
|
109
|
+
*
|
|
110
|
+
* 1. Each `<TThemeProvider>` receives `{ colors: { brand: { base: '#...' } } }`.
|
|
111
|
+
* 2. `createTheme()` regenerates the 12-step brand ramp (+ 12-step alpha ramp) from the seed hex.
|
|
112
|
+
* 3. The provider applies `class="toku-theme"` to its root `<div>` and sets the brand
|
|
113
|
+
* primitives as inline CSS custom properties (`--color-brand-1..12`, `--color-brand-a-1..12`).
|
|
114
|
+
* 4. Because `toku-ui/tokens.css` emits every token declaration under the `:root, .toku-theme`
|
|
115
|
+
* selector, the semantic aliases (`--color-bg-primary-default: var(--color-brand-9)`)
|
|
116
|
+
* re-resolve at the provider's scope using the local primitive overrides.
|
|
117
|
+
* 5. The switch reads `var(--color-bg-primary-default)` — which now resolves to the
|
|
118
|
+
* tenant's exact hex.
|
|
119
|
+
*
|
|
120
|
+
* The whole flip happens via CSS-variable cascade with **zero Vue re-renders**. Useful for
|
|
121
|
+
* multi-tenant white-label apps (e.g. `client-payment-portal-frontend`) where each
|
|
122
|
+
* organization sees their own brand color applied across the entire UI without touching
|
|
123
|
+
* component code.
|
|
124
|
+
*/
|
|
125
|
+
export declare const RuntimeTheming: Story;
|
|
9
126
|
//# sourceMappingURL=TSwitch.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TSwitch.stories.d.ts","sourceRoot":"","sources":["../../../src/components/TSwitch/TSwitch.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"TSwitch.stories.d.ts","sourceRoot":"","sources":["../../../src/components/TSwitch/TSwitch.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAY3D,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsGsB,CAAC;AAEjC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,KASxB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,KASvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,KAUvB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,KAUtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,KAW7B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,EAAE,KASrB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,EAAE,KA+BjC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc,EAAE,KAoC5B,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { AsTag } from 'reka-ui';
|
|
2
|
+
/**
|
|
3
|
+
* Accessible toggle switch for binary settings that take effect immediately.
|
|
4
|
+
*
|
|
5
|
+
* Use for "notifications on/off", "dark mode", "auto-save" — anything where the
|
|
6
|
+
* change commits the instant the user toggles it. For form state held until submit,
|
|
7
|
+
* use a checkbox instead; the visual difference signals when the change applies.
|
|
8
|
+
*
|
|
9
|
+
* ## Custom value types
|
|
10
|
+
*
|
|
11
|
+
* Generic over `T` (default `boolean`). To bind v-model to a non-boolean state,
|
|
12
|
+
* declare `trueValue` and `falseValue` together:
|
|
13
|
+
*
|
|
14
|
+
* const status = ref<'active' | 'paused'>('paused')
|
|
15
|
+
* // template: TSwitch v-model="status" :true-value="'active'" :false-value="'paused'"
|
|
16
|
+
*
|
|
17
|
+
* The "on" position emits `trueValue`; the "off" position emits `falseValue`. Useful
|
|
18
|
+
* for state machines, form payloads with string enums, or anywhere boolean coercion
|
|
19
|
+
* would lose semantic meaning. Reach for it when v-model would otherwise need a
|
|
20
|
+
* derived boolean adapter — not for simple on/off, which is the 95% case.
|
|
21
|
+
*
|
|
22
|
+
* The legacy `value` prop is `boolean`-only; don't mix it with non-boolean generic mode.
|
|
23
|
+
*
|
|
24
|
+
* ## Theming
|
|
25
|
+
*
|
|
26
|
+
* The "on" track resolves to `var(--color-bg-primary-default)` — the tenant brand.
|
|
27
|
+
* Wrap a subtree in `TThemeProvider` with a brand override to retheme at runtime
|
|
28
|
+
* (no re-renders; CSS variable cascade only).
|
|
29
|
+
*/
|
|
30
|
+
export interface TSwitchProps<T = boolean> {
|
|
31
|
+
/** Visible label rendered next to the switch. Also serves as the accessible name. */
|
|
32
|
+
label?: string;
|
|
33
|
+
/** Disables interaction. @defaultValue false */
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Initial / fallback checked state. **Deprecated — prefer `v-model`** (`modelValue`).
|
|
37
|
+
* Kept for the pre-migration `:value` + `@input` API; removal in a future major.
|
|
38
|
+
* Boolean-only — don't mix with non-boolean generic mode.
|
|
39
|
+
*/
|
|
40
|
+
value?: boolean;
|
|
41
|
+
/** Two-way bound state. Idiomatic usage: `v-model="enabled"`. */
|
|
42
|
+
modelValue?: T;
|
|
43
|
+
/** Value emitted when the switch is "on". Default: `true` (when T = boolean). */
|
|
44
|
+
trueValue?: T;
|
|
45
|
+
/** Value emitted when the switch is "off". Default: `false` (when T = boolean). */
|
|
46
|
+
falseValue?: T;
|
|
47
|
+
/** Position of the label relative to the switch. @defaultValue 'right' */
|
|
48
|
+
labelPosition?: 'left' | 'right';
|
|
49
|
+
/** Explicit id for the underlying control. Auto-generated via `useId()` if omitted. */
|
|
50
|
+
id?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Element the outer wrapper renders as. Use `'label'` to make the entire row
|
|
53
|
+
* clickable (native `label for=...` toggles the switch), `'li'` when placing
|
|
54
|
+
* switches inside a `ul`, or a component for polymorphic rendering.
|
|
55
|
+
* @defaultValue 'div'
|
|
56
|
+
*/
|
|
57
|
+
as?: AsTag;
|
|
58
|
+
}
|
|
59
|
+
export interface TSwitchEmits<T = boolean> {
|
|
60
|
+
/** Fires on every toggle (mouse, Space, Enter). Payload is the new value. */
|
|
61
|
+
change: [value: T];
|
|
62
|
+
/** Mirrors `change`. **Deprecated** — use `@change` or `v-model`. */
|
|
63
|
+
input: [value: T];
|
|
64
|
+
}
|
|
65
|
+
export interface TSwitchSlots {
|
|
66
|
+
/** Override the default label rendering. Receives the resolved `label` prop. */
|
|
67
|
+
label?: (props: {
|
|
68
|
+
label: string | undefined;
|
|
69
|
+
}) => unknown;
|
|
70
|
+
}
|
|
71
|
+
declare const _default: typeof __VLS_export;
|
|
72
|
+
export default _default;
|
|
73
|
+
declare const __VLS_export: <T = boolean>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
74
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<(TSwitchProps<T> & {
|
|
75
|
+
modelValue?: T;
|
|
76
|
+
}) & {
|
|
77
|
+
onInput?: ((value: T) => any) | undefined;
|
|
78
|
+
onChange?: ((value: T) => any) | undefined;
|
|
79
|
+
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
80
|
+
}> & (typeof globalThis extends {
|
|
81
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
82
|
+
} ? P : {});
|
|
83
|
+
expose: (exposed: {}) => void;
|
|
84
|
+
attrs: any;
|
|
85
|
+
slots: TSwitchSlots;
|
|
86
|
+
emit: (((evt: "input", value: T) => void) & ((evt: "change", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
87
|
+
}>) => import("vue").VNode & {
|
|
88
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
89
|
+
};
|
|
90
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
91
|
+
[K in keyof T]: T[K];
|
|
92
|
+
} : {
|
|
93
|
+
[K in keyof T as K]: T[K];
|
|
94
|
+
}) & {};
|
|
95
|
+
//# sourceMappingURL=TSwitch.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TSwitch.vue.d.ts","sourceRoot":"","sources":["../../../src/components/TSwitch/TSwitch.vue"],"names":[],"mappings":"AAmRA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,gDAAgD;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,iEAAiE;IACjE,UAAU,CAAC,EAAE,CAAC,CAAC;IAEf,iFAAiF;IACjF,SAAS,CAAC,EAAE,CAAC,CAAC;IAEd,mFAAmF;IACnF,UAAU,CAAC,EAAE,CAAC,CAAC;IAEf,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAEjC,uFAAuF;IACvF,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;;;;OAKG;IACH,EAAE,CAAC,EAAE,KAAK,CAAC;CACZ;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,6EAA6E;IAC7E,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACnB,qEAAqE;IACrE,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,KAAK,OAAO,CAAC;CAC3D;wBACoB,OAAO,YAAY;AAAxC,wBAAyC;AACzC,QAAA,MAAM,YAAY,GAAK,CAAC,GAAG,OAAO,EACjC,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,gBAAgB,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EAClE;WAwLO,OAAO,KAAK,EAAE,WAAW,GAAG,mBAAmB,CAAC;qBA3I3C,CAAC;;;;;KA2I6E,CAAC,GAAG,CAAC,OAAO,UAAU,SAAS;QAAE,oBAAoB,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,CAAC,GAAG,EAAE,CAAC;YAC5J,CAAC,OAAO,EAAE,EAAE,KAAK,IAAI;WACtB,GAAG;;UAEJ,yIAAoC;EAEvC,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAI,CAAC;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { default as TSwitch } from './TSwitch.vue';
|
|
2
|
+
export type { TSwitchEmits, TSwitchProps, TSwitchSlots } from './TSwitch.vue';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TSwitch/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TSwitch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,mBAAmB,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,mBAAmB,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const useForwardedAttrs: () => {
|
|
2
|
+
wrapperAttrs: import("vue").ComputedRef<{
|
|
3
|
+
[k: string]: unknown;
|
|
4
|
+
}>;
|
|
5
|
+
controlAttrs: import("vue").ComputedRef<{
|
|
6
|
+
[k: string]: unknown;
|
|
7
|
+
}>;
|
|
8
|
+
staticAttrs: import("vue").ComputedRef<{
|
|
9
|
+
[k: string]: unknown;
|
|
10
|
+
}>;
|
|
11
|
+
listenerAttrs: import("vue").ComputedRef<{
|
|
12
|
+
[k: string]: unknown;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=forwardedAttrs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forwardedAttrs.d.ts","sourceRoot":"","sources":["../../src/composables/forwardedAttrs.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;CAc7B,CAAC"}
|