cynx-lib 1.3.111 → 1.3.113

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.
Files changed (45) hide show
  1. package/gen.js +77 -77
  2. package/package.json +1 -1
  3. package/ui/components/ActionsMenu.jsx +357 -357
  4. package/ui/components/Drawer.jsx +208 -208
  5. package/ui/components/Globe.jsx +764 -764
  6. package/ui/components/HoverCard.jsx +85 -85
  7. package/ui/components/PrivacyBlur.jsx +603 -603
  8. package/ui/components/Sidebar.jsx +2 -1
  9. package/ui/components/useRuler.jsx +0 -1
  10. package/ui/index.cjs +0 -2
  11. package/ui/index.js +1 -2
  12. package/utils/index.js +24 -24
  13. package/utils/utils/duration.js +139 -139
  14. package/utils/utils/oidc.js +214 -214
  15. package/utils/utils/realtime.js +1634 -1634
  16. package/utils/utils/server.js +371 -371
  17. package/utils/utils/session.js +131 -131
  18. package/utils/utils/session_manager.js +580 -580
  19. package/utils/utils/sso_manager.js +702 -702
  20. package/utils/utils/storage.js +393 -393
  21. package/utils/utils/ui.js +111 -111
  22. package/vue/components/Badge.vue +79 -79
  23. package/vue/components/Button.vue +209 -209
  24. package/vue/components/Checkbox.vue +103 -103
  25. package/vue/components/CircularProgress.vue +383 -383
  26. package/vue/components/Divider.vue +94 -94
  27. package/vue/components/Drawer.vue +243 -243
  28. package/vue/components/InfoBadge.vue +223 -223
  29. package/vue/components/Input.vue +341 -341
  30. package/vue/components/LinearProgress.vue +268 -268
  31. package/vue/components/Modal.vue +226 -226
  32. package/vue/components/Pagination.vue +199 -199
  33. package/vue/components/Select.vue +713 -713
  34. package/vue/components/Sidebar.vue +955 -955
  35. package/vue/components/Skeleton.vue +91 -91
  36. package/vue/components/Spinner.vue +263 -263
  37. package/vue/components/StatusTag.vue +89 -89
  38. package/vue/components/TabBar.vue +176 -176
  39. package/vue/components/Table.vue +388 -388
  40. package/vue/components/TimePicker.vue +399 -399
  41. package/vue/components/Toggle.vue +115 -115
  42. package/vue/components/XTable.vue +140 -140
  43. package/vue/composables/useAutoSkeletonRows.ts +71 -71
  44. package/vue/index.d.ts +67 -67
  45. package/vue/index.js +86 -86
@@ -1,209 +1,209 @@
1
- <script setup lang="ts">
2
- import { computed, useSlots, type VNode } from "vue";
3
- import Spinner from "./Spinner.vue";
4
-
5
- const VARIANTS: Record<string, any> = {
6
- default: {
7
- background: "var(--surface, #fff)",
8
- color: "var(--def-btn-text, #0f111c)",
9
- border: "1px solid var(--bd, #d7d8e0)",
10
- hoverBg: "var(--grey-1, #f5f5f8)",
11
- hoverBorder: "var(--grey-2, #ebebee)",
12
- },
13
- primary: {
14
- background: "var(--accent, #12675D)",
15
- color: "#fff",
16
- border: "1px solid transparent",
17
- hoverBg: "var(--accent-hover, #0e524a)",
18
- hoverShadow: "0 2px 8px rgba(18, 103, 93, .35)",
19
- },
20
- secondary: {
21
- background: "var(--blue-bg, rgba(39,130,228,.1))",
22
- color: "var(--blue, #2782e4)",
23
- border: "1px solid var(--infd, rgba(39,130,228,.2))",
24
- hoverBg: "var(--infd, rgba(39,130,228,.18))",
25
- hoverShadow: "0 2px 8px rgba(39,130,228,.25)",
26
- },
27
- danger: {
28
- background: "var(--danger-bg, rgba(246,71,71,.1))",
29
- color: "var(--danger, #f64747)",
30
- border: "1px solid var(--dd, rgba(246,71,71,.2))",
31
- hoverBg: "var(--dd, rgba(246,71,71,.18))",
32
- hoverShadow: "0 2px 8px rgba(246,71,71,.25)",
33
- },
34
- "danger-solid": {
35
- background: "var(--danger, #EF4444)",
36
- color: "#fff",
37
- border: "1px solid transparent",
38
- hoverBg: "#dc2626",
39
- hoverShadow: "0 2px 8px rgba(239, 68, 68, .35)",
40
- },
41
- "danger-fill": {
42
- background: "var(--danger, #EF4444)",
43
- color: "#fff",
44
- border: "1px solid transparent",
45
- hoverBg: "#dc2626",
46
- hoverShadow: "0 2px 8px rgba(239, 68, 68, .35)",
47
- },
48
- success: {
49
- background: "var(--success-bg, rgba(39,174,96,.1))",
50
- color: "var(--success, #27ae60)",
51
- border: "1px solid var(--sd, rgba(39,174,96,.2))",
52
- hoverBg: "var(--sd, rgba(39,174,96,.18))",
53
- hoverShadow: "0 2px 8px rgba(39,174,96,.25)",
54
- },
55
- warning: {
56
- background: "var(--accent-bg, rgba(249,158,44,.1))",
57
- color: "var(--accent, #f99e2c)",
58
- border: "1px solid var(--accent-border, rgba(249,158,44,.25))",
59
- hoverBg: "var(--pd, rgba(249,158,44,.18))",
60
- hoverShadow: "0 2px 8px rgba(249,158,44,.25)",
61
- },
62
- ghost: {
63
- background: "var(--surface, #ffffff)",
64
- color: "var(--t2, #797b8d)",
65
- border: "1px solid var(--bd, #d7d8e0)",
66
- hoverColor: "var(--t1, #1a1a2e)",
67
- hoverBg: "var(--grey-1, #f5f5f8)",
68
- hoverBorder: "var(--grey-2, #ebebee)",
69
- },
70
- plain: {
71
- background: "transparent",
72
- color: "var(--t2, #797b8d)",
73
- border: "1px solid transparent",
74
- hoverColor: "var(--t1, #1a1a2e)",
75
- hoverBg: "var(--grey-1, #f5f5f8)",
76
- hoverBorder: "transparent",
77
- boxShadow: "none",
78
- },
79
- flat: {
80
- background: "transparent",
81
- color: "var(--t2, #797b8d)",
82
- border: "1px solid transparent",
83
- hoverColor: "var(--t1, #1a1a2e)",
84
- hoverBg: "var(--grey-1, #f5f5f8)",
85
- hoverBorder: "transparent",
86
- boxShadow: "none",
87
- },
88
- icon: {
89
- background: "transparent",
90
- color: "var(--t2, #797b8d)",
91
- border: "1px solid transparent",
92
- hoverColor: "var(--t1, #1a1a2e)",
93
- hoverBg: "var(--grey-1, #f5f5f8)",
94
- hoverBorder: "transparent",
95
- boxShadow: "none",
96
- },
97
- outline: {
98
- background: "transparent",
99
- color: "var(--accent, #12675D)",
100
- border: "1px solid var(--accent, #12675D)",
101
- hoverBg: "var(--accent-bg, rgba(18, 103, 93, .1))",
102
- },
103
- link: {
104
- background: "transparent",
105
- color: "var(--accent, #12675D)",
106
- border: "1px solid transparent",
107
- paddingLeft: "4px",
108
- paddingRight: "4px",
109
- boxShadow: "none",
110
- },
111
- "no-line": {
112
- background: "none",
113
- border: "none",
114
- boxShadow: "none",
115
- color: "var(--t3, #8a96b0)",
116
- paddingLeft: "14px",
117
- paddingRight: "14px",
118
- borderRadius: "var(--rmd, 8px)",
119
- },
120
- };
121
-
122
- const SIZES: Record<string, any> = {
123
- xs: { padding: "0 6px", fontSize: 11, height: 24 },
124
- sm: { padding: "0 8px", fontSize: 11.5, height: 28 },
125
- md: { padding: "0 14px", fontSize: 13, height: 32 },
126
- lg: { padding: "0 18px", fontSize: 14, height: 36 },
127
- };
128
-
129
- const props = withDefaults(
130
- defineProps<{
131
- variant?: string;
132
- size?: "xs" | "sm" | "md" | "lg";
133
- disabled?: boolean;
134
- loading?: boolean;
135
- type?: "button" | "submit" | "reset";
136
- iconOnly?: boolean;
137
- }>(),
138
- {
139
- variant: "default",
140
- size: "md",
141
- disabled: false,
142
- loading: false,
143
- type: "button",
144
- iconOnly: false,
145
- }
146
- );
147
-
148
- const emit = defineEmits<{
149
- (e: "click", event: MouseEvent): void;
150
- }>();
151
-
152
- const slots = useSlots();
153
- const v = computed(() => VARIANTS[props.variant] || VARIANTS.default);
154
- const s = computed(() => SIZES[props.size] || SIZES.md);
155
-
156
- const hasDefaultText = computed(() => {
157
- if (!slots.default) return false;
158
- const nodes = slots.default();
159
- if (!nodes || nodes.length === 0) return false;
160
- return nodes.some((node: VNode) => {
161
- if (node.type === Symbol.for("v-cmt")) return false;
162
- if (typeof node.children === "string") return node.children.trim().length > 0;
163
- if (Array.isArray(node.children)) return node.children.length > 0;
164
- return Boolean(node.type);
165
- });
166
- });
167
-
168
- const isIconOnly = computed(() => {
169
- if (props.iconOnly || props.variant === "icon") return true;
170
- const hasIconSlot = Boolean(slots.icon) || Boolean(slots.iconRight);
171
- return hasIconSlot && !hasDefaultText.value;
172
- });
173
- </script>
174
-
175
- <template>
176
- <button
177
- :type="type"
178
- :disabled="disabled || loading"
179
- :class="[`btn btn-${variant}`, 'inline-flex items-center justify-center gap-1.5 font-medium transition select-none flex-shrink-0']"
180
- :style="{
181
- borderRadius: 'var(--rads, 8px)',
182
- fontFamily: 'var(--f, var(--sans, inherit))',
183
- cursor: disabled ? 'not-allowed' : 'pointer',
184
- whiteSpace: 'nowrap',
185
- letterSpacing: '-.01em',
186
- outline: 'none',
187
- boxShadow: v.boxShadow !== undefined ? v.boxShadow : 'var(--shadow, 0 1px 3px rgba(20,22,41,.1))',
188
- opacity: disabled ? 0.45 : 1,
189
- pointerEvents: disabled ? 'none' : undefined,
190
- background: v.background,
191
- color: v.color,
192
- border: v.border,
193
- padding: isIconOnly ? '0' : s.padding,
194
- fontSize: `${s.fontSize}px`,
195
- height: `${s.height}px`,
196
- width: isIconOnly ? `${s.height}px` : undefined,
197
- minWidth: isIconOnly ? `${s.height}px` : undefined,
198
- maxWidth: isIconOnly ? `${s.height}px` : undefined,
199
- ...(v.paddingLeft !== undefined && { paddingLeft: v.paddingLeft }),
200
- ...(v.paddingRight !== undefined && { paddingRight: v.paddingRight }),
201
- }"
202
- @click="emit('click', $event)"
203
- >
204
- <Spinner v-if="loading" :size="14" inline color="currentColor" />
205
- <slot v-if="!loading" name="icon" />
206
- <slot v-if="!loading" />
207
- <slot v-if="!loading" name="iconRight" />
208
- </button>
209
- </template>
1
+ <script setup lang="ts">
2
+ import { computed, useSlots, type VNode } from "vue";
3
+ import Spinner from "./Spinner.vue";
4
+
5
+ const VARIANTS: Record<string, any> = {
6
+ default: {
7
+ background: "var(--surface, #fff)",
8
+ color: "var(--def-btn-text, #0f111c)",
9
+ border: "1px solid var(--bd, #d7d8e0)",
10
+ hoverBg: "var(--grey-1, #f5f5f8)",
11
+ hoverBorder: "var(--grey-2, #ebebee)",
12
+ },
13
+ primary: {
14
+ background: "var(--accent, #12675D)",
15
+ color: "#fff",
16
+ border: "1px solid transparent",
17
+ hoverBg: "var(--accent-hover, #0e524a)",
18
+ hoverShadow: "0 2px 8px rgba(18, 103, 93, .35)",
19
+ },
20
+ secondary: {
21
+ background: "var(--blue-bg, rgba(39,130,228,.1))",
22
+ color: "var(--blue, #2782e4)",
23
+ border: "1px solid var(--infd, rgba(39,130,228,.2))",
24
+ hoverBg: "var(--infd, rgba(39,130,228,.18))",
25
+ hoverShadow: "0 2px 8px rgba(39,130,228,.25)",
26
+ },
27
+ danger: {
28
+ background: "var(--danger-bg, rgba(246,71,71,.1))",
29
+ color: "var(--danger, #f64747)",
30
+ border: "1px solid var(--dd, rgba(246,71,71,.2))",
31
+ hoverBg: "var(--dd, rgba(246,71,71,.18))",
32
+ hoverShadow: "0 2px 8px rgba(246,71,71,.25)",
33
+ },
34
+ "danger-solid": {
35
+ background: "var(--danger, #EF4444)",
36
+ color: "#fff",
37
+ border: "1px solid transparent",
38
+ hoverBg: "#dc2626",
39
+ hoverShadow: "0 2px 8px rgba(239, 68, 68, .35)",
40
+ },
41
+ "danger-fill": {
42
+ background: "var(--danger, #EF4444)",
43
+ color: "#fff",
44
+ border: "1px solid transparent",
45
+ hoverBg: "#dc2626",
46
+ hoverShadow: "0 2px 8px rgba(239, 68, 68, .35)",
47
+ },
48
+ success: {
49
+ background: "var(--success-bg, rgba(39,174,96,.1))",
50
+ color: "var(--success, #27ae60)",
51
+ border: "1px solid var(--sd, rgba(39,174,96,.2))",
52
+ hoverBg: "var(--sd, rgba(39,174,96,.18))",
53
+ hoverShadow: "0 2px 8px rgba(39,174,96,.25)",
54
+ },
55
+ warning: {
56
+ background: "var(--accent-bg, rgba(249,158,44,.1))",
57
+ color: "var(--accent, #f99e2c)",
58
+ border: "1px solid var(--accent-border, rgba(249,158,44,.25))",
59
+ hoverBg: "var(--pd, rgba(249,158,44,.18))",
60
+ hoverShadow: "0 2px 8px rgba(249,158,44,.25)",
61
+ },
62
+ ghost: {
63
+ background: "var(--surface, #ffffff)",
64
+ color: "var(--t2, #797b8d)",
65
+ border: "1px solid var(--bd, #d7d8e0)",
66
+ hoverColor: "var(--t1, #1a1a2e)",
67
+ hoverBg: "var(--grey-1, #f5f5f8)",
68
+ hoverBorder: "var(--grey-2, #ebebee)",
69
+ },
70
+ plain: {
71
+ background: "transparent",
72
+ color: "var(--t2, #797b8d)",
73
+ border: "1px solid transparent",
74
+ hoverColor: "var(--t1, #1a1a2e)",
75
+ hoverBg: "var(--grey-1, #f5f5f8)",
76
+ hoverBorder: "transparent",
77
+ boxShadow: "none",
78
+ },
79
+ flat: {
80
+ background: "transparent",
81
+ color: "var(--t2, #797b8d)",
82
+ border: "1px solid transparent",
83
+ hoverColor: "var(--t1, #1a1a2e)",
84
+ hoverBg: "var(--grey-1, #f5f5f8)",
85
+ hoverBorder: "transparent",
86
+ boxShadow: "none",
87
+ },
88
+ icon: {
89
+ background: "transparent",
90
+ color: "var(--t2, #797b8d)",
91
+ border: "1px solid transparent",
92
+ hoverColor: "var(--t1, #1a1a2e)",
93
+ hoverBg: "var(--grey-1, #f5f5f8)",
94
+ hoverBorder: "transparent",
95
+ boxShadow: "none",
96
+ },
97
+ outline: {
98
+ background: "transparent",
99
+ color: "var(--accent, #12675D)",
100
+ border: "1px solid var(--accent, #12675D)",
101
+ hoverBg: "var(--accent-bg, rgba(18, 103, 93, .1))",
102
+ },
103
+ link: {
104
+ background: "transparent",
105
+ color: "var(--accent, #12675D)",
106
+ border: "1px solid transparent",
107
+ paddingLeft: "4px",
108
+ paddingRight: "4px",
109
+ boxShadow: "none",
110
+ },
111
+ "no-line": {
112
+ background: "none",
113
+ border: "none",
114
+ boxShadow: "none",
115
+ color: "var(--t3, #8a96b0)",
116
+ paddingLeft: "14px",
117
+ paddingRight: "14px",
118
+ borderRadius: "var(--rmd, 8px)",
119
+ },
120
+ };
121
+
122
+ const SIZES: Record<string, any> = {
123
+ xs: { padding: "0 6px", fontSize: 11, height: 24 },
124
+ sm: { padding: "0 8px", fontSize: 11.5, height: 28 },
125
+ md: { padding: "0 14px", fontSize: 13, height: 32 },
126
+ lg: { padding: "0 18px", fontSize: 14, height: 36 },
127
+ };
128
+
129
+ const props = withDefaults(
130
+ defineProps<{
131
+ variant?: string;
132
+ size?: "xs" | "sm" | "md" | "lg";
133
+ disabled?: boolean;
134
+ loading?: boolean;
135
+ type?: "button" | "submit" | "reset";
136
+ iconOnly?: boolean;
137
+ }>(),
138
+ {
139
+ variant: "default",
140
+ size: "md",
141
+ disabled: false,
142
+ loading: false,
143
+ type: "button",
144
+ iconOnly: false,
145
+ }
146
+ );
147
+
148
+ const emit = defineEmits<{
149
+ (e: "click", event: MouseEvent): void;
150
+ }>();
151
+
152
+ const slots = useSlots();
153
+ const v = computed(() => VARIANTS[props.variant] || VARIANTS.default);
154
+ const s = computed(() => SIZES[props.size] || SIZES.md);
155
+
156
+ const hasDefaultText = computed(() => {
157
+ if (!slots.default) return false;
158
+ const nodes = slots.default();
159
+ if (!nodes || nodes.length === 0) return false;
160
+ return nodes.some((node: VNode) => {
161
+ if (node.type === Symbol.for("v-cmt")) return false;
162
+ if (typeof node.children === "string") return node.children.trim().length > 0;
163
+ if (Array.isArray(node.children)) return node.children.length > 0;
164
+ return Boolean(node.type);
165
+ });
166
+ });
167
+
168
+ const isIconOnly = computed(() => {
169
+ if (props.iconOnly || props.variant === "icon") return true;
170
+ const hasIconSlot = Boolean(slots.icon) || Boolean(slots.iconRight);
171
+ return hasIconSlot && !hasDefaultText.value;
172
+ });
173
+ </script>
174
+
175
+ <template>
176
+ <button
177
+ :type="type"
178
+ :disabled="disabled || loading"
179
+ :class="[`btn btn-${variant}`, 'inline-flex items-center justify-center gap-1.5 font-medium transition select-none flex-shrink-0']"
180
+ :style="{
181
+ borderRadius: 'var(--rads, 8px)',
182
+ fontFamily: 'var(--f, var(--sans, inherit))',
183
+ cursor: disabled ? 'not-allowed' : 'pointer',
184
+ whiteSpace: 'nowrap',
185
+ letterSpacing: '-.01em',
186
+ outline: 'none',
187
+ boxShadow: v.boxShadow !== undefined ? v.boxShadow : 'var(--shadow, 0 1px 3px rgba(20,22,41,.1))',
188
+ opacity: disabled ? 0.45 : 1,
189
+ pointerEvents: disabled ? 'none' : undefined,
190
+ background: v.background,
191
+ color: v.color,
192
+ border: v.border,
193
+ padding: isIconOnly ? '0' : s.padding,
194
+ fontSize: `${s.fontSize}px`,
195
+ height: `${s.height}px`,
196
+ width: isIconOnly ? `${s.height}px` : undefined,
197
+ minWidth: isIconOnly ? `${s.height}px` : undefined,
198
+ maxWidth: isIconOnly ? `${s.height}px` : undefined,
199
+ ...(v.paddingLeft !== undefined && { paddingLeft: v.paddingLeft }),
200
+ ...(v.paddingRight !== undefined && { paddingRight: v.paddingRight }),
201
+ }"
202
+ @click="emit('click', $event)"
203
+ >
204
+ <Spinner v-if="loading" :size="14" inline color="currentColor" />
205
+ <slot v-if="!loading" name="icon" />
206
+ <slot v-if="!loading" />
207
+ <slot v-if="!loading" name="iconRight" />
208
+ </button>
209
+ </template>
@@ -1,103 +1,103 @@
1
- <script setup lang="ts">
2
- import { computed } from "vue";
3
-
4
- const props = withDefaults(
5
- defineProps<{
6
- modelValue?: boolean;
7
- checked?: boolean;
8
- indeterminate?: boolean;
9
- disabled?: boolean;
10
- size?: "sm" | "md";
11
- label?: string;
12
- }>(),
13
- {
14
- modelValue: false,
15
- checked: false,
16
- indeterminate: false,
17
- disabled: false,
18
- size: "md",
19
- label: "",
20
- }
21
- );
22
-
23
- const emit = defineEmits<{
24
- (e: "update:modelValue", value: boolean): void;
25
- (e: "change", value: boolean): void;
26
- }>();
27
-
28
- const isChecked = computed(() => props.modelValue || props.checked);
29
- const dims = computed(() =>
30
- props.size === "sm" ? { w: 14, h: 14, icon: 8 } : { w: 16, h: 16, icon: 10 }
31
- );
32
-
33
- const toggle = () => {
34
- if (props.disabled) return;
35
- const next = !isChecked.value;
36
- emit("update:modelValue", next);
37
- emit("change", next);
38
- };
39
- </script>
40
-
41
- <template>
42
- <label
43
- class="inline-flex items-center gap-1.5 cursor-pointer select-none m-0 p-0 leading-none transition"
44
- :style="{
45
- opacity: disabled ? 0.45 : 1,
46
- cursor: disabled ? 'not-allowed' : 'pointer',
47
- verticalAlign: 'middle',
48
- boxSizing: 'border-box',
49
- }"
50
- @click.prevent="toggle"
51
- >
52
- <span
53
- class="relative flex-shrink-0 transition-all duration-150 flex items-center justify-center overflow-hidden"
54
- :style="{
55
- width: `${dims.w}px`,
56
- height: `${dims.h}px`,
57
- boxSizing: 'border-box',
58
- verticalAlign: 'middle',
59
- border: `1.5px solid ${isChecked || indeterminate ? 'var(--accent, #12675D)' : 'var(--border, #e2e8f0)'}`,
60
- borderRadius: size === 'sm' ? '3px' : '4px',
61
- background: isChecked || indeterminate ? 'var(--accent, #12675D)' : 'var(--input-bg, #ffffff)',
62
- }"
63
- >
64
- <!-- Indeterminate dash -->
65
- <svg
66
- v-if="indeterminate"
67
- :width="dims.icon"
68
- :height="dims.icon"
69
- viewBox="0 0 10 10"
70
- fill="none"
71
- style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: block; pointer-events: none;"
72
- >
73
- <line x1="2" y1="5" x2="8" y2="5" stroke="white" stroke-width="1.6" stroke-linecap="round" />
74
- </svg>
75
-
76
- <!-- Checked checkmark -->
77
- <svg
78
- v-else-if="isChecked"
79
- :width="dims.icon"
80
- :height="dims.icon"
81
- viewBox="0 0 10 10"
82
- fill="none"
83
- style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: block; pointer-events: none;"
84
- >
85
- <polyline
86
- points="1.5,5 4,7.5 8.5,2.5"
87
- stroke="white"
88
- stroke-width="1.6"
89
- stroke-linecap="round"
90
- stroke-linejoin="round"
91
- />
92
- </svg>
93
- </span>
94
-
95
- <span
96
- v-if="label || $slots.default"
97
- :style="{ fontSize: size === 'sm' ? '.72rem' : '.78rem', lineHeight: '1.2' }"
98
- class="text-[var(--primary-text,#0f172a)] font-semibold select-none"
99
- >
100
- <slot>{{ label }}</slot>
101
- </span>
102
- </label>
103
- </template>
1
+ <script setup lang="ts">
2
+ import { computed } from "vue";
3
+
4
+ const props = withDefaults(
5
+ defineProps<{
6
+ modelValue?: boolean;
7
+ checked?: boolean;
8
+ indeterminate?: boolean;
9
+ disabled?: boolean;
10
+ size?: "sm" | "md";
11
+ label?: string;
12
+ }>(),
13
+ {
14
+ modelValue: false,
15
+ checked: false,
16
+ indeterminate: false,
17
+ disabled: false,
18
+ size: "md",
19
+ label: "",
20
+ }
21
+ );
22
+
23
+ const emit = defineEmits<{
24
+ (e: "update:modelValue", value: boolean): void;
25
+ (e: "change", value: boolean): void;
26
+ }>();
27
+
28
+ const isChecked = computed(() => props.modelValue || props.checked);
29
+ const dims = computed(() =>
30
+ props.size === "sm" ? { w: 14, h: 14, icon: 8 } : { w: 16, h: 16, icon: 10 }
31
+ );
32
+
33
+ const toggle = () => {
34
+ if (props.disabled) return;
35
+ const next = !isChecked.value;
36
+ emit("update:modelValue", next);
37
+ emit("change", next);
38
+ };
39
+ </script>
40
+
41
+ <template>
42
+ <label
43
+ class="inline-flex items-center gap-1.5 cursor-pointer select-none m-0 p-0 leading-none transition"
44
+ :style="{
45
+ opacity: disabled ? 0.45 : 1,
46
+ cursor: disabled ? 'not-allowed' : 'pointer',
47
+ verticalAlign: 'middle',
48
+ boxSizing: 'border-box',
49
+ }"
50
+ @click.prevent="toggle"
51
+ >
52
+ <span
53
+ class="relative flex-shrink-0 transition-all duration-150 flex items-center justify-center overflow-hidden"
54
+ :style="{
55
+ width: `${dims.w}px`,
56
+ height: `${dims.h}px`,
57
+ boxSizing: 'border-box',
58
+ verticalAlign: 'middle',
59
+ border: `1.5px solid ${isChecked || indeterminate ? 'var(--accent, #12675D)' : 'var(--border, #e2e8f0)'}`,
60
+ borderRadius: size === 'sm' ? '3px' : '4px',
61
+ background: isChecked || indeterminate ? 'var(--accent, #12675D)' : 'var(--input-bg, #ffffff)',
62
+ }"
63
+ >
64
+ <!-- Indeterminate dash -->
65
+ <svg
66
+ v-if="indeterminate"
67
+ :width="dims.icon"
68
+ :height="dims.icon"
69
+ viewBox="0 0 10 10"
70
+ fill="none"
71
+ style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: block; pointer-events: none;"
72
+ >
73
+ <line x1="2" y1="5" x2="8" y2="5" stroke="white" stroke-width="1.6" stroke-linecap="round" />
74
+ </svg>
75
+
76
+ <!-- Checked checkmark -->
77
+ <svg
78
+ v-else-if="isChecked"
79
+ :width="dims.icon"
80
+ :height="dims.icon"
81
+ viewBox="0 0 10 10"
82
+ fill="none"
83
+ style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: block; pointer-events: none;"
84
+ >
85
+ <polyline
86
+ points="1.5,5 4,7.5 8.5,2.5"
87
+ stroke="white"
88
+ stroke-width="1.6"
89
+ stroke-linecap="round"
90
+ stroke-linejoin="round"
91
+ />
92
+ </svg>
93
+ </span>
94
+
95
+ <span
96
+ v-if="label || $slots.default"
97
+ :style="{ fontSize: size === 'sm' ? '.72rem' : '.78rem', lineHeight: '1.2' }"
98
+ class="text-[var(--primary-text,#0f172a)] font-semibold select-none"
99
+ >
100
+ <slot>{{ label }}</slot>
101
+ </span>
102
+ </label>
103
+ </template>