@bagelink/vue 0.0.1258 → 0.0.1262

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/index.cjs CHANGED
@@ -5,51 +5,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5
5
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
6
  const vue = require("vue");
7
7
  const vueRouter = require("vue-router");
8
- const bagelFormUtils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9
- __proto__: null,
10
- get arrField() {
11
- return arrField;
12
- },
13
- get bglForm() {
14
- return bglForm;
15
- },
16
- get checkField() {
17
- return checkField;
18
- },
19
- get dateField() {
20
- return dateField;
21
- },
22
- get findBglFieldById() {
23
- return findBglFieldById;
24
- },
25
- get frmRow() {
26
- return frmRow;
27
- },
28
- get getBaseField() {
29
- return getBaseField;
30
- },
31
- get numField() {
32
- return numField;
33
- },
34
- get richText() {
35
- return richText;
36
- },
37
- get selectField() {
38
- return selectField;
39
- },
40
- get slctField() {
41
- return slctField;
42
- },
43
- get telField() {
44
- return telField;
45
- },
46
- get txtField() {
47
- return txtField;
48
- },
49
- get uploadField() {
50
- return uploadField;
51
- }
52
- }, Symbol.toStringTag, { value: "Module" }));
53
8
  const _sfc_main$1m = /* @__PURE__ */ vue.defineComponent({
54
9
  __name: "Accordion",
55
10
  setup(__props) {
@@ -4438,7 +4393,7 @@ const _sfc_main$_ = /* @__PURE__ */ vue.defineComponent({
4438
4393
  vue.createElementVNode("div", {
4439
4394
  ref_key: "bglSlider",
4440
4395
  ref: bglSlider,
4441
- class: vue.normalizeClass(["bgl-slider", { dragging: vue.unref(isDragging), clicking: vue.unref(isPressed), [`slides-${vue.unref(itemCount)}`]: true }]),
4396
+ class: vue.normalizeClass(["bgl-slider", { dragging: vue.unref(isDragging), clicking: vue.unref(isPressed), [`slides-${vue.unref(itemCount)}`]: true, grab: __props.freeDrag && vue.unref(slideCount) > 1 }]),
4442
4397
  style: vue.normalizeStyle({ "--item-count": vue.unref(itemCount) }),
4443
4398
  onMousedown: startDrag,
4444
4399
  onMouseover: clearAutoplay,
@@ -4477,7 +4432,7 @@ const _sfc_main$_ = /* @__PURE__ */ vue.defineComponent({
4477
4432
  };
4478
4433
  }
4479
4434
  });
4480
- const Carousel = /* @__PURE__ */ _export_sfc(_sfc_main$_, [["__scopeId", "data-v-d0b0c027"]]);
4435
+ const Carousel = /* @__PURE__ */ _export_sfc(_sfc_main$_, [["__scopeId", "data-v-31632a3b"]]);
4481
4436
  function _isPlaceholder(a2) {
4482
4437
  return a2 != null && typeof a2 === "object" && a2["@@functional/placeholder"] === true;
4483
4438
  }
@@ -10772,7 +10727,7 @@ function useTableData(options) {
10772
10727
  return currentData.map(transform).sort((a2, z2) => {
10773
10728
  const aValue = a2[computedSortField.value] ?? "";
10774
10729
  const bValue = z2[computedSortField.value] ?? "";
10775
- if (isDate(aValue) && isDate(bValue)) {
10730
+ if (isDate$2(aValue) && isDate$2(bValue)) {
10776
10731
  return sortDirection.value === "ASC" ? new Date(aValue).getTime() - new Date(bValue).getTime() : new Date(bValue).getTime() - new Date(aValue).getTime();
10777
10732
  }
10778
10733
  const numAValue = Number.parseInt(`${aValue}`.replaceAll(NON_DIGIT_REGEX, ""), 10);
@@ -11515,7 +11470,7 @@ const _sfc_main$X = /* @__PURE__ */ vue.defineComponent({
11515
11470
  emits: /* @__PURE__ */ vue.mergeModels(["update:selectedItems", "orderBy", "select", "lastItemVisible"], ["update:loading", "update:itemHeight", "update:selectedItems"]),
11516
11471
  setup(__props, { emit: __emit }) {
11517
11472
  vue.useCssVars((_ctx) => ({
11518
- "3ee4947a": vue.unref(computedItemHeight)
11473
+ "1ab0cc24": vue.unref(computedItemHeight)
11519
11474
  }));
11520
11475
  const props2 = __props;
11521
11476
  const emit2 = __emit;
@@ -11578,7 +11533,12 @@ const _sfc_main$X = /* @__PURE__ */ vue.defineComponent({
11578
11533
  function renderFieldForRow(field, row) {
11579
11534
  const { renderField } = useSchemaField({
11580
11535
  mode: "table",
11581
- getRowData: () => row
11536
+ getRowData: () => {
11537
+ if (field.id) {
11538
+ return { [field.id]: getNestedValue(row, field.id) };
11539
+ }
11540
+ return row;
11541
+ }
11582
11542
  });
11583
11543
  return renderField({ ...field, label: "" }, slots);
11584
11544
  }
@@ -11694,7 +11654,7 @@ const _sfc_main$X = /* @__PURE__ */ vue.defineComponent({
11694
11654
  };
11695
11655
  }
11696
11656
  });
11697
- const DataTable = /* @__PURE__ */ _export_sfc(_sfc_main$X, [["__scopeId", "data-v-3668ec69"]]);
11657
+ const DataTable = /* @__PURE__ */ _export_sfc(_sfc_main$X, [["__scopeId", "data-v-8e14fc71"]]);
11698
11658
  function useDraggable(options = {}) {
11699
11659
  const isDragging = vue.ref(false);
11700
11660
  const dragElement = vue.ref(null);
@@ -14916,6 +14876,385 @@ const _sfc_main$T = /* @__PURE__ */ vue.defineComponent({
14916
14876
  }
14917
14877
  });
14918
14878
  const Flag = /* @__PURE__ */ _export_sfc(_sfc_main$T, [["__scopeId", "data-v-f99f1900"]]);
14879
+ function getBaseField(id, labelOrRest = {}, rest = {}) {
14880
+ if (typeof labelOrRest === "object") return { id, ...labelOrRest };
14881
+ return { id, label: labelOrRest, ...rest };
14882
+ }
14883
+ function richText(id, label, options) {
14884
+ return {
14885
+ $el: "richtext",
14886
+ class: options == null ? void 0 : options.class,
14887
+ required: options == null ? void 0 : options.required,
14888
+ id,
14889
+ label,
14890
+ vIf: options == null ? void 0 : options.vIf,
14891
+ placeholder: options == null ? void 0 : options.placeholder,
14892
+ attrs: {}
14893
+ };
14894
+ }
14895
+ function txtField(id, label, options) {
14896
+ return {
14897
+ $el: "text",
14898
+ class: options == null ? void 0 : options.class,
14899
+ required: options == null ? void 0 : options.required,
14900
+ id,
14901
+ label,
14902
+ vIf: options == null ? void 0 : options.vIf,
14903
+ disabled: options == null ? void 0 : options.disabled,
14904
+ placeholder: options == null ? void 0 : options.placeholder,
14905
+ defaultValue: options == null ? void 0 : options.defaultValue,
14906
+ attrs: {
14907
+ type: options == null ? void 0 : options.type,
14908
+ pattern: options == null ? void 0 : options.pattern,
14909
+ multiline: options == null ? void 0 : options.multiline
14910
+ }
14911
+ };
14912
+ }
14913
+ function selectField(id, label, options, config) {
14914
+ return {
14915
+ $el: "select",
14916
+ id,
14917
+ options,
14918
+ class: config == null ? void 0 : config.class,
14919
+ placeholder: config == null ? void 0 : config.placeholder,
14920
+ required: config == null ? void 0 : config.required,
14921
+ label,
14922
+ defaultValue: config == null ? void 0 : config.defaultValue,
14923
+ vIf: config == null ? void 0 : config.vIf,
14924
+ attrs: {
14925
+ disabled: config == null ? void 0 : config.disabled,
14926
+ searchable: config == null ? void 0 : config.searchable,
14927
+ multiselect: config == null ? void 0 : config.multiselect,
14928
+ onSearch: config == null ? void 0 : config.onSearch,
14929
+ clearable: config == null ? void 0 : config.clearable
14930
+ }
14931
+ };
14932
+ }
14933
+ const slctField = selectField;
14934
+ function checkField(id, label, options) {
14935
+ return {
14936
+ $el: "check",
14937
+ class: options == null ? void 0 : options.class,
14938
+ required: options == null ? void 0 : options.required,
14939
+ id,
14940
+ label
14941
+ };
14942
+ }
14943
+ function dateField(id, label, options) {
14944
+ return {
14945
+ $el: "date",
14946
+ class: options == null ? void 0 : options.class,
14947
+ required: options == null ? void 0 : options.required,
14948
+ id,
14949
+ disabled: options == null ? void 0 : options.disabled,
14950
+ label,
14951
+ defaultValue: options == null ? void 0 : options.defaultValue,
14952
+ vIf: options == null ? void 0 : options.vIf,
14953
+ attrs: {
14954
+ disabled: options == null ? void 0 : options.disabled
14955
+ }
14956
+ };
14957
+ }
14958
+ function numField$1(id, label, options) {
14959
+ return {
14960
+ $el: "number",
14961
+ class: options == null ? void 0 : options.class,
14962
+ required: options == null ? void 0 : options.required,
14963
+ defaultValue: options == null ? void 0 : options.defaultValue,
14964
+ id,
14965
+ label,
14966
+ disabled: options == null ? void 0 : options.disabled,
14967
+ placeholder: options == null ? void 0 : options.placeholder,
14968
+ helptext: options == null ? void 0 : options.helptext,
14969
+ vIf: options == null ? void 0 : options.vIf,
14970
+ attrs: {
14971
+ step: options == null ? void 0 : options.step,
14972
+ min: options == null ? void 0 : options.min,
14973
+ max: options == null ? void 0 : options.max,
14974
+ layout: options == null ? void 0 : options.layout,
14975
+ padZero: options == null ? void 0 : options.padZero,
14976
+ center: options == null ? void 0 : options.center
14977
+ }
14978
+ };
14979
+ }
14980
+ function frmRow$1(...children2) {
14981
+ return {
14982
+ $el: "div",
14983
+ class: "flex gap-1 m_block align-items-end",
14984
+ children: children2
14985
+ };
14986
+ }
14987
+ function uploadField(id, label, options) {
14988
+ return {
14989
+ $el: "upload",
14990
+ id,
14991
+ label,
14992
+ vIf: options == null ? void 0 : options.vIf,
14993
+ attrs: {
14994
+ ...options
14995
+ }
14996
+ };
14997
+ }
14998
+ function bglForm(idOrField, ...schema) {
14999
+ if (typeof idOrField === "string") {
15000
+ return {
15001
+ $el: "bagelform",
15002
+ id: idOrField,
15003
+ attrs: {
15004
+ schema: [idOrField, ...schema]
15005
+ }
15006
+ };
15007
+ }
15008
+ return {
15009
+ $el: "bagelform",
15010
+ attrs: {
15011
+ schema: [idOrField, ...schema]
15012
+ }
15013
+ };
15014
+ }
15015
+ function telField(id, label, options) {
15016
+ return {
15017
+ $el: vue.markRaw(TelInput),
15018
+ id,
15019
+ label,
15020
+ vIf: options == null ? void 0 : options.vIf,
15021
+ attrs: options
15022
+ };
15023
+ }
15024
+ function findBglFieldById(id, _schema) {
15025
+ for (const field of _schema) {
15026
+ if (field.id === id) return field;
15027
+ if (field.children && Number(field.children.length) > 0) {
15028
+ const fieldChildren = field.children.filter((c2) => typeof c2 === "object" && "$el" in c2);
15029
+ const child = findBglFieldById(id, fieldChildren);
15030
+ if (child) return child;
15031
+ }
15032
+ }
15033
+ return void 0;
15034
+ }
15035
+ function arrField(id, label, schema, options) {
15036
+ return {
15037
+ label,
15038
+ id,
15039
+ $el: "array",
15040
+ vIf: options == null ? void 0 : options.vIf,
15041
+ attrs: { schema, delete: true, add: true, ...options }
15042
+ };
15043
+ }
15044
+ const bagelFormUtils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
15045
+ __proto__: null,
15046
+ arrField,
15047
+ bglForm,
15048
+ checkField,
15049
+ dateField,
15050
+ findBglFieldById,
15051
+ frmRow: frmRow$1,
15052
+ getBaseField,
15053
+ numField: numField$1,
15054
+ richText,
15055
+ selectField,
15056
+ slctField,
15057
+ telField,
15058
+ txtField,
15059
+ uploadField
15060
+ }, Symbol.toStringTag, { value: "Module" }));
15061
+ const state$1 = vue.reactive({
15062
+ defaultLang: "",
15063
+ availableLangs: [],
15064
+ lang: "en"
15065
+ });
15066
+ function $tdb(langEl) {
15067
+ if (!langEl) {
15068
+ console.warn("No language element provided for $tdb function");
15069
+ return "";
15070
+ }
15071
+ return langEl[state$1.lang] || langEl[state$1.defaultLang] || "";
15072
+ }
15073
+ function useLang() {
15074
+ const lang = vue.computed({
15075
+ get: () => state$1.lang,
15076
+ set: (val) => state$1.lang = val
15077
+ });
15078
+ const availableLangs = vue.computed({
15079
+ get: () => state$1.availableLangs,
15080
+ set: (val) => state$1.availableLangs = val
15081
+ });
15082
+ const defaultLang = vue.computed({
15083
+ get: () => state$1.defaultLang,
15084
+ set: (val) => state$1.defaultLang = val
15085
+ });
15086
+ return {
15087
+ lang,
15088
+ $tdb,
15089
+ availableLangs,
15090
+ defaultLang
15091
+ };
15092
+ }
15093
+ function formatString(str, format2) {
15094
+ if (format2 === "titleCase") {
15095
+ return str.split("_").map((word) => word[0].toUpperCase() + word.slice(1).toLocaleLowerCase()).join(" ");
15096
+ }
15097
+ if (format2 === "pascal") {
15098
+ return str.split("_").map((word) => word[0].toUpperCase() + word.slice(1).toLocaleLowerCase()).join("");
15099
+ }
15100
+ if (format2 === "camel") {
15101
+ return str.split("_").map((word, index2) => index2 === 0 ? word : word[0].toUpperCase() + word.slice(1)).join("");
15102
+ }
15103
+ if (format2 === "snake") {
15104
+ return [...str].map((letter) => {
15105
+ if (letter === letter.toUpperCase()) {
15106
+ return `_${letter.toLowerCase()}`;
15107
+ }
15108
+ return letter;
15109
+ }).join("");
15110
+ }
15111
+ return str;
15112
+ }
15113
+ const debouncers = /* @__PURE__ */ new Map();
15114
+ function debounce(fn2, wait = 500) {
15115
+ clearTimeout(debouncers.get(fn2));
15116
+ const timeout = setTimeout(() => {
15117
+ fn2();
15118
+ debouncers.delete(fn2);
15119
+ }, wait);
15120
+ debouncers.set(fn2, timeout);
15121
+ }
15122
+ function slugify(str) {
15123
+ return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").split(/[\s-]+/).join("-");
15124
+ }
15125
+ function keyToLabel(key) {
15126
+ if (key === void 0) return key;
15127
+ return key.split("_").map((k2) => k2.charAt(0).toUpperCase() + k2.slice(1)).join(" ") || key;
15128
+ }
15129
+ async function copyText(text, cb) {
15130
+ await navigator.clipboard.writeText(text);
15131
+ if (cb) cb("Copied to clipboard");
15132
+ }
15133
+ function initials(...strArr) {
15134
+ strArr = strArr.flatMap((str) => str.split(/\s/));
15135
+ return strArr.map((str) => str.charAt(0)).join("");
15136
+ }
15137
+ function useEscape(event, closeModel) {
15138
+ if (event.key === "Escape") {
15139
+ closeModel();
15140
+ }
15141
+ }
15142
+ function classify(fieldVal, row, ...classes) {
15143
+ return classes.map((cls) => {
15144
+ if (typeof cls === "function") return cls(fieldVal, row);
15145
+ return cls;
15146
+ }).join(" ");
15147
+ }
15148
+ function bindAttrs(attrs, fieldVal, row) {
15149
+ if (!attrs) return {};
15150
+ const exclude = ["class"];
15151
+ const arr = Object.entries(attrs).filter(([key]) => !exclude.includes(key)).map(([key, value]) => [
15152
+ key,
15153
+ typeof value === "function" ? value(fieldVal, row) : value
15154
+ ]);
15155
+ const resolvedAttrs = Object.fromEntries(arr);
15156
+ return resolvedAttrs;
15157
+ }
15158
+ function iffer(field, itemData) {
15159
+ var _a2;
15160
+ if (field["v-if"] === void 0) return true;
15161
+ if (typeof field["v-if"] === "boolean") return field["v-if"];
15162
+ if (typeof field["v-if"] === "string") return true;
15163
+ if (typeof field["v-if"] === "function")
15164
+ return (_a2 = field["v-if"]) == null ? void 0 : _a2.call(field, itemData == null ? void 0 : itemData[field.id], itemData);
15165
+ return true;
15166
+ }
15167
+ function denullify(itemData, fieldID) {
15168
+ if (!fieldID) return;
15169
+ return itemData ? itemData[fieldID] : void 0;
15170
+ }
15171
+ const isDate$2 = (dateToTest) => !Number.isNaN(Date.parse(dateToTest));
15172
+ function getFallbackSchema(data2, showFields) {
15173
+ const keys4 = Array.from(new Set((data2 ?? []).flatMap(Object.keys)));
15174
+ const schema = keys4.map((id) => ({
15175
+ id,
15176
+ label: keyToLabel(id),
15177
+ transform: (val) => {
15178
+ const dateFields = ["created_at", "updated_at"];
15179
+ if (dateFields.includes(id)) return val ? new Date(val).toLocaleString() : val;
15180
+ return val;
15181
+ }
15182
+ }));
15183
+ return showFields ? schema.filter((f2) => showFields.includes(f2.id) || !f2.id) : schema;
15184
+ }
15185
+ function sleep(ms = 100) {
15186
+ return new Promise((resolve) => setTimeout(resolve, ms));
15187
+ }
15188
+ function appendScript(src, options) {
15189
+ return new Promise((resolve, reject3) => {
15190
+ if (options == null ? void 0 : options.id) {
15191
+ if (document.getElementById(options.id)) {
15192
+ resolve();
15193
+ return;
15194
+ }
15195
+ } else if (document.querySelector(`script[src="${src}"]`)) {
15196
+ resolve();
15197
+ return;
15198
+ }
15199
+ const script2 = document.createElement("script");
15200
+ script2.src = src;
15201
+ if (options == null ? void 0 : options.id) {
15202
+ script2.id = options.id;
15203
+ }
15204
+ script2.onload = () => {
15205
+ resolve();
15206
+ };
15207
+ script2.onerror = reject3;
15208
+ document.head.append(script2);
15209
+ });
15210
+ }
15211
+ function appendStyle(src) {
15212
+ return new Promise((resolve, reject3) => {
15213
+ if (document.querySelector(`link[href="${src}"]`)) {
15214
+ resolve();
15215
+ return;
15216
+ }
15217
+ const link = document.createElement("link");
15218
+ link.href = src;
15219
+ link.rel = "stylesheet";
15220
+ link.onload = () => {
15221
+ resolve();
15222
+ };
15223
+ link.onerror = reject3;
15224
+ document.head.append(link);
15225
+ });
15226
+ }
15227
+ function normalizeURL(url) {
15228
+ if (url.startsWith("https://")) return url;
15229
+ url = url.replace(/http:\/\//, "");
15230
+ return `https://${url}`;
15231
+ }
15232
+ function normalizeDimension(value, defaultMetric = "px") {
15233
+ if (typeof value === "number") return `${value}${defaultMetric}`;
15234
+ return value;
15235
+ }
15236
+ const fileBaseUrl = "https://files.bagel.design".replace(/\/$/, "");
15237
+ const bagelBaseUrl = void 0;
15238
+ function pathKeyToURL(pathKey) {
15239
+ const urlRE = /^https?:\/\/|^\/\//;
15240
+ if (!pathKey || urlRE.test(pathKey)) return pathKey;
15241
+ if (pathKey.startsWith("static/")) {
15242
+ return `${bagelBaseUrl}/${pathKey}`;
15243
+ }
15244
+ return `${fileBaseUrl}/${pathKey}`;
15245
+ }
15246
+ function getNestedValue(obj, path, defaultValue = void 0) {
15247
+ if (!path) return obj;
15248
+ const keys4 = path.split(/[.[]/);
15249
+ let current = obj;
15250
+ for (const key of keys4) {
15251
+ if (!current || typeof current !== "object" || !(key in current)) {
15252
+ return defaultValue;
15253
+ }
15254
+ current = current[key];
15255
+ }
15256
+ return current ?? defaultValue;
15257
+ }
14919
15258
  const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
14920
15259
  __name: "BagelForm",
14921
15260
  props: {
@@ -14965,15 +15304,6 @@ const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
14965
15304
  return false;
14966
15305
  }
14967
15306
  });
14968
- function getNestedValue(obj, path) {
14969
- const keys4 = path.split(".");
14970
- let current = obj;
14971
- for (const key of keys4) {
14972
- if (current === void 0 || current === null) return void 0;
14973
- current = current[key];
14974
- }
14975
- return current;
14976
- }
14977
15307
  function updateFormData(fieldId, value) {
14978
15308
  const keys4 = fieldId.split(".");
14979
15309
  const newData = safeClone2(formData.value);
@@ -14997,8 +15327,9 @@ const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
14997
15327
  await ((_a2 = props2.onSubmit) == null ? void 0 : _a2.call(props2, formData.value));
14998
15328
  initialFormData.value = safeClone2(formData.value);
14999
15329
  formState.value = "success";
15000
- window.parent.postMessage({ type: "BAGEL_FORM_SUCCESS", data: formData.value }, "*");
15330
+ window.parent.postMessage({ type: "BAGEL_FORM_SUCCESS", data: JSON.stringify(formData.value) }, "*");
15001
15331
  } catch (error) {
15332
+ console.error("Form submission error:", error);
15002
15333
  formState.value = "error";
15003
15334
  }
15004
15335
  }
@@ -15012,7 +15343,7 @@ const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
15012
15343
  return {
15013
15344
  ...formData.value,
15014
15345
  // Add a special getter to handle nested paths
15015
- get: (path) => getNestedValue(formData.value, path)
15346
+ get: (path) => getNestedValue(formData.value, path, "")
15016
15347
  };
15017
15348
  },
15018
15349
  onUpdate: (field, value) => {
@@ -15027,30 +15358,34 @@ const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
15027
15358
  }
15028
15359
  __expose({ form, isDirty: isDirty.value, validateForm });
15029
15360
  return (_ctx, _cache) => {
15030
- return props2.tag === "form" ? (vue.openBlock(), vue.createElementBlock("form", {
15031
- key: 0,
15032
- ref_key: "form",
15033
- ref: form,
15034
- onSubmit: vue.withModifiers(handleSubmit, ["prevent"])
15035
- }, [
15036
- resolvedSchema.value ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(resolvedSchema.value, (field) => {
15037
- return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(renderSchemaField(field)), {
15038
- key: field.id
15039
- });
15040
- }), 128)) : vue.renderSlot(_ctx.$slots, "default", { key: 1 }),
15041
- vue.renderSlot(_ctx.$slots, "submit", {
15042
- submit: handleSubmit,
15043
- isDirty: isDirty.value,
15044
- validateForm,
15045
- formState: formState.value
15046
- }),
15047
- formState.value === "success" ? vue.renderSlot(_ctx.$slots, "success", { key: 2 }) : vue.createCommentVNode("", true),
15048
- formState.value === "error" ? vue.renderSlot(_ctx.$slots, "error", { key: 3 }) : vue.createCommentVNode("", true)
15049
- ], 544)) : (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(resolvedSchema.value, (field) => {
15050
- return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(renderSchemaField(field)), {
15051
- key: field.id
15052
- });
15053
- }), 128));
15361
+ return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
15362
+ formState.value !== "success" || !_ctx.$slots.success ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
15363
+ props2.tag === "form" ? (vue.openBlock(), vue.createElementBlock("form", {
15364
+ key: 0,
15365
+ ref_key: "form",
15366
+ ref: form,
15367
+ onSubmit: vue.withModifiers(handleSubmit, ["prevent"])
15368
+ }, [
15369
+ resolvedSchema.value ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(resolvedSchema.value, (field) => {
15370
+ return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(renderSchemaField(field)), {
15371
+ key: field.id
15372
+ });
15373
+ }), 128)) : vue.renderSlot(_ctx.$slots, "default", { key: 1 }),
15374
+ vue.renderSlot(_ctx.$slots, "submit", {
15375
+ submit: handleSubmit,
15376
+ isDirty: isDirty.value,
15377
+ validateForm,
15378
+ formState: formState.value
15379
+ })
15380
+ ], 544)) : (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(resolvedSchema.value, (field) => {
15381
+ return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(renderSchemaField(field)), {
15382
+ key: field.id
15383
+ });
15384
+ }), 128))
15385
+ ], 64)) : vue.createCommentVNode("", true),
15386
+ formState.value === "success" ? vue.renderSlot(_ctx.$slots, "success", { key: 1 }) : vue.createCommentVNode("", true),
15387
+ formState.value === "error" ? vue.renderSlot(_ctx.$slots, "error", { key: 2 }) : vue.createCommentVNode("", true)
15388
+ ], 64);
15054
15389
  };
15055
15390
  }
15056
15391
  });
@@ -16394,11 +16729,11 @@ function compareAsc(dateLeft, dateRight) {
16394
16729
  return diff;
16395
16730
  }
16396
16731
  }
16397
- function isDate$2(value) {
16732
+ function isDate$1(value) {
16398
16733
  return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
16399
16734
  }
16400
16735
  function isValid(date2) {
16401
- if (!isDate$2(date2) && typeof date2 !== "number") {
16736
+ if (!isDate$1(date2) && typeof date2 !== "number") {
16402
16737
  return false;
16403
16738
  }
16404
16739
  const _date = toDate(date2);
@@ -20080,7 +20415,7 @@ const bl = (e, t) => e == null ? void 0 : e.querySelector(`[data-dp-element="${t
20080
20415
  return l2 && e.preventDefault(), t();
20081
20416
  }, on$1 = (e, t, l2, a2, n2, c2) => {
20082
20417
  const v2 = parse$1(e, t.slice(0, e.length), /* @__PURE__ */ new Date(), { locale: c2 });
20083
- return isValid(v2) && isDate$2(v2) ? a2 || n2 ? v2 : set(v2, {
20418
+ return isValid(v2) && isDate$1(v2) ? a2 || n2 ? v2 : set(v2, {
20084
20419
  hours: +l2.hours,
20085
20420
  minutes: +(l2 == null ? void 0 : l2.minutes),
20086
20421
  seconds: +(l2 == null ? void 0 : l2.seconds),
@@ -26520,7 +26855,7 @@ function formatting(state2) {
26520
26855
  };
26521
26856
  return { text, block, list, clear };
26522
26857
  }
26523
- const { frmRow: frmRow$1, numField: numField$1 } = bagelFormUtils;
26858
+ const { frmRow, numField } = bagelFormUtils;
26524
26859
  function insertImage(modal, state2) {
26525
26860
  const { range: range2, doc } = state2;
26526
26861
  if (!range2 || !doc) return;
@@ -26529,9 +26864,9 @@ function insertImage(modal, state2) {
26529
26864
  schema: [
26530
26865
  { id: "src", $el: "file", attrs: { bindkey: "url" } },
26531
26866
  { id: "alt", $el: "text", label: "Alt Text" },
26532
- frmRow$1(
26533
- numField$1("width", "Width", { min: 1 }),
26534
- numField$1("height", "Height", { min: 1 })
26867
+ frmRow(
26868
+ numField("width", "Width", { min: 1 }),
26869
+ numField("height", "Height", { min: 1 })
26535
26870
  ),
26536
26871
  { id: "figcaption", $el: "check", label: "Show Caption" }
26537
26872
  ],
@@ -31113,7 +31448,7 @@ const isPlainObject = (val) => {
31113
31448
  const prototype2 = getPrototypeOf(val);
31114
31449
  return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
31115
31450
  };
31116
- const isDate$1 = kindOfTest("Date");
31451
+ const isDate = kindOfTest("Date");
31117
31452
  const isFile = kindOfTest("File");
31118
31453
  const isBlob = kindOfTest("Blob");
31119
31454
  const isFileList = kindOfTest("FileList");
@@ -31408,7 +31743,7 @@ const utils$1 = {
31408
31743
  isResponse,
31409
31744
  isHeaders,
31410
31745
  isUndefined,
31411
- isDate: isDate$1,
31746
+ isDate,
31412
31747
  isFile,
31413
31748
  isBlob,
31414
31749
  isRegExp,
@@ -41382,15 +41717,15 @@ const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
41382
41717
  }
41383
41718
  });
41384
41719
  const TabbedLayout = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-915732c1"]]);
41385
- const state$1 = vue.reactive(/* @__PURE__ */ new Map());
41720
+ const state = vue.reactive(/* @__PURE__ */ new Map());
41386
41721
  function useTabs(group) {
41387
- if (!state$1.has(group)) {
41388
- state$1.set(group, vue.reactive({ currentTab: void 0 }));
41722
+ if (!state.has(group)) {
41723
+ state.set(group, vue.reactive({ currentTab: void 0 }));
41389
41724
  }
41390
41725
  const currentTab = vue.computed({
41391
- get: () => state$1.get(group).currentTab,
41726
+ get: () => state.get(group).currentTab,
41392
41727
  set: (val) => {
41393
- state$1.get(group).currentTab = val;
41728
+ state.get(group).currentTab = val;
41394
41729
  }
41395
41730
  });
41396
41731
  return { currentTab };
@@ -43566,19 +43901,7 @@ function safeClone(obj) {
43566
43901
  function provideBagelFormState(initialData) {
43567
43902
  const data2 = vue.ref(initialData);
43568
43903
  const isDirty = vue.ref(false);
43569
- const getFieldData = (path) => {
43570
- if (!path) return "";
43571
- const keys4 = path.split(/[.[]/);
43572
- let current = data2.value;
43573
- for (let i2 = 0; i2 < keys4.length; i2++) {
43574
- const key = keys4[i2];
43575
- if (!current || typeof current !== "object" || !(key in current)) {
43576
- return "";
43577
- }
43578
- current = current[key];
43579
- }
43580
- return current ?? "";
43581
- };
43904
+ const getFieldData = (path) => getNestedValue(data2.value, path, "");
43582
43905
  const updateField = (path, value) => {
43583
43906
  const keys4 = path.split(/[.[]/);
43584
43907
  if (typeof data2.value !== "object" || data2.value === null) {
@@ -44392,356 +44715,6 @@ const ripple = {
44392
44715
  }
44393
44716
  }
44394
44717
  };
44395
- function getBaseField(id, labelOrRest = {}, rest = {}) {
44396
- if (typeof labelOrRest === "object") return { id, ...labelOrRest };
44397
- return { id, label: labelOrRest, ...rest };
44398
- }
44399
- function richText(id, label, options) {
44400
- return {
44401
- $el: "richtext",
44402
- class: options == null ? void 0 : options.class,
44403
- required: options == null ? void 0 : options.required,
44404
- id,
44405
- label,
44406
- vIf: options == null ? void 0 : options.vIf,
44407
- placeholder: options == null ? void 0 : options.placeholder,
44408
- attrs: {}
44409
- };
44410
- }
44411
- function txtField(id, label, options) {
44412
- return {
44413
- $el: "text",
44414
- class: options == null ? void 0 : options.class,
44415
- required: options == null ? void 0 : options.required,
44416
- id,
44417
- label,
44418
- vIf: options == null ? void 0 : options.vIf,
44419
- disabled: options == null ? void 0 : options.disabled,
44420
- placeholder: options == null ? void 0 : options.placeholder,
44421
- defaultValue: options == null ? void 0 : options.defaultValue,
44422
- attrs: {
44423
- type: options == null ? void 0 : options.type,
44424
- pattern: options == null ? void 0 : options.pattern,
44425
- multiline: options == null ? void 0 : options.multiline
44426
- }
44427
- };
44428
- }
44429
- function selectField(id, label, options, config) {
44430
- return {
44431
- $el: "select",
44432
- id,
44433
- options,
44434
- class: config == null ? void 0 : config.class,
44435
- placeholder: config == null ? void 0 : config.placeholder,
44436
- required: config == null ? void 0 : config.required,
44437
- label,
44438
- defaultValue: config == null ? void 0 : config.defaultValue,
44439
- vIf: config == null ? void 0 : config.vIf,
44440
- attrs: {
44441
- disabled: config == null ? void 0 : config.disabled,
44442
- searchable: config == null ? void 0 : config.searchable,
44443
- multiselect: config == null ? void 0 : config.multiselect,
44444
- onSearch: config == null ? void 0 : config.onSearch,
44445
- clearable: config == null ? void 0 : config.clearable
44446
- }
44447
- };
44448
- }
44449
- const slctField = selectField;
44450
- function checkField(id, label, options) {
44451
- return {
44452
- $el: "check",
44453
- class: options == null ? void 0 : options.class,
44454
- required: options == null ? void 0 : options.required,
44455
- id,
44456
- label
44457
- };
44458
- }
44459
- function dateField(id, label, options) {
44460
- return {
44461
- $el: "date",
44462
- class: options == null ? void 0 : options.class,
44463
- required: options == null ? void 0 : options.required,
44464
- id,
44465
- disabled: options == null ? void 0 : options.disabled,
44466
- label,
44467
- defaultValue: options == null ? void 0 : options.defaultValue,
44468
- vIf: options == null ? void 0 : options.vIf,
44469
- attrs: {
44470
- disabled: options == null ? void 0 : options.disabled
44471
- }
44472
- };
44473
- }
44474
- function numField(id, label, options) {
44475
- return {
44476
- $el: "number",
44477
- class: options == null ? void 0 : options.class,
44478
- required: options == null ? void 0 : options.required,
44479
- defaultValue: options == null ? void 0 : options.defaultValue,
44480
- id,
44481
- label,
44482
- disabled: options == null ? void 0 : options.disabled,
44483
- placeholder: options == null ? void 0 : options.placeholder,
44484
- helptext: options == null ? void 0 : options.helptext,
44485
- vIf: options == null ? void 0 : options.vIf,
44486
- attrs: {
44487
- step: options == null ? void 0 : options.step,
44488
- min: options == null ? void 0 : options.min,
44489
- max: options == null ? void 0 : options.max,
44490
- layout: options == null ? void 0 : options.layout,
44491
- padZero: options == null ? void 0 : options.padZero,
44492
- center: options == null ? void 0 : options.center
44493
- }
44494
- };
44495
- }
44496
- function frmRow(...children2) {
44497
- return {
44498
- $el: "div",
44499
- class: "flex gap-1 m_block align-items-end",
44500
- children: children2
44501
- };
44502
- }
44503
- function uploadField(id, label, options) {
44504
- return {
44505
- $el: "upload",
44506
- id,
44507
- label,
44508
- vIf: options == null ? void 0 : options.vIf,
44509
- attrs: {
44510
- ...options
44511
- }
44512
- };
44513
- }
44514
- function bglForm(idOrField, ...schema) {
44515
- if (typeof idOrField === "string") {
44516
- return {
44517
- $el: "bagelform",
44518
- id: idOrField,
44519
- attrs: {
44520
- schema: [idOrField, ...schema]
44521
- }
44522
- };
44523
- }
44524
- return {
44525
- $el: "bagelform",
44526
- attrs: {
44527
- schema: [idOrField, ...schema]
44528
- }
44529
- };
44530
- }
44531
- function telField(id, label, options) {
44532
- return {
44533
- $el: vue.markRaw(TelInput),
44534
- id,
44535
- label,
44536
- vIf: options == null ? void 0 : options.vIf,
44537
- attrs: options
44538
- };
44539
- }
44540
- function findBglFieldById(id, _schema) {
44541
- for (const field of _schema) {
44542
- if (field.id === id) return field;
44543
- if (field.children && Number(field.children.length) > 0) {
44544
- const fieldChildren = field.children.filter((c2) => typeof c2 === "object" && "$el" in c2);
44545
- const child = findBglFieldById(id, fieldChildren);
44546
- if (child) return child;
44547
- }
44548
- }
44549
- return void 0;
44550
- }
44551
- function arrField(id, label, schema, options) {
44552
- return {
44553
- label,
44554
- id,
44555
- $el: "array",
44556
- vIf: options == null ? void 0 : options.vIf,
44557
- attrs: { schema, delete: true, add: true, ...options }
44558
- };
44559
- }
44560
- const state = vue.reactive({
44561
- defaultLang: "",
44562
- availableLangs: [],
44563
- lang: "en"
44564
- });
44565
- function $tdb(langEl) {
44566
- if (!langEl) {
44567
- console.warn("No language element provided for $tdb function");
44568
- return "";
44569
- }
44570
- return langEl[state.lang] || langEl[state.defaultLang] || "";
44571
- }
44572
- function useLang() {
44573
- const lang = vue.computed({
44574
- get: () => state.lang,
44575
- set: (val) => state.lang = val
44576
- });
44577
- const availableLangs = vue.computed({
44578
- get: () => state.availableLangs,
44579
- set: (val) => state.availableLangs = val
44580
- });
44581
- const defaultLang = vue.computed({
44582
- get: () => state.defaultLang,
44583
- set: (val) => state.defaultLang = val
44584
- });
44585
- return {
44586
- lang,
44587
- $tdb,
44588
- availableLangs,
44589
- defaultLang
44590
- };
44591
- }
44592
- function formatString(str, format2) {
44593
- if (format2 === "titleCase") {
44594
- return str.split("_").map((word) => word[0].toUpperCase() + word.slice(1).toLocaleLowerCase()).join(" ");
44595
- }
44596
- if (format2 === "pascal") {
44597
- return str.split("_").map((word) => word[0].toUpperCase() + word.slice(1).toLocaleLowerCase()).join("");
44598
- }
44599
- if (format2 === "camel") {
44600
- return str.split("_").map((word, index2) => index2 === 0 ? word : word[0].toUpperCase() + word.slice(1)).join("");
44601
- }
44602
- if (format2 === "snake") {
44603
- return [...str].map((letter) => {
44604
- if (letter === letter.toUpperCase()) {
44605
- return `_${letter.toLowerCase()}`;
44606
- }
44607
- return letter;
44608
- }).join("");
44609
- }
44610
- return str;
44611
- }
44612
- const debouncers = /* @__PURE__ */ new Map();
44613
- function debounce(fn2, wait = 500) {
44614
- clearTimeout(debouncers.get(fn2));
44615
- const timeout = setTimeout(() => {
44616
- fn2();
44617
- debouncers.delete(fn2);
44618
- }, wait);
44619
- debouncers.set(fn2, timeout);
44620
- }
44621
- function slugify(str) {
44622
- return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").split(/[\s-]+/).join("-");
44623
- }
44624
- function keyToLabel(key) {
44625
- if (key === void 0) return key;
44626
- return key.split("_").map((k2) => k2.charAt(0).toUpperCase() + k2.slice(1)).join(" ") || key;
44627
- }
44628
- async function copyText(text, cb) {
44629
- await navigator.clipboard.writeText(text);
44630
- if (cb) cb("Copied to clipboard");
44631
- }
44632
- function initials(...strArr) {
44633
- strArr = strArr.flatMap((str) => str.split(/\s/));
44634
- return strArr.map((str) => str.charAt(0)).join("");
44635
- }
44636
- function useEscape(event, closeModel) {
44637
- if (event.key === "Escape") {
44638
- closeModel();
44639
- }
44640
- }
44641
- function classify(fieldVal, row, ...classes) {
44642
- return classes.map((cls) => {
44643
- if (typeof cls === "function") return cls(fieldVal, row);
44644
- return cls;
44645
- }).join(" ");
44646
- }
44647
- function bindAttrs(attrs, fieldVal, row) {
44648
- if (!attrs) return {};
44649
- const exclude = ["class"];
44650
- const arr = Object.entries(attrs).filter(([key]) => !exclude.includes(key)).map(([key, value]) => [
44651
- key,
44652
- typeof value === "function" ? value(fieldVal, row) : value
44653
- ]);
44654
- const resolvedAttrs = Object.fromEntries(arr);
44655
- return resolvedAttrs;
44656
- }
44657
- function iffer(field, itemData) {
44658
- var _a2;
44659
- if (field["v-if"] === void 0) return true;
44660
- if (typeof field["v-if"] === "boolean") return field["v-if"];
44661
- if (typeof field["v-if"] === "string") return true;
44662
- if (typeof field["v-if"] === "function")
44663
- return (_a2 = field["v-if"]) == null ? void 0 : _a2.call(field, itemData == null ? void 0 : itemData[field.id], itemData);
44664
- return true;
44665
- }
44666
- function denullify(itemData, fieldID) {
44667
- if (!fieldID) return;
44668
- return itemData ? itemData[fieldID] : void 0;
44669
- }
44670
- const isDate = (dateToTest) => !Number.isNaN(Date.parse(dateToTest));
44671
- function getFallbackSchema(data2, showFields) {
44672
- const keys4 = Array.from(new Set((data2 ?? []).flatMap(Object.keys)));
44673
- const schema = keys4.map((id) => ({
44674
- id,
44675
- label: keyToLabel(id),
44676
- transform: (val) => {
44677
- const dateFields = ["created_at", "updated_at"];
44678
- if (dateFields.includes(id)) return val ? new Date(val).toLocaleString() : val;
44679
- return val;
44680
- }
44681
- }));
44682
- return showFields ? schema.filter((f2) => showFields.includes(f2.id) || !f2.id) : schema;
44683
- }
44684
- function sleep(ms = 100) {
44685
- return new Promise((resolve) => setTimeout(resolve, ms));
44686
- }
44687
- function appendScript(src, options) {
44688
- return new Promise((resolve, reject3) => {
44689
- if (options == null ? void 0 : options.id) {
44690
- if (document.getElementById(options.id)) {
44691
- resolve();
44692
- return;
44693
- }
44694
- } else if (document.querySelector(`script[src="${src}"]`)) {
44695
- resolve();
44696
- return;
44697
- }
44698
- const script2 = document.createElement("script");
44699
- script2.src = src;
44700
- if (options == null ? void 0 : options.id) {
44701
- script2.id = options.id;
44702
- }
44703
- script2.onload = () => {
44704
- resolve();
44705
- };
44706
- script2.onerror = reject3;
44707
- document.head.append(script2);
44708
- });
44709
- }
44710
- function appendStyle(src) {
44711
- return new Promise((resolve, reject3) => {
44712
- if (document.querySelector(`link[href="${src}"]`)) {
44713
- resolve();
44714
- return;
44715
- }
44716
- const link = document.createElement("link");
44717
- link.href = src;
44718
- link.rel = "stylesheet";
44719
- link.onload = () => {
44720
- resolve();
44721
- };
44722
- link.onerror = reject3;
44723
- document.head.append(link);
44724
- });
44725
- }
44726
- function normalizeURL(url) {
44727
- if (url.startsWith("https://")) return url;
44728
- url = url.replace(/http:\/\//, "");
44729
- return `https://${url}`;
44730
- }
44731
- function normalizeDimension(value, defaultMetric = "px") {
44732
- if (typeof value === "number") return `${value}${defaultMetric}`;
44733
- return value;
44734
- }
44735
- const fileBaseUrl = "https://files.bagel.design".replace(/\/$/, "");
44736
- const bagelBaseUrl = void 0;
44737
- function pathKeyToURL(pathKey) {
44738
- const urlRE = /^https?:\/\/|^\/\//;
44739
- if (!pathKey || urlRE.test(pathKey)) return pathKey;
44740
- if (pathKey.startsWith("static/")) {
44741
- return `${bagelBaseUrl}/${pathKey}`;
44742
- }
44743
- return `${fileBaseUrl}/${pathKey}`;
44744
- }
44745
44718
  const clickOutside = {
44746
44719
  beforeMount(el, binding) {
44747
44720
  el.clickOutsideEvent = (event) => {
@@ -45359,10 +45332,11 @@ exports.debounce = debounce;
45359
45332
  exports.denullify = denullify;
45360
45333
  exports.formatString = formatString;
45361
45334
  exports.getFallbackSchema = getFallbackSchema;
45335
+ exports.getNestedValue = getNestedValue;
45362
45336
  exports.i18nTInjectionKey = i18nTInjectionKey;
45363
45337
  exports.iffer = iffer;
45364
45338
  exports.initials = initials;
45365
- exports.isDate = isDate;
45339
+ exports.isDate = isDate$2;
45366
45340
  exports.keyToLabel = keyToLabel;
45367
45341
  exports.localRef = localRef;
45368
45342
  exports.normalizeDimension = normalizeDimension;