@sprawlify/vue 0.0.64 → 0.0.66
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/chunk-BN_g-Awi.js +18 -0
- package/dist/clean-props-ChPEW0vT.js +9 -0
- package/dist/collapsible-BBV8R9Wm.js +259 -0
- package/dist/collection-DR2kMzrX.js +218 -0
- package/dist/components/accordion/index.d.ts +195 -0
- package/dist/components/accordion/index.js +361 -0
- package/dist/components/angle-slider/index.d.ts +230 -0
- package/dist/components/angle-slider/index.js +371 -0
- package/dist/components/avatar/index.d.ts +116 -0
- package/dist/components/avatar/index.js +177 -0
- package/dist/components/bottom-sheet/index.d.ts +241 -0
- package/dist/components/bottom-sheet/index.js +429 -0
- package/dist/components/carousel/index.d.ts +306 -0
- package/dist/components/carousel/index.js +500 -0
- package/dist/components/checkbox/index.d.ts +273 -0
- package/dist/components/checkbox/index.js +500 -0
- package/dist/components/client-only/index.d.ts +20 -0
- package/dist/components/client-only/index.js +22 -0
- package/dist/components/clipboard/index.d.ts +204 -0
- package/dist/components/clipboard/index.js +297 -0
- package/dist/components/collapsible/index.d.ts +163 -0
- package/dist/components/collapsible/index.js +7 -0
- package/dist/components/collection/index.d.ts +2 -0
- package/dist/components/collection/index.js +4 -0
- package/dist/components/field/index.d.ts +326 -0
- package/dist/components/field/index.js +7 -0
- package/dist/components/fieldset/index.d.ts +161 -0
- package/dist/components/fieldset/index.js +7 -0
- package/dist/components/presence/index.d.ts +3 -0
- package/dist/components/presence/index.js +6 -0
- package/dist/components/select/index.d.ts +429 -0
- package/dist/components/select/index.js +769 -0
- package/dist/core-DNndr38p.js +337 -0
- package/dist/create-split-props-YZ3qgXe_.js +11 -0
- package/dist/factory-BH3WrWd2.js +68 -0
- package/dist/factory-D_ge_w76.d.ts +8 -0
- package/dist/field-DnHnX3Tf.js +501 -0
- package/dist/fieldset-DzhN7Zrg.js +278 -0
- package/dist/index-B66Om_3U.d.ts +22 -0
- package/dist/index-DqRk-Yea.d.ts +199 -0
- package/dist/index-rHf4D8np.d.ts +57 -0
- package/dist/index.d.ts +10 -34
- package/dist/index.js +4 -551
- package/dist/presence-CvUnYMZQ.js +105 -0
- package/dist/presence-types-Bv1E60Cw.d.ts +13 -0
- package/dist/providers-B2CNPFg1.js +108 -0
- package/dist/types-Bj-dS2Hc.d.ts +9 -0
- package/dist/use-forward-expose-4p5AGAI3.js +67 -0
- package/dist/use-render-strategy-BkxoN6ll.js +7 -0
- package/dist/use-render-strategy-CHj_pCfT.d.ts +9 -0
- package/dist/utils-B4FuOOE-.js +51 -0
- package/package.json +58 -2
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
import { t as __exportAll } from "../../chunk-BN_g-Awi.js";
|
|
2
|
+
import { n as useMachine, r as normalizeProps$1, t as mergeProps$1 } from "../../core-DNndr38p.js";
|
|
3
|
+
import { a as useLocaleContext, c as useEnvironmentContext, i as DEFAULT_LOCALE, s as DEFAULT_ENVIRONMENT } from "../../providers-B2CNPFg1.js";
|
|
4
|
+
import { r as createContext, t as useForwardExpose } from "../../use-forward-expose-4p5AGAI3.js";
|
|
5
|
+
import { t as sprawlify } from "../../factory-BH3WrWd2.js";
|
|
6
|
+
import { t as cleanProps } from "../../clean-props-ChPEW0vT.js";
|
|
7
|
+
import { u as useFieldsetContext } from "../../fieldset-DzhN7Zrg.js";
|
|
8
|
+
import { m as useFieldContext } from "../../field-DnHnX3Tf.js";
|
|
9
|
+
import { computed, createBlock, defineComponent, getCurrentInstance, guardReactiveProps, mergeDefaults, mergeProps, nextTick, normalizeProps, openBlock, ref, renderSlot, toRefs, toValue, unref, useId, watch, withCtx } from "vue";
|
|
10
|
+
import * as checkbox from "@sprawlify/primitives/machines/checkbox";
|
|
11
|
+
import { anatomy } from "@sprawlify/primitives/machines/checkbox";
|
|
12
|
+
|
|
13
|
+
//#region src/components/checkbox/use-checkbox-context.ts
|
|
14
|
+
const [CheckboxProvider, useCheckboxContext] = createContext("CheckboxContext");
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/components/checkbox/checkbox-context.vue?vue&type=script&setup=true&lang.ts
|
|
18
|
+
var checkbox_context_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
19
|
+
__name: "checkbox-context",
|
|
20
|
+
setup(__props) {
|
|
21
|
+
const checkbox = useCheckboxContext();
|
|
22
|
+
return (_ctx, _cache) => {
|
|
23
|
+
return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(unref(checkbox))));
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/components/checkbox/checkbox-context.vue
|
|
30
|
+
var checkbox_context_default = checkbox_context_vue_vue_type_script_setup_true_lang_default;
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/components/checkbox/checkbox-control.vue?vue&type=script&setup=true&lang.ts
|
|
34
|
+
var checkbox_control_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
35
|
+
__name: "checkbox-control",
|
|
36
|
+
props: { asChild: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
required: false
|
|
39
|
+
} },
|
|
40
|
+
setup(__props) {
|
|
41
|
+
const checkbox = useCheckboxContext();
|
|
42
|
+
useForwardExpose();
|
|
43
|
+
return (_ctx, _cache) => {
|
|
44
|
+
return openBlock(), createBlock(unref(sprawlify).div, mergeProps(unref(checkbox).getControlProps(), { "as-child": __props.asChild }), {
|
|
45
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
46
|
+
_: 3
|
|
47
|
+
}, 16, ["as-child"]);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/components/checkbox/checkbox-control.vue
|
|
54
|
+
var checkbox_control_default = checkbox_control_vue_vue_type_script_setup_true_lang_default;
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/components/checkbox/checkbox-anatomy.ts
|
|
58
|
+
const checkboxAnatomy = anatomy.extendWith("group");
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/utils/boolean.ts
|
|
62
|
+
const toBooleanValue = (value) => {
|
|
63
|
+
return typeof value === "boolean" ? value : value === "true";
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/components/use-v-model.ts
|
|
68
|
+
function useVModel(props, key, emit, options = {}) {
|
|
69
|
+
const { passive = false, eventName, defaultValue } = options;
|
|
70
|
+
const vm = getCurrentInstance();
|
|
71
|
+
const _emit = emit || vm?.emit || vm?.$emit?.bind(vm) || vm?.proxy?.$emit?.bind(vm?.proxy);
|
|
72
|
+
const prop = key || "modelValue";
|
|
73
|
+
const getValue = () => props[prop] ?? defaultValue;
|
|
74
|
+
const triggerEmit = (value) => {
|
|
75
|
+
if (!eventName) _emit(eventName || `update:${prop.toString()}`, value);
|
|
76
|
+
else for (const event of eventName) _emit(event, value);
|
|
77
|
+
};
|
|
78
|
+
if (passive) {
|
|
79
|
+
const proxy = ref(getValue());
|
|
80
|
+
let isUpdating = false;
|
|
81
|
+
watch(() => props[prop], (v) => {
|
|
82
|
+
if (!isUpdating) {
|
|
83
|
+
isUpdating = true;
|
|
84
|
+
proxy.value = v;
|
|
85
|
+
nextTick(() => {
|
|
86
|
+
isUpdating = false;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
watch(proxy, (v) => {
|
|
91
|
+
if (!isUpdating && v !== props[prop]) triggerEmit(v);
|
|
92
|
+
});
|
|
93
|
+
return proxy;
|
|
94
|
+
}
|
|
95
|
+
return computed({
|
|
96
|
+
get() {
|
|
97
|
+
return getValue();
|
|
98
|
+
},
|
|
99
|
+
set(value) {
|
|
100
|
+
triggerEmit(value);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/components/checkbox/use-checkbox-group.ts
|
|
107
|
+
function useCheckboxGroup(props, emit) {
|
|
108
|
+
const fieldset = useFieldsetContext();
|
|
109
|
+
const disabled = computed(() => props.disabled ?? fieldset?.value?.disabled);
|
|
110
|
+
const invalid = computed(() => props.invalid ?? fieldset?.value?.invalid);
|
|
111
|
+
const interactive = computed(() => !(disabled.value || props.readOnly));
|
|
112
|
+
const { defaultValue } = toRefs(props);
|
|
113
|
+
const valueRef = useVModel(props, "modelValue", emit, {
|
|
114
|
+
defaultValue: defaultValue?.value ?? [],
|
|
115
|
+
passive: props.modelValue === void 0,
|
|
116
|
+
eventName: ["valueChange", "update:modelValue"]
|
|
117
|
+
});
|
|
118
|
+
const isChecked = (val) => {
|
|
119
|
+
return valueRef.value.some((v) => String(v) === String(val));
|
|
120
|
+
};
|
|
121
|
+
const toggleValue = (val) => {
|
|
122
|
+
isChecked(val) ? removeValue(val) : addValue(val);
|
|
123
|
+
};
|
|
124
|
+
const addValue = (val) => {
|
|
125
|
+
if (!interactive.value) return;
|
|
126
|
+
if (isChecked(val)) return;
|
|
127
|
+
valueRef.value = valueRef.value.concat(val);
|
|
128
|
+
};
|
|
129
|
+
const removeValue = (val) => {
|
|
130
|
+
if (!interactive.value) return;
|
|
131
|
+
valueRef.value = valueRef.value.filter((v) => String(v) !== String(val));
|
|
132
|
+
};
|
|
133
|
+
const getItemProps = (itemProps) => {
|
|
134
|
+
return {
|
|
135
|
+
checked: itemProps.value != null ? isChecked(itemProps.value) : void 0,
|
|
136
|
+
onCheckedChange() {
|
|
137
|
+
if (itemProps.value != null) toggleValue(itemProps.value);
|
|
138
|
+
},
|
|
139
|
+
name: props.name,
|
|
140
|
+
disabled: toBooleanValue(disabled.value),
|
|
141
|
+
readOnly: props.readOnly,
|
|
142
|
+
invalid: invalid.value
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
const setValue = (value) => {
|
|
146
|
+
valueRef.value = value;
|
|
147
|
+
};
|
|
148
|
+
return computed(() => ({
|
|
149
|
+
isChecked,
|
|
150
|
+
value: valueRef.value,
|
|
151
|
+
name: props.name,
|
|
152
|
+
disabled: toBooleanValue(disabled.value),
|
|
153
|
+
readOnly: props.readOnly,
|
|
154
|
+
invalid: invalid.value,
|
|
155
|
+
addValue,
|
|
156
|
+
setValue,
|
|
157
|
+
toggleValue,
|
|
158
|
+
getItemProps
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/components/checkbox/use-checkbox-group-context.tsx
|
|
164
|
+
const [CheckboxGroupContextProvider, useCheckboxGroupContext] = createContext("CheckboxGroupContext");
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/components/checkbox/checkbox-group.vue?vue&type=script&setup=true&lang.ts
|
|
168
|
+
var checkbox_group_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
169
|
+
__name: "checkbox-group",
|
|
170
|
+
props: /* @__PURE__ */ mergeDefaults({
|
|
171
|
+
defaultValue: {
|
|
172
|
+
type: Array,
|
|
173
|
+
required: false
|
|
174
|
+
},
|
|
175
|
+
modelValue: {
|
|
176
|
+
type: Array,
|
|
177
|
+
required: false
|
|
178
|
+
},
|
|
179
|
+
disabled: {
|
|
180
|
+
type: Boolean,
|
|
181
|
+
required: false
|
|
182
|
+
},
|
|
183
|
+
readOnly: {
|
|
184
|
+
type: Boolean,
|
|
185
|
+
required: false
|
|
186
|
+
},
|
|
187
|
+
name: {
|
|
188
|
+
type: String,
|
|
189
|
+
required: false
|
|
190
|
+
},
|
|
191
|
+
invalid: {
|
|
192
|
+
type: Boolean,
|
|
193
|
+
required: false
|
|
194
|
+
},
|
|
195
|
+
asChild: {
|
|
196
|
+
type: Boolean,
|
|
197
|
+
required: false
|
|
198
|
+
}
|
|
199
|
+
}, {
|
|
200
|
+
disabled: void 0,
|
|
201
|
+
readOnly: void 0,
|
|
202
|
+
invalid: void 0
|
|
203
|
+
}),
|
|
204
|
+
emits: ["valueChange", "update:modelValue"],
|
|
205
|
+
setup(__props, { emit: __emit }) {
|
|
206
|
+
CheckboxGroupContextProvider(useCheckboxGroup(__props, __emit));
|
|
207
|
+
useForwardExpose();
|
|
208
|
+
return (_ctx, _cache) => {
|
|
209
|
+
return openBlock(), createBlock(unref(sprawlify).div, mergeProps({ role: "group" }, { ...unref(checkboxAnatomy).build().group.attrs }, { "as-child": __props.asChild }), {
|
|
210
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
211
|
+
_: 3
|
|
212
|
+
}, 16, ["as-child"]);
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region src/components/checkbox/checkbox-group.vue
|
|
219
|
+
var checkbox_group_default = checkbox_group_vue_vue_type_script_setup_true_lang_default;
|
|
220
|
+
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/components/checkbox/checkbox-group-provider.vue?vue&type=script&setup=true&lang.ts
|
|
223
|
+
var checkbox_group_provider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
224
|
+
__name: "checkbox-group-provider",
|
|
225
|
+
props: {
|
|
226
|
+
value: {
|
|
227
|
+
type: null,
|
|
228
|
+
required: true
|
|
229
|
+
},
|
|
230
|
+
asChild: {
|
|
231
|
+
type: Boolean,
|
|
232
|
+
required: false
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
setup(__props) {
|
|
236
|
+
const props = __props;
|
|
237
|
+
CheckboxGroupContextProvider(computed(() => props.value));
|
|
238
|
+
useForwardExpose();
|
|
239
|
+
return (_ctx, _cache) => {
|
|
240
|
+
return openBlock(), createBlock(unref(sprawlify).div, mergeProps({ role: "group" }, unref(checkboxAnatomy).build().group.attrs, { "as-child": __props.asChild }), {
|
|
241
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
242
|
+
_: 3
|
|
243
|
+
}, 16, ["as-child"]);
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/components/checkbox/checkbox-group-provider.vue
|
|
250
|
+
var checkbox_group_provider_default = checkbox_group_provider_vue_vue_type_script_setup_true_lang_default;
|
|
251
|
+
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/components/checkbox/checkbox-hidden-input.vue?vue&type=script&setup=true&lang.ts
|
|
254
|
+
var checkbox_hidden_input_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
255
|
+
__name: "checkbox-hidden-input",
|
|
256
|
+
props: { asChild: {
|
|
257
|
+
type: Boolean,
|
|
258
|
+
required: false
|
|
259
|
+
} },
|
|
260
|
+
setup(__props) {
|
|
261
|
+
const checkbox = useCheckboxContext();
|
|
262
|
+
const field = useFieldContext();
|
|
263
|
+
useForwardExpose();
|
|
264
|
+
return (_ctx, _cache) => {
|
|
265
|
+
return openBlock(), createBlock(unref(sprawlify).input, mergeProps({ "aria-describedby": unref(field)?.ariaDescribedby }, unref(checkbox).getHiddenInputProps(), { "as-child": __props.asChild }), {
|
|
266
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
267
|
+
_: 3
|
|
268
|
+
}, 16, ["aria-describedby", "as-child"]);
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/components/checkbox/checkbox-hidden-input.vue
|
|
275
|
+
var checkbox_hidden_input_default = checkbox_hidden_input_vue_vue_type_script_setup_true_lang_default;
|
|
276
|
+
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/components/checkbox/checkbox-indicator.vue?vue&type=script&setup=true&lang.ts
|
|
279
|
+
var checkbox_indicator_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
280
|
+
__name: "checkbox-indicator",
|
|
281
|
+
props: {
|
|
282
|
+
indeterminate: {
|
|
283
|
+
type: Boolean,
|
|
284
|
+
required: false
|
|
285
|
+
},
|
|
286
|
+
asChild: {
|
|
287
|
+
type: Boolean,
|
|
288
|
+
required: false
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
setup(__props) {
|
|
292
|
+
const props = __props;
|
|
293
|
+
const checkbox = useCheckboxContext();
|
|
294
|
+
const isHidden = computed(() => props.indeterminate ? checkbox.value.indeterminate : checkbox.value.checked);
|
|
295
|
+
useForwardExpose();
|
|
296
|
+
return (_ctx, _cache) => {
|
|
297
|
+
return openBlock(), createBlock(unref(sprawlify).div, mergeProps(unref(checkbox).getIndicatorProps(), {
|
|
298
|
+
hidden: !isHidden.value,
|
|
299
|
+
"as-child": __props.asChild
|
|
300
|
+
}), {
|
|
301
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
302
|
+
_: 3
|
|
303
|
+
}, 16, ["hidden", "as-child"]);
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region src/components/checkbox/checkbox-indicator.vue
|
|
310
|
+
var checkbox_indicator_default = checkbox_indicator_vue_vue_type_script_setup_true_lang_default;
|
|
311
|
+
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/components/checkbox/checkbox-label.vue?vue&type=script&setup=true&lang.ts
|
|
314
|
+
var checkbox_label_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
315
|
+
__name: "checkbox-label",
|
|
316
|
+
props: { asChild: {
|
|
317
|
+
type: Boolean,
|
|
318
|
+
required: false
|
|
319
|
+
} },
|
|
320
|
+
setup(__props) {
|
|
321
|
+
const checkbox = useCheckboxContext();
|
|
322
|
+
useForwardExpose();
|
|
323
|
+
return (_ctx, _cache) => {
|
|
324
|
+
return openBlock(), createBlock(unref(sprawlify).span, mergeProps(unref(checkbox).getLabelProps(), { "as-child": __props.asChild }), {
|
|
325
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
326
|
+
_: 3
|
|
327
|
+
}, 16, ["as-child"]);
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region src/components/checkbox/checkbox-label.vue
|
|
334
|
+
var checkbox_label_default = checkbox_label_vue_vue_type_script_setup_true_lang_default;
|
|
335
|
+
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/components/checkbox/checkbox-root-provider.vue?vue&type=script&setup=true&lang.ts
|
|
338
|
+
var checkbox_root_provider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
339
|
+
__name: "checkbox-root-provider",
|
|
340
|
+
props: {
|
|
341
|
+
value: {
|
|
342
|
+
type: null,
|
|
343
|
+
required: true
|
|
344
|
+
},
|
|
345
|
+
asChild: {
|
|
346
|
+
type: Boolean,
|
|
347
|
+
required: false
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
setup(__props) {
|
|
351
|
+
const props = __props;
|
|
352
|
+
const checkbox = computed(() => props.value);
|
|
353
|
+
CheckboxProvider(checkbox);
|
|
354
|
+
useForwardExpose();
|
|
355
|
+
return (_ctx, _cache) => {
|
|
356
|
+
return openBlock(), createBlock(unref(sprawlify).label, mergeProps(checkbox.value.getRootProps(), { "as-child": __props.asChild }), {
|
|
357
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
358
|
+
_: 3
|
|
359
|
+
}, 16, ["as-child"]);
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region src/components/checkbox/checkbox-root-provider.vue
|
|
366
|
+
var checkbox_root_provider_default = checkbox_root_provider_vue_vue_type_script_setup_true_lang_default;
|
|
367
|
+
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/components/checkbox/use-checkbox.ts
|
|
370
|
+
const useCheckbox = (props = {}, emit) => {
|
|
371
|
+
const id = useId();
|
|
372
|
+
const env = useEnvironmentContext(DEFAULT_ENVIRONMENT);
|
|
373
|
+
const locale = useLocaleContext(DEFAULT_LOCALE);
|
|
374
|
+
const field = useFieldContext();
|
|
375
|
+
const checkboxGroup = useCheckboxGroupContext();
|
|
376
|
+
const computedProps = computed(() => {
|
|
377
|
+
const propsValue = toValue(props);
|
|
378
|
+
return mergeProps$1(checkboxGroup?.value.getItemProps({ value: propsValue.value }) ?? {}, propsValue);
|
|
379
|
+
});
|
|
380
|
+
const context = computed(() => {
|
|
381
|
+
const localProps = toValue(computedProps);
|
|
382
|
+
return {
|
|
383
|
+
id,
|
|
384
|
+
ids: {
|
|
385
|
+
label: field?.value.ids.label,
|
|
386
|
+
hiddenInput: field?.value.ids.control
|
|
387
|
+
},
|
|
388
|
+
disabled: field?.value.disabled,
|
|
389
|
+
readOnly: field?.value.readOnly,
|
|
390
|
+
invalid: field?.value.invalid,
|
|
391
|
+
required: field?.value.required,
|
|
392
|
+
dir: locale.value.dir,
|
|
393
|
+
getRootNode: env?.value.getRootNode,
|
|
394
|
+
...cleanProps(localProps),
|
|
395
|
+
onCheckedChange(details) {
|
|
396
|
+
emit?.("checkedChange", details);
|
|
397
|
+
emit?.("update:checked", details.checked);
|
|
398
|
+
localProps.onCheckedChange?.(details);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
});
|
|
402
|
+
const service = useMachine(checkbox.machine, context);
|
|
403
|
+
return computed(() => checkbox.connect(service, normalizeProps$1));
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/components/checkbox/checkbox-root.vue?vue&type=script&setup=true&lang.ts
|
|
408
|
+
var checkbox_root_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
409
|
+
__name: "checkbox-root",
|
|
410
|
+
props: /* @__PURE__ */ mergeDefaults({
|
|
411
|
+
checked: {
|
|
412
|
+
type: null,
|
|
413
|
+
required: false
|
|
414
|
+
},
|
|
415
|
+
defaultChecked: {
|
|
416
|
+
type: null,
|
|
417
|
+
required: false
|
|
418
|
+
},
|
|
419
|
+
disabled: {
|
|
420
|
+
type: Boolean,
|
|
421
|
+
required: false
|
|
422
|
+
},
|
|
423
|
+
form: {
|
|
424
|
+
type: String,
|
|
425
|
+
required: false
|
|
426
|
+
},
|
|
427
|
+
id: {
|
|
428
|
+
type: String,
|
|
429
|
+
required: false
|
|
430
|
+
},
|
|
431
|
+
ids: {
|
|
432
|
+
type: Object,
|
|
433
|
+
required: false
|
|
434
|
+
},
|
|
435
|
+
invalid: {
|
|
436
|
+
type: Boolean,
|
|
437
|
+
required: false
|
|
438
|
+
},
|
|
439
|
+
name: {
|
|
440
|
+
type: String,
|
|
441
|
+
required: false
|
|
442
|
+
},
|
|
443
|
+
readOnly: {
|
|
444
|
+
type: Boolean,
|
|
445
|
+
required: false
|
|
446
|
+
},
|
|
447
|
+
required: {
|
|
448
|
+
type: Boolean,
|
|
449
|
+
required: false
|
|
450
|
+
},
|
|
451
|
+
value: {
|
|
452
|
+
type: String,
|
|
453
|
+
required: false
|
|
454
|
+
},
|
|
455
|
+
asChild: {
|
|
456
|
+
type: Boolean,
|
|
457
|
+
required: false
|
|
458
|
+
}
|
|
459
|
+
}, {
|
|
460
|
+
checked: void 0,
|
|
461
|
+
defaultChecked: void 0,
|
|
462
|
+
disabled: void 0,
|
|
463
|
+
invalid: void 0,
|
|
464
|
+
readOnly: void 0,
|
|
465
|
+
required: void 0
|
|
466
|
+
}),
|
|
467
|
+
emits: ["checkedChange", "update:checked"],
|
|
468
|
+
setup(__props, { emit: __emit }) {
|
|
469
|
+
const checkbox = useCheckbox(__props, __emit);
|
|
470
|
+
CheckboxProvider(checkbox);
|
|
471
|
+
useForwardExpose();
|
|
472
|
+
return (_ctx, _cache) => {
|
|
473
|
+
return openBlock(), createBlock(unref(sprawlify).label, mergeProps(unref(checkbox).getRootProps(), { "as-child": __props.asChild }), {
|
|
474
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
475
|
+
_: 3
|
|
476
|
+
}, 16, ["as-child"]);
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region src/components/checkbox/checkbox-root.vue
|
|
483
|
+
var checkbox_root_default = checkbox_root_vue_vue_type_script_setup_true_lang_default;
|
|
484
|
+
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/components/checkbox/checkbox.ts
|
|
487
|
+
var checkbox_exports = /* @__PURE__ */ __exportAll({
|
|
488
|
+
Context: () => checkbox_context_default,
|
|
489
|
+
Control: () => checkbox_control_default,
|
|
490
|
+
Group: () => checkbox_group_default,
|
|
491
|
+
GroupProvider: () => checkbox_group_provider_default,
|
|
492
|
+
HiddenInput: () => checkbox_hidden_input_default,
|
|
493
|
+
Indicator: () => checkbox_indicator_default,
|
|
494
|
+
Label: () => checkbox_label_default,
|
|
495
|
+
Root: () => checkbox_root_default,
|
|
496
|
+
RootProvider: () => checkbox_root_provider_default
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
//#endregion
|
|
500
|
+
export { checkbox_exports as Checkbox, checkbox_context_default as CheckboxContext, checkbox_control_default as CheckboxControl, checkbox_group_default as CheckboxGroup, checkbox_group_provider_default as CheckboxGroupProvider, checkbox_hidden_input_default as CheckboxHiddenInput, checkbox_indicator_default as CheckboxIndicator, checkbox_label_default as CheckboxLabel, checkbox_root_default as CheckboxRoot, checkbox_root_provider_default as CheckboxRootProvider, checkboxAnatomy, useCheckbox, useCheckboxContext, useCheckboxGroup, useCheckboxGroupContext };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as vue258 from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/components/client-only/client-only.vue.d.ts
|
|
4
|
+
type ClientOnlyProps = {};
|
|
5
|
+
declare var __VLS_1: {}, __VLS_3: {};
|
|
6
|
+
type __VLS_Slots = {} & {
|
|
7
|
+
default?: (props: typeof __VLS_1) => any;
|
|
8
|
+
} & {
|
|
9
|
+
fallback?: (props: typeof __VLS_3) => any;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_base: vue258.DefineComponent<{}, {}, {}, {}, {}, vue258.ComponentOptionsMixin, vue258.ComponentOptionsMixin, {}, string, vue258.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue258.ComponentProvideOptions, true, {}, any>;
|
|
12
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
15
|
+
new (): {
|
|
16
|
+
$slots: S;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { _default as ClientOnly, type ClientOnlyProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createCommentVNode, defineComponent, onMounted, ref, renderSlot } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/components/client-only/client-only.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var client_only_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
5
|
+
__name: "client-only",
|
|
6
|
+
setup(__props) {
|
|
7
|
+
const isClient = ref(false);
|
|
8
|
+
onMounted(() => {
|
|
9
|
+
isClient.value = true;
|
|
10
|
+
});
|
|
11
|
+
return (_ctx, _cache) => {
|
|
12
|
+
return isClient.value ? renderSlot(_ctx.$slots, "default", { key: 0 }) : renderSlot(_ctx.$slots, "fallback", { key: 1 });
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/components/client-only/client-only.vue
|
|
19
|
+
var client_only_default = client_only_vue_vue_type_script_setup_true_lang_default;
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { client_only_default as ClientOnly };
|