@auronui/vue 1.0.3 → 1.0.4
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/cjs/index.cjs +440 -37
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/autocomplete/Autocomplete.context.js.map +1 -1
- package/dist/components/autocomplete/Autocomplete.js.map +1 -1
- package/dist/components/autocomplete/Autocomplete.vue_vue_type_script_setup_true_lang.js +24 -3
- package/dist/components/autocomplete/Autocomplete.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/autocomplete/AutocompleteContent.js.map +1 -1
- package/dist/components/autocomplete/AutocompleteContent.vue_vue_type_script_setup_true_lang.js +39 -1
- package/dist/components/autocomplete/AutocompleteContent.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/autocomplete/AutocompleteItem.js.map +1 -1
- package/dist/components/autocomplete/AutocompleteItem.vue_vue_type_script_setup_true_lang.js +24 -4
- package/dist/components/autocomplete/AutocompleteItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/combo-box/ComboBox.context.js.map +1 -1
- package/dist/components/combo-box/ComboBox.js.map +1 -1
- package/dist/components/combo-box/ComboBox.vue_vue_type_script_setup_true_lang.js +46 -11
- package/dist/components/combo-box/ComboBox.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/combo-box/ComboBoxContent.js.map +1 -1
- package/dist/components/combo-box/ComboBoxContent.vue_vue_type_script_setup_true_lang.js +35 -1
- package/dist/components/combo-box/ComboBoxContent.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/combo-box/ComboBoxItem.js.map +1 -1
- package/dist/components/combo-box/ComboBoxItem.vue_vue_type_script_setup_true_lang.js +27 -5
- package/dist/components/combo-box/ComboBoxItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/date-time-picker/DateTimePicker.js.map +1 -1
- package/dist/components/date-time-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/components/date-time-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/form/Form.js +7 -0
- package/dist/components/form/Form.js.map +1 -0
- package/dist/components/form/Form.vue_vue_type_script_setup_true_lang.js +97 -0
- package/dist/components/form/Form.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/form/FormField.js +7 -0
- package/dist/components/form/FormField.js.map +1 -0
- package/dist/components/form/FormField.vue_vue_type_script_setup_true_lang.js +75 -0
- package/dist/components/form/FormField.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/form/form.context.js +15 -0
- package/dist/components/form/form.context.js.map +1 -0
- package/dist/components/form/validation.js +71 -0
- package/dist/components/form/validation.js.map +1 -0
- package/dist/components/select/SelectContent.js.map +1 -1
- package/dist/components/select/SelectContent.vue_vue_type_script_setup_true_lang.js +7 -14
- package/dist/components/select/SelectContent.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/select/SelectItem.js.map +1 -1
- package/dist/components/select/SelectItem.vue_vue_type_script_setup_true_lang.js +3 -1
- package/dist/components/select/SelectItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/select/SelectValue.js.map +1 -1
- package/dist/components/select/SelectValue.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/select/SelectValue.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/index.js +3 -1
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -1442,6 +1442,244 @@ var Link_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
1442
1442
|
}
|
|
1443
1443
|
});
|
|
1444
1444
|
//#endregion
|
|
1445
|
+
//#region src/components/form/form.context.ts
|
|
1446
|
+
var { useProvide: useFormProvide, useInject: _useFormInjectStrict, key: formContextKey } = createContext("Form");
|
|
1447
|
+
/**
|
|
1448
|
+
* Inject Form context. Returns null when called outside a <Form> — callers
|
|
1449
|
+
* handle standalone mode themselves.
|
|
1450
|
+
*/
|
|
1451
|
+
function useFormInject() {
|
|
1452
|
+
return (0, vue.inject)(formContextKey, null);
|
|
1453
|
+
}
|
|
1454
|
+
//#endregion
|
|
1455
|
+
//#region src/components/form/validation.ts
|
|
1456
|
+
var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1457
|
+
function isEmpty(value) {
|
|
1458
|
+
if (value === void 0 || value === null || value === "" || value === false) return true;
|
|
1459
|
+
if (Array.isArray(value) && value.length === 0) return true;
|
|
1460
|
+
return false;
|
|
1461
|
+
}
|
|
1462
|
+
function resolveSimpleRule(rule) {
|
|
1463
|
+
if (typeof rule === "string") return {
|
|
1464
|
+
enabled: true,
|
|
1465
|
+
message: rule
|
|
1466
|
+
};
|
|
1467
|
+
return {
|
|
1468
|
+
enabled: rule,
|
|
1469
|
+
message: void 0
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
function resolveNumericRule(rule) {
|
|
1473
|
+
if (typeof rule === "number") return {
|
|
1474
|
+
value: rule,
|
|
1475
|
+
message: void 0
|
|
1476
|
+
};
|
|
1477
|
+
return rule;
|
|
1478
|
+
}
|
|
1479
|
+
function resolvePatternRule(rule) {
|
|
1480
|
+
if (rule instanceof RegExp) return {
|
|
1481
|
+
value: rule,
|
|
1482
|
+
message: void 0
|
|
1483
|
+
};
|
|
1484
|
+
return rule;
|
|
1485
|
+
}
|
|
1486
|
+
async function runValidation(value, rules, validate) {
|
|
1487
|
+
if (!rules && !validate) return void 0;
|
|
1488
|
+
if (rules?.required !== void 0) {
|
|
1489
|
+
const { enabled, message } = resolveSimpleRule(rules.required);
|
|
1490
|
+
if (enabled && isEmpty(value)) return message ?? "This field is required";
|
|
1491
|
+
}
|
|
1492
|
+
if (isEmpty(value)) {
|
|
1493
|
+
if (validate) return await validate(value);
|
|
1494
|
+
return;
|
|
1495
|
+
}
|
|
1496
|
+
if (rules?.email !== void 0) {
|
|
1497
|
+
const { enabled, message } = resolveSimpleRule(rules.email);
|
|
1498
|
+
if (enabled && !EMAIL_REGEX.test(String(value))) return message ?? "Enter a valid email address";
|
|
1499
|
+
}
|
|
1500
|
+
if (rules?.pattern !== void 0) {
|
|
1501
|
+
const { value: regex, message } = resolvePatternRule(rules.pattern);
|
|
1502
|
+
if (!regex.test(String(value))) return message ?? "Invalid format";
|
|
1503
|
+
}
|
|
1504
|
+
if (rules?.minLength !== void 0) {
|
|
1505
|
+
const { value: min, message } = resolveNumericRule(rules.minLength);
|
|
1506
|
+
if ((Array.isArray(value) ? value.length : String(value).length) < min) return message ?? `Must be at least ${min} characters`;
|
|
1507
|
+
}
|
|
1508
|
+
if (rules?.maxLength !== void 0) {
|
|
1509
|
+
const { value: max, message } = resolveNumericRule(rules.maxLength);
|
|
1510
|
+
if ((Array.isArray(value) ? value.length : String(value).length) > max) return message ?? `Must be at most ${max} characters`;
|
|
1511
|
+
}
|
|
1512
|
+
if (rules?.min !== void 0) {
|
|
1513
|
+
const { value: minVal, message } = resolveNumericRule(rules.min);
|
|
1514
|
+
if (Number(value) < minVal) return message ?? `Must be at least ${minVal}`;
|
|
1515
|
+
}
|
|
1516
|
+
if (rules?.max !== void 0) {
|
|
1517
|
+
const { value: maxVal, message } = resolveNumericRule(rules.max);
|
|
1518
|
+
if (Number(value) > maxVal) return message ?? `Must be at most ${maxVal}`;
|
|
1519
|
+
}
|
|
1520
|
+
if (validate) return await validate(value);
|
|
1521
|
+
}
|
|
1522
|
+
//#endregion
|
|
1523
|
+
//#region src/components/form/Form.vue
|
|
1524
|
+
var Form_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
1525
|
+
__name: "Form",
|
|
1526
|
+
props: {
|
|
1527
|
+
validationMode: { default: "on-submit" },
|
|
1528
|
+
isDisabled: {
|
|
1529
|
+
type: Boolean,
|
|
1530
|
+
default: false
|
|
1531
|
+
},
|
|
1532
|
+
class: { default: void 0 }
|
|
1533
|
+
},
|
|
1534
|
+
emits: ["submit", "invalid"],
|
|
1535
|
+
setup(__props, { emit: __emit }) {
|
|
1536
|
+
const props = __props;
|
|
1537
|
+
const emit = __emit;
|
|
1538
|
+
const errors = (0, vue.ref)({});
|
|
1539
|
+
const isSubmitting = (0, vue.ref)(false);
|
|
1540
|
+
const fields = /* @__PURE__ */ new Map();
|
|
1541
|
+
function registerField(reg) {
|
|
1542
|
+
fields.set(reg.name, reg);
|
|
1543
|
+
}
|
|
1544
|
+
function unregisterField(name) {
|
|
1545
|
+
fields.delete(name);
|
|
1546
|
+
const next = { ...errors.value };
|
|
1547
|
+
delete next[name];
|
|
1548
|
+
errors.value = next;
|
|
1549
|
+
}
|
|
1550
|
+
async function triggerFieldValidation(name) {
|
|
1551
|
+
const field = fields.get(name);
|
|
1552
|
+
if (!field) return;
|
|
1553
|
+
const error = await runValidation(field.getValue(), field.rules, field.validate);
|
|
1554
|
+
const next = { ...errors.value };
|
|
1555
|
+
if (error) next[name] = error;
|
|
1556
|
+
else delete next[name];
|
|
1557
|
+
errors.value = next;
|
|
1558
|
+
}
|
|
1559
|
+
function setErrors(newErrors) {
|
|
1560
|
+
errors.value = {
|
|
1561
|
+
...errors.value,
|
|
1562
|
+
...newErrors
|
|
1563
|
+
};
|
|
1564
|
+
isSubmitting.value = false;
|
|
1565
|
+
}
|
|
1566
|
+
async function handleSubmit() {
|
|
1567
|
+
isSubmitting.value = true;
|
|
1568
|
+
const results = await Promise.all([...fields.entries()].map(async ([name, field]) => {
|
|
1569
|
+
return {
|
|
1570
|
+
name,
|
|
1571
|
+
error: await runValidation(field.getValue(), field.rules, field.validate)
|
|
1572
|
+
};
|
|
1573
|
+
}));
|
|
1574
|
+
const nextErrors = {};
|
|
1575
|
+
for (const { name, error } of results) if (error) nextErrors[name] = error;
|
|
1576
|
+
if (Object.keys(nextErrors).length > 0) {
|
|
1577
|
+
errors.value = nextErrors;
|
|
1578
|
+
isSubmitting.value = false;
|
|
1579
|
+
emit("invalid", nextErrors);
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1582
|
+
errors.value = {};
|
|
1583
|
+
const values = {};
|
|
1584
|
+
for (const [name, field] of fields.entries()) values[name] = field.getValue();
|
|
1585
|
+
emit("submit", {
|
|
1586
|
+
values,
|
|
1587
|
+
setErrors
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
(0, vue.provide)(formContextKey, {
|
|
1591
|
+
errors,
|
|
1592
|
+
isSubmitting,
|
|
1593
|
+
isDisabled: (0, vue.computed)(() => props.isDisabled),
|
|
1594
|
+
validationMode: (0, vue.computed)(() => props.validationMode),
|
|
1595
|
+
registerField,
|
|
1596
|
+
unregisterField,
|
|
1597
|
+
triggerFieldValidation,
|
|
1598
|
+
setErrors
|
|
1599
|
+
});
|
|
1600
|
+
return (_ctx, _cache) => {
|
|
1601
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("form", {
|
|
1602
|
+
class: (0, vue.normalizeClass)(props.class),
|
|
1603
|
+
novalidate: "",
|
|
1604
|
+
onSubmit: (0, vue.withModifiers)(handleSubmit, ["prevent"])
|
|
1605
|
+
}, [(0, vue.renderSlot)(_ctx.$slots, "default", {
|
|
1606
|
+
isSubmitting: isSubmitting.value,
|
|
1607
|
+
isDisabled: props.isDisabled,
|
|
1608
|
+
errors: errors.value
|
|
1609
|
+
})], 34);
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
//#endregion
|
|
1614
|
+
//#region src/components/form/FormField.vue
|
|
1615
|
+
var FormField_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
1616
|
+
inheritAttrs: false,
|
|
1617
|
+
__name: "FormField",
|
|
1618
|
+
props: /* @__PURE__ */ (0, vue.mergeModels)({
|
|
1619
|
+
name: {},
|
|
1620
|
+
rules: {},
|
|
1621
|
+
validate: { type: Function },
|
|
1622
|
+
validationMode: {}
|
|
1623
|
+
}, {
|
|
1624
|
+
"modelValue": { default: void 0 },
|
|
1625
|
+
"modelModifiers": {}
|
|
1626
|
+
}),
|
|
1627
|
+
emits: ["update:modelValue"],
|
|
1628
|
+
setup(__props) {
|
|
1629
|
+
const props = __props;
|
|
1630
|
+
const modelValue = (0, vue.useModel)(__props, "modelValue");
|
|
1631
|
+
const ctx = useFormInject();
|
|
1632
|
+
const localError = (0, vue.ref)(void 0);
|
|
1633
|
+
const fieldError = (0, vue.computed)(() => ctx ? ctx.errors.value[props.name] : localError.value);
|
|
1634
|
+
const hasBeenInvalid = (0, vue.ref)(false);
|
|
1635
|
+
(0, vue.watch)(fieldError, (error) => {
|
|
1636
|
+
if (error) hasBeenInvalid.value = true;
|
|
1637
|
+
});
|
|
1638
|
+
const isInvalid = (0, vue.computed)(() => !!fieldError.value);
|
|
1639
|
+
const isDisabled = (0, vue.computed)(() => ctx?.isDisabled.value ?? false);
|
|
1640
|
+
const validationMode = (0, vue.computed)(() => props.validationMode ?? ctx?.validationMode.value ?? "on-submit");
|
|
1641
|
+
(0, vue.onMounted)(() => {
|
|
1642
|
+
ctx?.registerField({
|
|
1643
|
+
name: props.name,
|
|
1644
|
+
getValue: () => modelValue.value,
|
|
1645
|
+
rules: props.rules,
|
|
1646
|
+
validate: props.validate
|
|
1647
|
+
});
|
|
1648
|
+
});
|
|
1649
|
+
(0, vue.onUnmounted)(() => {
|
|
1650
|
+
ctx?.unregisterField(props.name);
|
|
1651
|
+
});
|
|
1652
|
+
async function triggerValidation(val) {
|
|
1653
|
+
const error = await runValidation(val, props.rules, props.validate);
|
|
1654
|
+
if (ctx) {
|
|
1655
|
+
const next = { ...ctx.errors.value };
|
|
1656
|
+
if (error) next[props.name] = error;
|
|
1657
|
+
else delete next[props.name];
|
|
1658
|
+
ctx.errors.value = next;
|
|
1659
|
+
} else localError.value = error;
|
|
1660
|
+
}
|
|
1661
|
+
async function handleUpdate(val) {
|
|
1662
|
+
modelValue.value = val;
|
|
1663
|
+
if (validationMode.value === "on-change" || hasBeenInvalid.value) await triggerValidation(val);
|
|
1664
|
+
}
|
|
1665
|
+
async function handleBlur() {
|
|
1666
|
+
if (validationMode.value === "on-blur") await triggerValidation(modelValue.value);
|
|
1667
|
+
}
|
|
1668
|
+
const fieldProps = (0, vue.computed)(() => ({
|
|
1669
|
+
name: props.name,
|
|
1670
|
+
modelValue: modelValue.value,
|
|
1671
|
+
"onUpdate:modelValue": handleUpdate,
|
|
1672
|
+
isInvalid: isInvalid.value,
|
|
1673
|
+
errorMessage: fieldError.value,
|
|
1674
|
+
isDisabled: isDisabled.value,
|
|
1675
|
+
onBlur: handleBlur
|
|
1676
|
+
}));
|
|
1677
|
+
return (_ctx, _cache) => {
|
|
1678
|
+
return (0, vue.renderSlot)(_ctx.$slots, "default", { fieldProps: fieldProps.value });
|
|
1679
|
+
};
|
|
1680
|
+
}
|
|
1681
|
+
});
|
|
1682
|
+
//#endregion
|
|
1445
1683
|
//#region src/components/input/Input.vue?vue&type=script&setup=true&lang.ts
|
|
1446
1684
|
var _hoisted_1$49 = [
|
|
1447
1685
|
"data-invalid",
|
|
@@ -14720,7 +14958,7 @@ var SelectValue_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
14720
14958
|
placeholder: props.placeholder,
|
|
14721
14959
|
"data-slot": "value"
|
|
14722
14960
|
}, {
|
|
14723
|
-
default: (0, vue.withCtx)(({ modelValue }) => [modelValue != null && (Array.isArray(modelValue) ? modelValue.length > 0 : modelValue !== "") ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key:
|
|
14961
|
+
default: (0, vue.withCtx)(({ selectedLabel, modelValue }) => [selectedLabel && selectedLabel.length > 0 ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 0 }, [(0, vue.createTextVNode)((0, vue.toDisplayString)(selectedLabel.join(", ")), 1)], 64)) : modelValue != null && (Array.isArray(modelValue) ? modelValue.length > 0 : modelValue !== "") ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, [(0, vue.createTextVNode)((0, vue.toDisplayString)((0, vue.unref)(ctx).itemLabel(Array.isArray(modelValue) ? modelValue : modelValue.toString())), 1)], 64)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 2 }, [(0, vue.createTextVNode)((0, vue.toDisplayString)(props.placeholder), 1)], 64))]),
|
|
14724
14962
|
_: 1
|
|
14725
14963
|
}, 8, ["class", "placeholder"]);
|
|
14726
14964
|
};
|
|
@@ -14742,24 +14980,17 @@ var SelectContent_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
14742
14980
|
return (_ctx, _cache) => {
|
|
14743
14981
|
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(reka_ui.SelectPortal), null, {
|
|
14744
14982
|
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(AnimatePresence_default), null, {
|
|
14745
|
-
default: (0, vue.withCtx)(() => [(0, vue.
|
|
14746
|
-
key: 0,
|
|
14983
|
+
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(reka_ui.SelectContent), {
|
|
14747
14984
|
position: props.position,
|
|
14748
14985
|
"side-offset": props.sideOffset,
|
|
14749
|
-
"as-child": "",
|
|
14750
14986
|
"data-slot": "popover"
|
|
14751
14987
|
}, {
|
|
14752
|
-
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(motion).div, {
|
|
14988
|
+
default: (0, vue.withCtx)(() => [(0, vue.withDirectives)((0, vue.createVNode)((0, vue.unref)(motion).div, {
|
|
14753
14989
|
class: (0, vue.normalizeClass)((0, vue.unref)(ctx).slots.value.popover()),
|
|
14754
|
-
|
|
14755
|
-
opacity: 0,
|
|
14756
|
-
scale: .95
|
|
14757
|
-
},
|
|
14758
|
-
animate: {
|
|
14990
|
+
animate: (0, vue.unref)(rootContext).open.value ? {
|
|
14759
14991
|
opacity: 1,
|
|
14760
14992
|
scale: 1
|
|
14761
|
-
}
|
|
14762
|
-
exit: {
|
|
14993
|
+
} : {
|
|
14763
14994
|
opacity: 0,
|
|
14764
14995
|
scale: .95
|
|
14765
14996
|
},
|
|
@@ -14770,9 +15001,9 @@ var SelectContent_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
14770
15001
|
_: 3
|
|
14771
15002
|
})]),
|
|
14772
15003
|
_: 3
|
|
14773
|
-
}, 8, ["class"])]),
|
|
15004
|
+
}, 8, ["class", "animate"]), [[vue.vShow, (0, vue.unref)(rootContext).open.value]])]),
|
|
14774
15005
|
_: 3
|
|
14775
|
-
}, 8, ["position", "side-offset"])
|
|
15006
|
+
}, 8, ["position", "side-offset"])]),
|
|
14776
15007
|
_: 3
|
|
14777
15008
|
})]),
|
|
14778
15009
|
_: 3
|
|
@@ -14797,8 +15028,10 @@ var SelectItem_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
14797
15028
|
const props = __props;
|
|
14798
15029
|
const ctx = useSelectInject();
|
|
14799
15030
|
const textRef = (0, vue.useTemplateRef)("textRef");
|
|
15031
|
+
if (props.textValue !== void 0) ctx.registerItem(props.value, props.textValue);
|
|
14800
15032
|
(0, vue.onMounted)(() => {
|
|
14801
|
-
const
|
|
15033
|
+
const el = textRef.value?.$el;
|
|
15034
|
+
const label = props.textValue ?? el?.textContent?.trim() ?? props.value;
|
|
14802
15035
|
ctx.registerItem(props.value, label);
|
|
14803
15036
|
});
|
|
14804
15037
|
return (_ctx, _cache) => {
|
|
@@ -15414,17 +15647,52 @@ var ComboBox_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
15414
15647
|
if (props.filterFunction) return props.filterFunction;
|
|
15415
15648
|
return (itemText, searchTerm) => itemText.toLowerCase().includes(searchTerm.toLowerCase());
|
|
15416
15649
|
});
|
|
15417
|
-
const
|
|
15418
|
-
|
|
15419
|
-
const
|
|
15420
|
-
|
|
15650
|
+
const slotItemRegistry = (0, vue.ref)(/* @__PURE__ */ new Map());
|
|
15651
|
+
function registerItem(value, label) {
|
|
15652
|
+
const next = new Map(slotItemRegistry.value);
|
|
15653
|
+
next.set(value, label);
|
|
15654
|
+
slotItemRegistry.value = next;
|
|
15655
|
+
}
|
|
15656
|
+
function unregisterItem(value) {
|
|
15657
|
+
const next = new Map(slotItemRegistry.value);
|
|
15658
|
+
next.delete(value);
|
|
15659
|
+
slotItemRegistry.value = next;
|
|
15660
|
+
}
|
|
15661
|
+
function labelFor(value) {
|
|
15662
|
+
if (!value) return "";
|
|
15663
|
+
const item = props.items.find((i) => i.value === value);
|
|
15664
|
+
if (item) return item.label ?? item.textValue ?? value;
|
|
15665
|
+
return slotItemRegistry.value.get(value) ?? value;
|
|
15666
|
+
}
|
|
15667
|
+
function valueFor(label) {
|
|
15668
|
+
if (!label) return "";
|
|
15669
|
+
const item = props.items.find((i) => (i.label ?? i.textValue ?? i.value) === label);
|
|
15670
|
+
if (item) return item.value;
|
|
15671
|
+
for (const [value, lbl] of slotItemRegistry.value) if (lbl === label) return value;
|
|
15672
|
+
return label;
|
|
15673
|
+
}
|
|
15674
|
+
const internalValue = (0, vue.ref)(labelFor(props.modelValue));
|
|
15675
|
+
const displayValue = (0, vue.computed)(() => (val) => val);
|
|
15676
|
+
(0, vue.watch)(() => props.modelValue, (val) => {
|
|
15677
|
+
const next = labelFor(val);
|
|
15678
|
+
if (internalValue.value !== next) internalValue.value = next;
|
|
15679
|
+
});
|
|
15680
|
+
function handleModelValueUpdate(emitted) {
|
|
15681
|
+
internalValue.value = emitted;
|
|
15682
|
+
emit("update:modelValue", valueFor(emitted));
|
|
15683
|
+
}
|
|
15684
|
+
(0, vue.watch)(slotItemRegistry, () => {
|
|
15685
|
+
const next = labelFor(props.modelValue);
|
|
15686
|
+
if (next !== internalValue.value && valueFor(internalValue.value) === (props.modelValue ?? "")) internalValue.value = next;
|
|
15421
15687
|
});
|
|
15422
15688
|
useComboBoxProvide({
|
|
15423
15689
|
isDisabled: (0, vue.toRef)(props, "isDisabled"),
|
|
15424
15690
|
isInvalid: (0, vue.toRef)(props, "isInvalid"),
|
|
15425
15691
|
fullWidth: (0, vue.toRef)(props, "fullWidth"),
|
|
15426
15692
|
slots: slotFns,
|
|
15427
|
-
displayValue
|
|
15693
|
+
displayValue,
|
|
15694
|
+
registerItem,
|
|
15695
|
+
unregisterItem
|
|
15428
15696
|
});
|
|
15429
15697
|
return (_ctx, _cache) => {
|
|
15430
15698
|
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
|
|
@@ -15438,20 +15706,20 @@ var ComboBox_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
15438
15706
|
"data-slot": "label"
|
|
15439
15707
|
}, [(0, vue.createTextVNode)((0, vue.toDisplayString)(props.label) + " ", 1), props.isRequired ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_3$12, " *")) : (0, vue.createCommentVNode)("", true)], 8, _hoisted_2$19)) : (0, vue.createCommentVNode)("", true),
|
|
15440
15708
|
(0, vue.createVNode)((0, vue.unref)(reka_ui.ComboboxRoot), {
|
|
15441
|
-
|
|
15442
|
-
"
|
|
15709
|
+
modelValue: internalValue.value,
|
|
15710
|
+
"onUpdate:modelValue": [_cache[0] || (_cache[0] = ($event) => internalValue.value = $event), _cache[1] || (_cache[1] = ($event) => handleModelValueUpdate($event))],
|
|
15711
|
+
"default-value": props.defaultValue ? labelFor(props.defaultValue) : void 0,
|
|
15443
15712
|
open: props.open,
|
|
15444
15713
|
"default-open": props.defaultOpen,
|
|
15445
15714
|
disabled: props.isDisabled,
|
|
15446
15715
|
required: props.isRequired,
|
|
15447
15716
|
"filter-function": effectiveFilter.value,
|
|
15448
|
-
"onUpdate:
|
|
15449
|
-
"onUpdate:open": _cache[1] || (_cache[1] = ($event) => emit("update:open", $event))
|
|
15717
|
+
"onUpdate:open": _cache[2] || (_cache[2] = ($event) => emit("update:open", $event))
|
|
15450
15718
|
}, {
|
|
15451
15719
|
default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
|
|
15452
15720
|
_: 3
|
|
15453
15721
|
}, 8, [
|
|
15454
|
-
"
|
|
15722
|
+
"modelValue",
|
|
15455
15723
|
"default-value",
|
|
15456
15724
|
"open",
|
|
15457
15725
|
"default-open",
|
|
@@ -15560,6 +15828,40 @@ var ComboBoxContent_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
15560
15828
|
const props = __props;
|
|
15561
15829
|
const ctx = useComboBoxInject();
|
|
15562
15830
|
const comboboxRootContext = (0, reka_ui.injectComboboxRootContext)();
|
|
15831
|
+
const slots = (0, vue.useSlots)();
|
|
15832
|
+
function extractNodeText(nodes) {
|
|
15833
|
+
return nodes.map((n) => {
|
|
15834
|
+
if (typeof n.children === "string") return n.children;
|
|
15835
|
+
if (Array.isArray(n.children)) return extractNodeText(n.children);
|
|
15836
|
+
return "";
|
|
15837
|
+
}).join("");
|
|
15838
|
+
}
|
|
15839
|
+
function walkAndRegister(nodes) {
|
|
15840
|
+
for (const node of nodes) {
|
|
15841
|
+
if (node.props && typeof node.props.value === "string") {
|
|
15842
|
+
const value = node.props.value;
|
|
15843
|
+
const children = node.children;
|
|
15844
|
+
if (children && typeof children === "object" && "default" in children) {
|
|
15845
|
+
const slotFn = children.default;
|
|
15846
|
+
if (typeof slotFn === "function") {
|
|
15847
|
+
const text = extractNodeText(slotFn()).trim();
|
|
15848
|
+
if (text) ctx.registerItem(value, text);
|
|
15849
|
+
}
|
|
15850
|
+
} else if (typeof children === "string") {
|
|
15851
|
+
const text = children.trim();
|
|
15852
|
+
if (text) ctx.registerItem(value, text);
|
|
15853
|
+
} else if (Array.isArray(children)) {
|
|
15854
|
+
const text = extractNodeText(children).trim();
|
|
15855
|
+
if (text) ctx.registerItem(value, text);
|
|
15856
|
+
}
|
|
15857
|
+
}
|
|
15858
|
+
if (Array.isArray(node.children)) walkAndRegister(node.children);
|
|
15859
|
+
}
|
|
15860
|
+
}
|
|
15861
|
+
(0, vue.watchEffect)(() => {
|
|
15862
|
+
const vnodes = slots.default?.();
|
|
15863
|
+
if (vnodes) walkAndRegister(vnodes);
|
|
15864
|
+
});
|
|
15563
15865
|
return (_ctx, _cache) => {
|
|
15564
15866
|
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(reka_ui.ComboboxPortal), null, {
|
|
15565
15867
|
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(AnimatePresence_default), null, {
|
|
@@ -15607,7 +15909,6 @@ var ComboBoxItem_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
15607
15909
|
__name: "ComboBoxItem",
|
|
15608
15910
|
props: {
|
|
15609
15911
|
value: {},
|
|
15610
|
-
textValue: { default: void 0 },
|
|
15611
15912
|
isDisabled: {
|
|
15612
15913
|
type: Boolean,
|
|
15613
15914
|
default: false
|
|
@@ -15616,11 +15917,32 @@ var ComboBoxItem_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
15616
15917
|
},
|
|
15617
15918
|
setup(__props) {
|
|
15618
15919
|
const props = __props;
|
|
15920
|
+
const slots = (0, vue.useSlots)();
|
|
15921
|
+
const ctx = useComboBoxInject();
|
|
15922
|
+
function extractText(nodes) {
|
|
15923
|
+
return nodes.map((n) => {
|
|
15924
|
+
if (typeof n.children === "string") return n.children;
|
|
15925
|
+
if (Array.isArray(n.children)) return extractText(n.children);
|
|
15926
|
+
return "";
|
|
15927
|
+
}).join("");
|
|
15928
|
+
}
|
|
15929
|
+
const displayText = (0, vue.computed)(() => {
|
|
15930
|
+
const vnodes = slots.default?.();
|
|
15931
|
+
if (!vnodes) return props.value;
|
|
15932
|
+
return extractText(vnodes).trim() || props.value;
|
|
15933
|
+
});
|
|
15934
|
+
(0, vue.onMounted)(() => {
|
|
15935
|
+
ctx.registerItem(props.value, displayText.value);
|
|
15936
|
+
});
|
|
15937
|
+
(0, vue.onUnmounted)(() => {
|
|
15938
|
+
ctx.unregisterItem(props.value);
|
|
15939
|
+
});
|
|
15619
15940
|
return (_ctx, _cache) => {
|
|
15620
15941
|
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(reka_ui.ComboboxItem), {
|
|
15621
|
-
value:
|
|
15622
|
-
"text-value":
|
|
15942
|
+
value: displayText.value,
|
|
15943
|
+
"text-value": displayText.value,
|
|
15623
15944
|
disabled: props.isDisabled,
|
|
15945
|
+
"data-item-value": props.value,
|
|
15624
15946
|
class: "list-box-item list-box-item--default",
|
|
15625
15947
|
"data-slot": "list-box-item"
|
|
15626
15948
|
}, {
|
|
@@ -15652,7 +15974,8 @@ var ComboBoxItem_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
15652
15974
|
}, 8, [
|
|
15653
15975
|
"value",
|
|
15654
15976
|
"text-value",
|
|
15655
|
-
"disabled"
|
|
15977
|
+
"disabled",
|
|
15978
|
+
"data-item-value"
|
|
15656
15979
|
]);
|
|
15657
15980
|
};
|
|
15658
15981
|
}
|
|
@@ -15762,6 +16085,17 @@ var Autocomplete_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
15762
16085
|
const generatedId = (0, vue.useId)();
|
|
15763
16086
|
const inputId = (0, vue.computed)(() => attrs.id ?? generatedId);
|
|
15764
16087
|
const hasLabel = (0, vue.computed)(() => !!props.label);
|
|
16088
|
+
const slotItemRegistry = (0, vue.ref)(/* @__PURE__ */ new Map());
|
|
16089
|
+
function registerItem(value, label) {
|
|
16090
|
+
const next = new Map(slotItemRegistry.value);
|
|
16091
|
+
next.set(value, label);
|
|
16092
|
+
slotItemRegistry.value = next;
|
|
16093
|
+
}
|
|
16094
|
+
function unregisterItem(value) {
|
|
16095
|
+
const next = new Map(slotItemRegistry.value);
|
|
16096
|
+
next.delete(value);
|
|
16097
|
+
slotItemRegistry.value = next;
|
|
16098
|
+
}
|
|
15765
16099
|
const isLoading = (0, vue.ref)(false);
|
|
15766
16100
|
const internalItems = (0, vue.ref)([...props.items]);
|
|
15767
16101
|
const isOpen = (0, vue.ref)(props.defaultOpen ?? false);
|
|
@@ -15775,11 +16109,15 @@ var Autocomplete_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
15775
16109
|
function labelFor(value) {
|
|
15776
16110
|
if (value == null || value === "") return "";
|
|
15777
16111
|
const match = internalItems.value.find((i) => i.value === value);
|
|
15778
|
-
return match
|
|
16112
|
+
if (match) return match.label ?? match.textValue ?? value;
|
|
16113
|
+
return slotItemRegistry.value.get(value) ?? value;
|
|
15779
16114
|
}
|
|
15780
16115
|
function valueFor(displayed) {
|
|
15781
16116
|
if (!displayed) return "";
|
|
15782
|
-
|
|
16117
|
+
const match = internalItems.value.find((i) => (i.label ?? i.textValue ?? i.value) === displayed);
|
|
16118
|
+
if (match) return match.value;
|
|
16119
|
+
for (const [value, label] of slotItemRegistry.value) if (label === displayed) return value;
|
|
16120
|
+
return displayed;
|
|
15783
16121
|
}
|
|
15784
16122
|
const searchTerm = (0, vue.ref)(labelFor(props.modelValue));
|
|
15785
16123
|
const isFilled = (0, vue.computed)(() => !!searchTerm.value);
|
|
@@ -15839,6 +16177,10 @@ var Autocomplete_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
15839
16177
|
const next = labelFor(props.modelValue);
|
|
15840
16178
|
if (next && searchTerm.value !== next && valueFor(searchTerm.value) === (props.modelValue ?? "")) searchTerm.value = next;
|
|
15841
16179
|
});
|
|
16180
|
+
(0, vue.watch)(slotItemRegistry, () => {
|
|
16181
|
+
const next = labelFor(props.modelValue);
|
|
16182
|
+
if (next && searchTerm.value !== next && valueFor(searchTerm.value) === (props.modelValue ?? "")) searchTerm.value = next;
|
|
16183
|
+
});
|
|
15842
16184
|
const slotFns = (0, vue.computed)(() => (0, _auronui_styles.autocompleteVariants)({
|
|
15843
16185
|
variant: props.variant,
|
|
15844
16186
|
size: props.size,
|
|
@@ -15866,7 +16208,9 @@ var Autocomplete_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
15866
16208
|
ariaDescribedBy,
|
|
15867
16209
|
truncateItems: (0, vue.toRef)(props, "truncateItems"),
|
|
15868
16210
|
hasItems,
|
|
15869
|
-
slots: slotFns
|
|
16211
|
+
slots: slotFns,
|
|
16212
|
+
registerItem,
|
|
16213
|
+
unregisterItem
|
|
15870
16214
|
});
|
|
15871
16215
|
return (_ctx, _cache) => {
|
|
15872
16216
|
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
|
|
@@ -16072,6 +16416,44 @@ var AutocompleteContent_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
16072
16416
|
const props = __props;
|
|
16073
16417
|
const ctx = useAutocompleteInject();
|
|
16074
16418
|
const rootContext = (0, reka_ui.injectComboboxRootContext)();
|
|
16419
|
+
const slots = (0, vue.useSlots)();
|
|
16420
|
+
function extractNodeText(nodes) {
|
|
16421
|
+
return nodes.map((n) => {
|
|
16422
|
+
if (typeof n.children === "string") return n.children;
|
|
16423
|
+
if (Array.isArray(n.children)) return extractNodeText(n.children);
|
|
16424
|
+
return "";
|
|
16425
|
+
}).join("");
|
|
16426
|
+
}
|
|
16427
|
+
function walkAndRegister(nodes) {
|
|
16428
|
+
for (const node of nodes) {
|
|
16429
|
+
if (node.props && typeof node.props.value === "string") {
|
|
16430
|
+
const value = node.props.value;
|
|
16431
|
+
const label = node.props.label;
|
|
16432
|
+
if (label) ctx.registerItem(value, label);
|
|
16433
|
+
else {
|
|
16434
|
+
const children = node.children;
|
|
16435
|
+
if (children && typeof children === "object" && "default" in children) {
|
|
16436
|
+
const slotFn = children.default;
|
|
16437
|
+
if (typeof slotFn === "function") {
|
|
16438
|
+
const text = extractNodeText(slotFn()).trim();
|
|
16439
|
+
if (text) ctx.registerItem(value, text);
|
|
16440
|
+
}
|
|
16441
|
+
} else if (typeof children === "string") {
|
|
16442
|
+
const text = children.trim();
|
|
16443
|
+
if (text) ctx.registerItem(value, text);
|
|
16444
|
+
} else if (Array.isArray(children)) {
|
|
16445
|
+
const text = extractNodeText(children).trim();
|
|
16446
|
+
if (text) ctx.registerItem(value, text);
|
|
16447
|
+
}
|
|
16448
|
+
}
|
|
16449
|
+
}
|
|
16450
|
+
if (Array.isArray(node.children)) walkAndRegister(node.children);
|
|
16451
|
+
}
|
|
16452
|
+
}
|
|
16453
|
+
(0, vue.watchEffect)(() => {
|
|
16454
|
+
const vnodes = slots.default?.();
|
|
16455
|
+
if (vnodes) walkAndRegister(vnodes);
|
|
16456
|
+
});
|
|
16075
16457
|
return (_ctx, _cache) => {
|
|
16076
16458
|
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(reka_ui.AutocompletePortal), null, {
|
|
16077
16459
|
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(AnimatePresence_default), null, {
|
|
@@ -16145,7 +16527,6 @@ var AutocompleteItem_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
16145
16527
|
__name: "AutocompleteItem",
|
|
16146
16528
|
props: {
|
|
16147
16529
|
value: {},
|
|
16148
|
-
textValue: { default: void 0 },
|
|
16149
16530
|
isDisabled: {
|
|
16150
16531
|
type: Boolean,
|
|
16151
16532
|
default: false
|
|
@@ -16154,10 +16535,30 @@ var AutocompleteItem_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
16154
16535
|
},
|
|
16155
16536
|
setup(__props) {
|
|
16156
16537
|
const props = __props;
|
|
16538
|
+
const slots = (0, vue.useSlots)();
|
|
16539
|
+
const ctx = useAutocompleteInject();
|
|
16540
|
+
function extractText(nodes) {
|
|
16541
|
+
return nodes.map((n) => {
|
|
16542
|
+
if (typeof n.children === "string") return n.children;
|
|
16543
|
+
if (Array.isArray(n.children)) return extractText(n.children);
|
|
16544
|
+
return "";
|
|
16545
|
+
}).join("");
|
|
16546
|
+
}
|
|
16547
|
+
const displayText = (0, vue.computed)(() => {
|
|
16548
|
+
const vnodes = slots.default?.();
|
|
16549
|
+
if (!vnodes) return props.value;
|
|
16550
|
+
return extractText(vnodes).trim() || props.value;
|
|
16551
|
+
});
|
|
16552
|
+
(0, vue.onMounted)(() => {
|
|
16553
|
+
ctx.registerItem(props.value, displayText.value);
|
|
16554
|
+
});
|
|
16555
|
+
(0, vue.onUnmounted)(() => {
|
|
16556
|
+
ctx.unregisterItem(props.value);
|
|
16557
|
+
});
|
|
16157
16558
|
return (_ctx, _cache) => {
|
|
16158
16559
|
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(reka_ui.AutocompleteItem), {
|
|
16159
|
-
value:
|
|
16160
|
-
"text-value":
|
|
16560
|
+
value: displayText.value,
|
|
16561
|
+
"text-value": displayText.value,
|
|
16161
16562
|
disabled: props.isDisabled,
|
|
16162
16563
|
"data-item-value": props.value,
|
|
16163
16564
|
class: "list-box-item list-box-item--default",
|
|
@@ -25343,7 +25744,6 @@ var DateTimePicker_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
25343
25744
|
}, {
|
|
25344
25745
|
default: (0, vue.withCtx)(() => [(0, vue.createVNode)(DateInput_default, {
|
|
25345
25746
|
"model-value": internalValue.value,
|
|
25346
|
-
"onUpdate:modelValue": onInputChange,
|
|
25347
25747
|
variant: __props.variant,
|
|
25348
25748
|
size: __props.size,
|
|
25349
25749
|
color: __props.color,
|
|
@@ -25361,7 +25761,8 @@ var DateTimePicker_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
25361
25761
|
"is-read-only": __props.isReadOnly,
|
|
25362
25762
|
"is-required": __props.isRequired,
|
|
25363
25763
|
name: __props.name,
|
|
25364
|
-
"hide-time-zone": __props.hideTimeZone
|
|
25764
|
+
"hide-time-zone": __props.hideTimeZone,
|
|
25765
|
+
"onUpdate:modelValue": onInputChange
|
|
25365
25766
|
}, {
|
|
25366
25767
|
endContent: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(reka_ui.DatePickerTrigger), {
|
|
25367
25768
|
class: (0, vue.normalizeClass)(slotFns.value.trigger()),
|
|
@@ -26261,6 +26662,8 @@ exports.DropdownTrigger = DropdownTrigger_default;
|
|
|
26261
26662
|
exports.EmptyState = EmptyState_default;
|
|
26262
26663
|
exports.EmptyStateContent = EmptyStateContent_default;
|
|
26263
26664
|
exports.Fieldset = Fieldset_default;
|
|
26665
|
+
exports.Form = Form_default;
|
|
26666
|
+
exports.FormField = FormField_default;
|
|
26264
26667
|
exports.Header = Header_default;
|
|
26265
26668
|
exports.Input = Input_default;
|
|
26266
26669
|
exports.InputOTP = InputOTP_default;
|