@bagelink/vue 0.0.1058 → 0.0.1062
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/form/BglField.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/NumberInput.vue.d.ts.map +1 -1
- package/dist/index.cjs +20 -23
- package/dist/index.mjs +20 -23
- package/dist/style.css +5 -5
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/form/BglField.vue +12 -18
- package/src/components/form/inputs/NumberInput.vue +2 -2
- package/src/utils/index.ts +8 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BglField.vue.d.ts","sourceRoot":"","sources":["../../../src/components/form/BglField.vue"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"BglField.vue.d.ts","sourceRoot":"","sources":["../../../src/components/form/BglField.vue"],"names":[],"mappings":"AAAA,OAqIO,EAIN,KAAK,KAAK,EAYV,MAAM,eAAe,CAAA;yBAML,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,eAChC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WAuKxD,mBAAmB,CAAC;;;eAnKtB,KAAK,CAAC,CAAC,CAAC;kBACL,MAAM;qBACH,GAAG;qBACH,MAAM;KAgKmG,CAAC,4BAA2B;oBAChI,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;;OAKD,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AAjLzE,wBAiL4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/NumberInput.vue"],"names":[],"mappings":"AA2KA,OAAO,EAAQ,KAAK,aAAa,EAAO,MAAM,eAAe,CAAA;AAK7D,KAAK,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CAAA;AAEzD,UAAU,gBAAgB;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;CAChB;;;;;;
|
|
1
|
+
{"version":3,"file":"NumberInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/NumberInput.vue"],"names":[],"mappings":"AA2KA,OAAO,EAAQ,KAAK,aAAa,EAAO,MAAM,eAAe,CAAA;AAK7D,KAAK,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CAAA;AAEzD,UAAU,gBAAgB;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;CAChB;;;;;;AA0RD,wBAQG"}
|
package/dist/index.cjs
CHANGED
|
@@ -9976,7 +9976,7 @@ const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
|
|
|
9976
9976
|
setup(__props, { emit: __emit }) {
|
|
9977
9977
|
const props2 = __props;
|
|
9978
9978
|
const emit2 = __emit;
|
|
9979
|
-
const formState = vue.inject(FORM_STATE_KEY);
|
|
9979
|
+
const formState = vue.inject(FORM_STATE_KEY) ?? provideBagelFormState(props2.modelValue);
|
|
9980
9980
|
const customAttrs = vue.ref({});
|
|
9981
9981
|
const is4 = vue.computed(() => {
|
|
9982
9982
|
if (props2.field.$el === "text") return TextInput;
|
|
@@ -10000,54 +10000,49 @@ const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
|
|
|
10000
10000
|
const fieldData = vue.computed({
|
|
10001
10001
|
get: () => {
|
|
10002
10002
|
if (!props2.fieldID) return props2.field.defaultValue ?? (props2.field.$el === "form" ? {} : "");
|
|
10003
|
-
const value = formState
|
|
10003
|
+
const value = formState.getFieldData(props2.fieldID);
|
|
10004
10004
|
if (props2.field.$el === "form" && !value) return {};
|
|
10005
10005
|
return value ?? "";
|
|
10006
10006
|
},
|
|
10007
10007
|
set: (val) => {
|
|
10008
10008
|
if (!props2.fieldID) return;
|
|
10009
|
-
const currentValue = formState
|
|
10009
|
+
const currentValue = formState.getFieldData(props2.fieldID);
|
|
10010
10010
|
if (JSON.stringify(val) === JSON.stringify(currentValue)) return;
|
|
10011
10011
|
emit2("update:modelValue", val);
|
|
10012
10012
|
if (props2.field.onUpdate) {
|
|
10013
10013
|
props2.field.onUpdate(val, currentValue);
|
|
10014
10014
|
}
|
|
10015
|
-
formState
|
|
10015
|
+
formState.updateField(props2.fieldID, val);
|
|
10016
10016
|
}
|
|
10017
10017
|
});
|
|
10018
10018
|
const vIf = vue.computed(() => {
|
|
10019
10019
|
if (props2.field["v-if"] === void 0 && props2.field.vIf === void 0) return true;
|
|
10020
10020
|
if (typeof props2.field["v-if"] === "boolean" || typeof props2.field.vIf === "boolean") return props2.field["v-if"];
|
|
10021
10021
|
if (typeof props2.field["v-if"] === "string" || typeof props2.field.vIf === "string") return true;
|
|
10022
|
-
if (typeof props2.field["v-if"] === "function") return props2.field["v-if"](fieldData.value, formState
|
|
10023
|
-
if (typeof props2.field.vIf === "function") return props2.field.vIf(fieldData.value, formState
|
|
10022
|
+
if (typeof props2.field["v-if"] === "function") return props2.field["v-if"](fieldData.value, formState.data.value);
|
|
10023
|
+
if (typeof props2.field.vIf === "function") return props2.field.vIf(fieldData.value, formState.data.value);
|
|
10024
10024
|
return true;
|
|
10025
10025
|
});
|
|
10026
|
-
|
|
10026
|
+
vue.computed(
|
|
10027
10027
|
() => {
|
|
10028
10028
|
var _a2, _b;
|
|
10029
|
-
return ((_b = (_a2 = props2.field).transform) == null ? void 0 : _b.call(_a2, fieldData.value, formState
|
|
10029
|
+
return ((_b = (_a2 = props2.field).transform) == null ? void 0 : _b.call(_a2, fieldData.value, formState.data.value)) ?? fieldData.value;
|
|
10030
10030
|
}
|
|
10031
10031
|
);
|
|
10032
10032
|
const computedOptions = vue.computed(
|
|
10033
|
-
() => bindAttrs({ options: props2.field.options }, fieldData.value, formState
|
|
10033
|
+
() => bindAttrs({ options: props2.field.options }, fieldData.value, formState.data.value).options
|
|
10034
10034
|
);
|
|
10035
10035
|
const computedAttrs = vue.computed(() => {
|
|
10036
10036
|
const attrs = { ...customAttrs.value, ...props2.field.attrs };
|
|
10037
|
-
|
|
10038
|
-
const boundAttrs = bindAttrs(attrs, fieldData.value, formState == null ? void 0 : formState.data.value);
|
|
10039
|
-
return Object.fromEntries(
|
|
10040
|
-
Object.entries(boundAttrs).filter(([_2, value]) => value !== void 0)
|
|
10041
|
-
);
|
|
10037
|
+
return bindAttrs(attrs, fieldData.value, formState.data.value);
|
|
10042
10038
|
});
|
|
10043
10039
|
const computedClass = vue.computed(
|
|
10044
10040
|
() => {
|
|
10045
10041
|
var _a2;
|
|
10046
|
-
return classify(fieldData.value, formState
|
|
10042
|
+
return classify(fieldData.value, formState.data.value, props2.field.class, (_a2 = props2.field.attrs) == null ? void 0 : _a2.class);
|
|
10047
10043
|
}
|
|
10048
10044
|
);
|
|
10049
10045
|
return (_ctx, _cache) => {
|
|
10050
|
-
var _a2;
|
|
10051
10046
|
const _component_BglField = vue.resolveComponent("BglField", true);
|
|
10052
10047
|
return vIf.value ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(is4.value), vue.mergeProps({ key: 0 }, computedAttrs.value, {
|
|
10053
10048
|
modelValue: fieldData.value,
|
|
@@ -10060,11 +10055,9 @@ const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
|
|
|
10060
10055
|
defaultValue: _ctx.field.defaultValue,
|
|
10061
10056
|
disabled: _ctx.field.disabled,
|
|
10062
10057
|
options: computedOptions.value,
|
|
10063
|
-
helptext: _ctx.field.helptext
|
|
10064
|
-
schema: ((_a2 = _ctx.field.attrs) == null ? void 0 : _a2.schema) ?? void 0
|
|
10058
|
+
helptext: _ctx.field.helptext
|
|
10065
10059
|
}), {
|
|
10066
10060
|
default: vue.withCtx(() => [
|
|
10067
|
-
vue.createTextVNode(vue.toDisplayString(computedFieldData.value) + " ", 1),
|
|
10068
10061
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.field.children, (child, ii) => {
|
|
10069
10062
|
return vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: ii }, [
|
|
10070
10063
|
typeof child !== "string" ? (vue.openBlock(), vue.createBlock(_component_BglField, {
|
|
@@ -10077,7 +10070,7 @@ const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
|
|
|
10077
10070
|
}), 128))
|
|
10078
10071
|
]),
|
|
10079
10072
|
_: 1
|
|
10080
|
-
}, 16, ["modelValue", "fieldID", "required", "class", "label", "placeholder", "defaultValue", "disabled", "options", "helptext"
|
|
10073
|
+
}, 16, ["modelValue", "fieldID", "required", "class", "label", "placeholder", "defaultValue", "disabled", "options", "helptext"])) : vue.createCommentVNode("", true);
|
|
10081
10074
|
};
|
|
10082
10075
|
}
|
|
10083
10076
|
});
|
|
@@ -20117,14 +20110,14 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
|
|
|
20117
20110
|
icon: "add",
|
|
20118
20111
|
flat: "",
|
|
20119
20112
|
thin: "",
|
|
20120
|
-
class: "bgl-ctrl-num-btn",
|
|
20113
|
+
class: "bgl-ctrl-num-btn ctrl-add color-gray",
|
|
20121
20114
|
onClick: increment
|
|
20122
20115
|
}),
|
|
20123
20116
|
vue.createVNode(vue.unref(Btn), {
|
|
20124
20117
|
icon: "remove",
|
|
20125
20118
|
flat: "",
|
|
20126
20119
|
thin: "",
|
|
20127
|
-
class: "bgl-ctrl-num-btn",
|
|
20120
|
+
class: "bgl-ctrl-num-btn ctrl-remove color-gray",
|
|
20128
20121
|
onClick: decrement
|
|
20129
20122
|
})
|
|
20130
20123
|
])) : vue.createCommentVNode("", true)
|
|
@@ -20134,7 +20127,7 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
|
|
|
20134
20127
|
};
|
|
20135
20128
|
}
|
|
20136
20129
|
});
|
|
20137
|
-
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-
|
|
20130
|
+
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-abb5baff"]]);
|
|
20138
20131
|
const _hoisted_1$v = ["value", "autofocus", "onKeydown", "onPaste"];
|
|
20139
20132
|
const _sfc_main$E = /* @__PURE__ */ vue.defineComponent({
|
|
20140
20133
|
__name: "OTP",
|
|
@@ -34498,6 +34491,9 @@ function debounce(fn2, wait = 500) {
|
|
|
34498
34491
|
}, wait);
|
|
34499
34492
|
debouncers.set(fn2, timeout);
|
|
34500
34493
|
}
|
|
34494
|
+
function slugify(str) {
|
|
34495
|
+
return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").split(/[\s-]+/).join("-");
|
|
34496
|
+
}
|
|
34501
34497
|
function keyToLabel(key) {
|
|
34502
34498
|
if (key === void 0) return key;
|
|
34503
34499
|
return key.split("_").map((k2) => k2.charAt(0).toUpperCase() + k2.slice(1)).join(" ") || key;
|
|
@@ -35230,6 +35226,7 @@ exports.normalizeDimension = normalizeDimension;
|
|
|
35230
35226
|
exports.normalizeURL = normalizeURL;
|
|
35231
35227
|
exports.provideBagelFormState = provideBagelFormState;
|
|
35232
35228
|
exports.sleep = sleep;
|
|
35229
|
+
exports.slugify = slugify;
|
|
35233
35230
|
exports.timeAgo = timeAgo;
|
|
35234
35231
|
exports.useBagel = useBagel;
|
|
35235
35232
|
exports.useBagelFormState = useBagelFormState;
|
package/dist/index.mjs
CHANGED
|
@@ -9974,7 +9974,7 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
|
|
|
9974
9974
|
setup(__props, { emit: __emit }) {
|
|
9975
9975
|
const props2 = __props;
|
|
9976
9976
|
const emit2 = __emit;
|
|
9977
|
-
const formState = inject(FORM_STATE_KEY);
|
|
9977
|
+
const formState = inject(FORM_STATE_KEY) ?? provideBagelFormState(props2.modelValue);
|
|
9978
9978
|
const customAttrs = ref({});
|
|
9979
9979
|
const is4 = computed(() => {
|
|
9980
9980
|
if (props2.field.$el === "text") return TextInput;
|
|
@@ -9998,54 +9998,49 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
|
|
|
9998
9998
|
const fieldData = computed({
|
|
9999
9999
|
get: () => {
|
|
10000
10000
|
if (!props2.fieldID) return props2.field.defaultValue ?? (props2.field.$el === "form" ? {} : "");
|
|
10001
|
-
const value = formState
|
|
10001
|
+
const value = formState.getFieldData(props2.fieldID);
|
|
10002
10002
|
if (props2.field.$el === "form" && !value) return {};
|
|
10003
10003
|
return value ?? "";
|
|
10004
10004
|
},
|
|
10005
10005
|
set: (val) => {
|
|
10006
10006
|
if (!props2.fieldID) return;
|
|
10007
|
-
const currentValue = formState
|
|
10007
|
+
const currentValue = formState.getFieldData(props2.fieldID);
|
|
10008
10008
|
if (JSON.stringify(val) === JSON.stringify(currentValue)) return;
|
|
10009
10009
|
emit2("update:modelValue", val);
|
|
10010
10010
|
if (props2.field.onUpdate) {
|
|
10011
10011
|
props2.field.onUpdate(val, currentValue);
|
|
10012
10012
|
}
|
|
10013
|
-
formState
|
|
10013
|
+
formState.updateField(props2.fieldID, val);
|
|
10014
10014
|
}
|
|
10015
10015
|
});
|
|
10016
10016
|
const vIf = computed(() => {
|
|
10017
10017
|
if (props2.field["v-if"] === void 0 && props2.field.vIf === void 0) return true;
|
|
10018
10018
|
if (typeof props2.field["v-if"] === "boolean" || typeof props2.field.vIf === "boolean") return props2.field["v-if"];
|
|
10019
10019
|
if (typeof props2.field["v-if"] === "string" || typeof props2.field.vIf === "string") return true;
|
|
10020
|
-
if (typeof props2.field["v-if"] === "function") return props2.field["v-if"](fieldData.value, formState
|
|
10021
|
-
if (typeof props2.field.vIf === "function") return props2.field.vIf(fieldData.value, formState
|
|
10020
|
+
if (typeof props2.field["v-if"] === "function") return props2.field["v-if"](fieldData.value, formState.data.value);
|
|
10021
|
+
if (typeof props2.field.vIf === "function") return props2.field.vIf(fieldData.value, formState.data.value);
|
|
10022
10022
|
return true;
|
|
10023
10023
|
});
|
|
10024
|
-
|
|
10024
|
+
computed(
|
|
10025
10025
|
() => {
|
|
10026
10026
|
var _a2, _b;
|
|
10027
|
-
return ((_b = (_a2 = props2.field).transform) == null ? void 0 : _b.call(_a2, fieldData.value, formState
|
|
10027
|
+
return ((_b = (_a2 = props2.field).transform) == null ? void 0 : _b.call(_a2, fieldData.value, formState.data.value)) ?? fieldData.value;
|
|
10028
10028
|
}
|
|
10029
10029
|
);
|
|
10030
10030
|
const computedOptions = computed(
|
|
10031
|
-
() => bindAttrs({ options: props2.field.options }, fieldData.value, formState
|
|
10031
|
+
() => bindAttrs({ options: props2.field.options }, fieldData.value, formState.data.value).options
|
|
10032
10032
|
);
|
|
10033
10033
|
const computedAttrs = computed(() => {
|
|
10034
10034
|
const attrs = { ...customAttrs.value, ...props2.field.attrs };
|
|
10035
|
-
|
|
10036
|
-
const boundAttrs = bindAttrs(attrs, fieldData.value, formState == null ? void 0 : formState.data.value);
|
|
10037
|
-
return Object.fromEntries(
|
|
10038
|
-
Object.entries(boundAttrs).filter(([_2, value]) => value !== void 0)
|
|
10039
|
-
);
|
|
10035
|
+
return bindAttrs(attrs, fieldData.value, formState.data.value);
|
|
10040
10036
|
});
|
|
10041
10037
|
const computedClass = computed(
|
|
10042
10038
|
() => {
|
|
10043
10039
|
var _a2;
|
|
10044
|
-
return classify(fieldData.value, formState
|
|
10040
|
+
return classify(fieldData.value, formState.data.value, props2.field.class, (_a2 = props2.field.attrs) == null ? void 0 : _a2.class);
|
|
10045
10041
|
}
|
|
10046
10042
|
);
|
|
10047
10043
|
return (_ctx, _cache) => {
|
|
10048
|
-
var _a2;
|
|
10049
10044
|
const _component_BglField = resolveComponent("BglField", true);
|
|
10050
10045
|
return vIf.value ? (openBlock(), createBlock(resolveDynamicComponent(is4.value), mergeProps({ key: 0 }, computedAttrs.value, {
|
|
10051
10046
|
modelValue: fieldData.value,
|
|
@@ -10058,11 +10053,9 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
|
|
|
10058
10053
|
defaultValue: _ctx.field.defaultValue,
|
|
10059
10054
|
disabled: _ctx.field.disabled,
|
|
10060
10055
|
options: computedOptions.value,
|
|
10061
|
-
helptext: _ctx.field.helptext
|
|
10062
|
-
schema: ((_a2 = _ctx.field.attrs) == null ? void 0 : _a2.schema) ?? void 0
|
|
10056
|
+
helptext: _ctx.field.helptext
|
|
10063
10057
|
}), {
|
|
10064
10058
|
default: withCtx(() => [
|
|
10065
|
-
createTextVNode(toDisplayString(computedFieldData.value) + " ", 1),
|
|
10066
10059
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.field.children, (child, ii) => {
|
|
10067
10060
|
return openBlock(), createElementBlock(Fragment, { key: ii }, [
|
|
10068
10061
|
typeof child !== "string" ? (openBlock(), createBlock(_component_BglField, {
|
|
@@ -10075,7 +10068,7 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
|
|
|
10075
10068
|
}), 128))
|
|
10076
10069
|
]),
|
|
10077
10070
|
_: 1
|
|
10078
|
-
}, 16, ["modelValue", "fieldID", "required", "class", "label", "placeholder", "defaultValue", "disabled", "options", "helptext"
|
|
10071
|
+
}, 16, ["modelValue", "fieldID", "required", "class", "label", "placeholder", "defaultValue", "disabled", "options", "helptext"])) : createCommentVNode("", true);
|
|
10079
10072
|
};
|
|
10080
10073
|
}
|
|
10081
10074
|
});
|
|
@@ -20115,14 +20108,14 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
20115
20108
|
icon: "add",
|
|
20116
20109
|
flat: "",
|
|
20117
20110
|
thin: "",
|
|
20118
|
-
class: "bgl-ctrl-num-btn",
|
|
20111
|
+
class: "bgl-ctrl-num-btn ctrl-add color-gray",
|
|
20119
20112
|
onClick: increment
|
|
20120
20113
|
}),
|
|
20121
20114
|
createVNode(unref(Btn), {
|
|
20122
20115
|
icon: "remove",
|
|
20123
20116
|
flat: "",
|
|
20124
20117
|
thin: "",
|
|
20125
|
-
class: "bgl-ctrl-num-btn",
|
|
20118
|
+
class: "bgl-ctrl-num-btn ctrl-remove color-gray",
|
|
20126
20119
|
onClick: decrement
|
|
20127
20120
|
})
|
|
20128
20121
|
])) : createCommentVNode("", true)
|
|
@@ -20132,7 +20125,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
20132
20125
|
};
|
|
20133
20126
|
}
|
|
20134
20127
|
});
|
|
20135
|
-
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-
|
|
20128
|
+
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-abb5baff"]]);
|
|
20136
20129
|
const _hoisted_1$v = ["value", "autofocus", "onKeydown", "onPaste"];
|
|
20137
20130
|
const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
20138
20131
|
__name: "OTP",
|
|
@@ -34496,6 +34489,9 @@ function debounce(fn2, wait = 500) {
|
|
|
34496
34489
|
}, wait);
|
|
34497
34490
|
debouncers.set(fn2, timeout);
|
|
34498
34491
|
}
|
|
34492
|
+
function slugify(str) {
|
|
34493
|
+
return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").split(/[\s-]+/).join("-");
|
|
34494
|
+
}
|
|
34499
34495
|
function keyToLabel(key) {
|
|
34500
34496
|
if (key === void 0) return key;
|
|
34501
34497
|
return key.split("_").map((k2) => k2.charAt(0).toUpperCase() + k2.slice(1)).join(" ") || key;
|
|
@@ -35229,6 +35225,7 @@ export {
|
|
|
35229
35225
|
normalizeURL,
|
|
35230
35226
|
provideBagelFormState,
|
|
35231
35227
|
sleep,
|
|
35228
|
+
slugify,
|
|
35232
35229
|
timeAgo,
|
|
35233
35230
|
useBagel,
|
|
35234
35231
|
useBagelFormState,
|
package/dist/style.css
CHANGED
|
@@ -1074,27 +1074,27 @@ pre code.hljs{
|
|
|
1074
1074
|
direction: ltr;
|
|
1075
1075
|
}
|
|
1076
1076
|
|
|
1077
|
-
.txtInputIconStart .iconStart[data-v-
|
|
1077
|
+
.txtInputIconStart .iconStart[data-v-abb5baff] {
|
|
1078
1078
|
color: var(--input-color);
|
|
1079
1079
|
position: absolute;
|
|
1080
1080
|
inset-inline-start:calc(var(--input-height) / 3 - 0.25rem);
|
|
1081
1081
|
margin-top: calc(var(--input-height) / 2 );
|
|
1082
1082
|
line-height: 0;
|
|
1083
1083
|
}
|
|
1084
|
-
.textInputSpinnerWrap .spinner[data-v-
|
|
1084
|
+
.textInputSpinnerWrap .spinner[data-v-abb5baff] {
|
|
1085
1085
|
color: var(--input-color);
|
|
1086
1086
|
position: absolute;
|
|
1087
1087
|
inset-inline-end: 0;
|
|
1088
1088
|
margin-top: calc(var(--input-height) / -1);
|
|
1089
1089
|
line-height: 0;
|
|
1090
1090
|
}
|
|
1091
|
-
.bgl-ctrl-num-btn[data-v-
|
|
1091
|
+
.bgl-ctrl-num-btn[data-v-abb5baff]{
|
|
1092
1092
|
height: calc(var(--input-height) / 2) !important;
|
|
1093
1093
|
}
|
|
1094
|
-
.bgl-big-ctrl-num-btn[data-v-
|
|
1094
|
+
.bgl-big-ctrl-num-btn[data-v-abb5baff]{
|
|
1095
1095
|
width: 100% !important;
|
|
1096
1096
|
}
|
|
1097
|
-
.bgl-number-input[data-v-
|
|
1097
|
+
.bgl-number-input[data-v-abb5baff]{
|
|
1098
1098
|
padding-inline-end: 1.75rem !important;
|
|
1099
1099
|
}
|
|
1100
1100
|
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Attributes, BglFormSchemaT } from '..';
|
|
2
2
|
export declare function debounce(fn: () => void, wait?: number): void;
|
|
3
|
+
export declare function slugify(str: string): string;
|
|
3
4
|
export declare function keyToLabel(key?: string): string | undefined;
|
|
4
5
|
export declare function copyText(text: string, cb?: (msg: string) => void): Promise<void>;
|
|
5
6
|
export declare function initials(...strArr: string[]): string;
|
|
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GAAG,MAAM,GAAG,SAAS,CAG/G;AAED,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAA;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -16,9 +16,9 @@ import {
|
|
|
16
16
|
type BagelFormState,
|
|
17
17
|
BglForm
|
|
18
18
|
} from '@bagelink/vue'
|
|
19
|
-
import { inject } from 'vue'
|
|
19
|
+
import { inject, ref } from 'vue'
|
|
20
20
|
import TabsNav from '../layout/TabsNav.vue'
|
|
21
|
-
import { FORM_STATE_KEY } from './useBagelFormState'
|
|
21
|
+
import { FORM_STATE_KEY, provideBagelFormState } from './useBagelFormState'
|
|
22
22
|
|
|
23
23
|
const props = defineProps<{
|
|
24
24
|
field: Field<T>
|
|
@@ -31,7 +31,7 @@ const emit = defineEmits<{
|
|
|
31
31
|
'update:modelValue': [value: any]
|
|
32
32
|
}>()
|
|
33
33
|
|
|
34
|
-
const formState = inject<BagelFormState<T>>(FORM_STATE_KEY)
|
|
34
|
+
const formState = inject<BagelFormState<T>>(FORM_STATE_KEY) ?? provideBagelFormState(props.modelValue)
|
|
35
35
|
|
|
36
36
|
const customAttrs = $ref<{ [key: string]: any }>({})
|
|
37
37
|
|
|
@@ -58,20 +58,20 @@ const is = $computed(() => {
|
|
|
58
58
|
const fieldData = $computed({
|
|
59
59
|
get: () => {
|
|
60
60
|
if (!props.fieldID) return props.field.defaultValue ?? (props.field.$el === 'form' ? {} : '')
|
|
61
|
-
const value = formState
|
|
61
|
+
const value = formState.getFieldData(props.fieldID)
|
|
62
62
|
if (props.field.$el === 'form' && !value) return {}
|
|
63
63
|
return value ?? ''
|
|
64
64
|
},
|
|
65
65
|
set: (val: any) => {
|
|
66
66
|
if (!props.fieldID) return
|
|
67
|
-
const currentValue = formState
|
|
67
|
+
const currentValue = formState.getFieldData(props.fieldID)
|
|
68
68
|
if (JSON.stringify(val) === JSON.stringify(currentValue)) return
|
|
69
69
|
|
|
70
70
|
emit('update:modelValue', val)
|
|
71
71
|
if (props.field.onUpdate) {
|
|
72
72
|
props.field.onUpdate(val, currentValue)
|
|
73
73
|
}
|
|
74
|
-
formState
|
|
74
|
+
formState.updateField(props.fieldID, val)
|
|
75
75
|
}
|
|
76
76
|
})
|
|
77
77
|
|
|
@@ -79,30 +79,26 @@ const vIf = $computed(() => {
|
|
|
79
79
|
if (props.field['v-if'] === undefined && props.field.vIf === undefined) return true
|
|
80
80
|
if (typeof props.field['v-if'] === 'boolean' || typeof props.field.vIf === 'boolean') return props.field['v-if']
|
|
81
81
|
if (typeof props.field['v-if'] === 'string' || typeof props.field.vIf === 'string') return true
|
|
82
|
-
if (typeof props.field['v-if'] === 'function') return props.field['v-if'](fieldData, formState
|
|
83
|
-
if (typeof props.field.vIf === 'function') return props.field.vIf(fieldData, formState
|
|
82
|
+
if (typeof props.field['v-if'] === 'function') return props.field['v-if'](fieldData, formState.data.value as T)
|
|
83
|
+
if (typeof props.field.vIf === 'function') return props.field.vIf(fieldData, formState.data.value as T)
|
|
84
84
|
return true
|
|
85
85
|
})
|
|
86
86
|
|
|
87
87
|
const computedFieldData = $computed(
|
|
88
|
-
() => props.field.transform?.(fieldData, formState
|
|
88
|
+
() => props.field.transform?.(fieldData, formState.data.value as T) ?? fieldData
|
|
89
89
|
)
|
|
90
90
|
|
|
91
91
|
const computedOptions = $computed(
|
|
92
|
-
() => bindAttrs({ options: props.field.options }, fieldData, formState
|
|
92
|
+
() => bindAttrs({ options: props.field.options }, fieldData, formState.data.value).options
|
|
93
93
|
)
|
|
94
94
|
|
|
95
95
|
const computedAttrs = $computed(() => {
|
|
96
96
|
const attrs = { ...customAttrs, ...props.field.attrs }
|
|
97
|
-
|
|
98
|
-
const boundAttrs = bindAttrs(attrs, fieldData, formState?.data.value)
|
|
99
|
-
return Object.fromEntries(
|
|
100
|
-
Object.entries(boundAttrs).filter(([_, value]) => value !== undefined)
|
|
101
|
-
)
|
|
97
|
+
return bindAttrs(attrs, fieldData, formState.data.value)
|
|
102
98
|
})
|
|
103
99
|
|
|
104
100
|
const computedClass = $computed(
|
|
105
|
-
() => classify(fieldData, formState
|
|
101
|
+
() => classify(fieldData, formState.data.value, props.field.class, props.field.attrs?.class)
|
|
106
102
|
)
|
|
107
103
|
</script>
|
|
108
104
|
|
|
@@ -121,9 +117,7 @@ const computedClass = $computed(
|
|
|
121
117
|
:disabled="field.disabled"
|
|
122
118
|
:options="computedOptions"
|
|
123
119
|
:helptext="field.helptext"
|
|
124
|
-
:schema="field.attrs?.schema ?? undefined"
|
|
125
120
|
>
|
|
126
|
-
{{ computedFieldData }}
|
|
127
121
|
<template v-for="(child, ii) in field.children" :key="ii">
|
|
128
122
|
<BglField
|
|
129
123
|
v-if="(typeof child !== 'string')"
|
|
@@ -133,8 +133,8 @@ watch(() => modelValue, (newVal) => {
|
|
|
133
133
|
<Btn v-if="layout && btnLayouts.includes(layout)" flat icon="remove" class="radius" :class="[{ 'bgl-big-ctrl-num-btn': layout === 'vertical' }]" @click="decrement" />
|
|
134
134
|
|
|
135
135
|
<div v-if="spinner && (!layout || !btnLayouts.includes(layout))" class="flex column spinner">
|
|
136
|
-
<Btn icon="add" flat thin class="bgl-ctrl-num-btn" @click="increment" />
|
|
137
|
-
<Btn icon="remove" flat thin class="bgl-ctrl-num-btn" @click="decrement" />
|
|
136
|
+
<Btn icon="add" flat thin class="bgl-ctrl-num-btn ctrl-add color-gray" @click="increment" />
|
|
137
|
+
<Btn icon="remove" flat thin class="bgl-ctrl-num-btn ctrl-remove color-gray" @click="decrement" />
|
|
138
138
|
</div>
|
|
139
139
|
</div>
|
|
140
140
|
</label>
|
package/src/utils/index.ts
CHANGED
|
@@ -11,6 +11,14 @@ export function debounce(fn: () => void, wait: number = 500) {
|
|
|
11
11
|
debouncers.set(fn, timeout)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export function slugify(str: string) {
|
|
15
|
+
return str
|
|
16
|
+
.toLowerCase()
|
|
17
|
+
.replace(/[^a-z0-9-\s]/g, '')
|
|
18
|
+
.split(/[\s-]+/)
|
|
19
|
+
.join('-')
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
export function keyToLabel(key?: string): string | undefined {
|
|
15
23
|
if (key === undefined) return key
|
|
16
24
|
return (
|