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