@bagelink/vue 0.0.1060 → 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 +15 -21
- package/dist/index.mjs +15 -21
- package/dist/style.css +5 -5
- package/package.json +1 -1
- package/src/components/form/BglField.vue +12 -17
- package/src/components/form/inputs/NumberInput.vue +2 -2
|
@@ -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,8 +10055,7 @@ 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
10061
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.field.children, (child, ii) => {
|
|
@@ -10076,7 +10070,7 @@ const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
|
|
|
10076
10070
|
}), 128))
|
|
10077
10071
|
]),
|
|
10078
10072
|
_: 1
|
|
10079
|
-
}, 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);
|
|
10080
10074
|
};
|
|
10081
10075
|
}
|
|
10082
10076
|
});
|
|
@@ -20116,14 +20110,14 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
|
|
|
20116
20110
|
icon: "add",
|
|
20117
20111
|
flat: "",
|
|
20118
20112
|
thin: "",
|
|
20119
|
-
class: "bgl-ctrl-num-btn",
|
|
20113
|
+
class: "bgl-ctrl-num-btn ctrl-add color-gray",
|
|
20120
20114
|
onClick: increment
|
|
20121
20115
|
}),
|
|
20122
20116
|
vue.createVNode(vue.unref(Btn), {
|
|
20123
20117
|
icon: "remove",
|
|
20124
20118
|
flat: "",
|
|
20125
20119
|
thin: "",
|
|
20126
|
-
class: "bgl-ctrl-num-btn",
|
|
20120
|
+
class: "bgl-ctrl-num-btn ctrl-remove color-gray",
|
|
20127
20121
|
onClick: decrement
|
|
20128
20122
|
})
|
|
20129
20123
|
])) : vue.createCommentVNode("", true)
|
|
@@ -20133,7 +20127,7 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
|
|
|
20133
20127
|
};
|
|
20134
20128
|
}
|
|
20135
20129
|
});
|
|
20136
|
-
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-
|
|
20130
|
+
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-abb5baff"]]);
|
|
20137
20131
|
const _hoisted_1$v = ["value", "autofocus", "onKeydown", "onPaste"];
|
|
20138
20132
|
const _sfc_main$E = /* @__PURE__ */ vue.defineComponent({
|
|
20139
20133
|
__name: "OTP",
|
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,8 +10053,7 @@ 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
10059
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.field.children, (child, ii) => {
|
|
@@ -10074,7 +10068,7 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
|
|
|
10074
10068
|
}), 128))
|
|
10075
10069
|
]),
|
|
10076
10070
|
_: 1
|
|
10077
|
-
}, 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);
|
|
10078
10072
|
};
|
|
10079
10073
|
}
|
|
10080
10074
|
});
|
|
@@ -20114,14 +20108,14 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
20114
20108
|
icon: "add",
|
|
20115
20109
|
flat: "",
|
|
20116
20110
|
thin: "",
|
|
20117
|
-
class: "bgl-ctrl-num-btn",
|
|
20111
|
+
class: "bgl-ctrl-num-btn ctrl-add color-gray",
|
|
20118
20112
|
onClick: increment
|
|
20119
20113
|
}),
|
|
20120
20114
|
createVNode(unref(Btn), {
|
|
20121
20115
|
icon: "remove",
|
|
20122
20116
|
flat: "",
|
|
20123
20117
|
thin: "",
|
|
20124
|
-
class: "bgl-ctrl-num-btn",
|
|
20118
|
+
class: "bgl-ctrl-num-btn ctrl-remove color-gray",
|
|
20125
20119
|
onClick: decrement
|
|
20126
20120
|
})
|
|
20127
20121
|
])) : createCommentVNode("", true)
|
|
@@ -20131,7 +20125,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
20131
20125
|
};
|
|
20132
20126
|
}
|
|
20133
20127
|
});
|
|
20134
|
-
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-
|
|
20128
|
+
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-abb5baff"]]);
|
|
20135
20129
|
const _hoisted_1$v = ["value", "autofocus", "onKeydown", "onPaste"];
|
|
20136
20130
|
const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
20137
20131
|
__name: "OTP",
|
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/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,7 +117,6 @@ 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
121
|
<template v-for="(child, ii) in field.children" :key="ii">
|
|
127
122
|
<BglField
|
|
@@ -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>
|