@windwalker-io/unicorn-next 0.1.0 → 0.1.1

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.
Files changed (135) hide show
  1. package/.editorconfig +18 -18
  2. package/.gulp.json +7 -7
  3. package/bin/release.mjs +47 -47
  4. package/dist/chunks/button-radio.js.map +1 -1
  5. package/dist/chunks/checkboxes-multi-select.js.map +1 -1
  6. package/dist/chunks/field-cascade-select.js.map +1 -1
  7. package/dist/chunks/field-file-drag.js.map +1 -1
  8. package/dist/chunks/field-flatpickr.js.map +1 -1
  9. package/dist/chunks/field-modal-select.js.map +1 -1
  10. package/dist/chunks/field-modal-tree.js +2 -2
  11. package/dist/chunks/field-modal-tree.js.map +1 -1
  12. package/dist/chunks/field-multi-uploader.js.map +1 -1
  13. package/dist/chunks/field-repeatable.js.map +1 -1
  14. package/dist/chunks/field-single-image-drag.js.map +1 -1
  15. package/dist/chunks/form.js +1 -1
  16. package/dist/chunks/form.js.map +1 -1
  17. package/dist/chunks/grid.js.map +1 -1
  18. package/dist/chunks/http-client.js.map +1 -1
  19. package/dist/chunks/iframe-modal.js.map +1 -1
  20. package/dist/chunks/keep-tab.js +1 -1
  21. package/dist/chunks/keep-tab.js.map +1 -1
  22. package/dist/chunks/legacy.js +3 -3
  23. package/dist/chunks/legacy.js.map +1 -1
  24. package/dist/chunks/list-dependent.js.map +1 -1
  25. package/dist/chunks/s3-multipart-uploader.js.map +1 -1
  26. package/dist/chunks/s3-uploader.js.map +1 -1
  27. package/dist/chunks/show-on.js.map +1 -1
  28. package/dist/chunks/tinymce.js +14 -4
  29. package/dist/chunks/tinymce.js.map +1 -1
  30. package/dist/chunks/ui-bootstrap5.js +9 -2
  31. package/dist/chunks/ui-bootstrap5.js.map +1 -1
  32. package/dist/chunks/unicorn.js +94 -46
  33. package/dist/chunks/unicorn.js.map +1 -1
  34. package/dist/chunks/validation.js.map +1 -1
  35. package/dist/editor.css +1 -1
  36. package/dist/index.d.ts +55 -36
  37. package/dist/multi-level-menu.css +1 -1
  38. package/dist/switcher.css +1 -1
  39. package/dist/unicorn.js +22 -22
  40. package/fusionfile.mjs +155 -155
  41. package/package.json +102 -102
  42. package/scss/bootstrap/multi-level-menu.scss +121 -121
  43. package/scss/editor.scss +116 -116
  44. package/scss/field/file-drag.scss +102 -102
  45. package/scss/field/single-image-drag.scss +88 -88
  46. package/scss/field/vue-drag-uploader.scss +160 -160
  47. package/scss/switcher.scss +156 -156
  48. package/src/app.ts +128 -128
  49. package/src/bootstrap/button-radio.ts +208 -208
  50. package/src/bootstrap/keep-tab.ts +155 -155
  51. package/src/composable/index.ts +21 -21
  52. package/src/composable/useCheckboxesMultiSelect.ts +22 -22
  53. package/src/composable/useFieldCascadeSelect.ts +9 -9
  54. package/src/composable/useFieldFileDrag.ts +9 -9
  55. package/src/composable/useFieldFlatpickr.ts +3 -3
  56. package/src/composable/useFieldModalSelect.ts +6 -6
  57. package/src/composable/useFieldModalTree.ts +3 -3
  58. package/src/composable/useFieldMultiUploader.ts +3 -3
  59. package/src/composable/useFieldRepeatable.ts +9 -9
  60. package/src/composable/useFieldSingleImageDrag.ts +5 -5
  61. package/src/composable/useForm.ts +43 -43
  62. package/src/composable/useGrid.ts +57 -57
  63. package/src/composable/useHttp.ts +9 -8
  64. package/src/composable/useIframeModal.ts +9 -9
  65. package/src/composable/useListDependent.ts +26 -26
  66. package/src/composable/useQueue.ts +13 -13
  67. package/src/composable/useS3Uploader.ts +32 -32
  68. package/src/composable/useShowOn.ts +9 -9
  69. package/src/composable/useStack.ts +13 -13
  70. package/src/composable/useTinymce.ts +29 -29
  71. package/src/composable/useTomSelect.ts +72 -72
  72. package/src/composable/useUIBootstrap5.ts +48 -48
  73. package/src/composable/useUniDirective.ts +32 -32
  74. package/src/composable/useValidation.ts +39 -39
  75. package/src/data.ts +34 -36
  76. package/src/events.ts +82 -73
  77. package/src/legacy/legacy.ts +186 -186
  78. package/src/legacy/loader.ts +125 -125
  79. package/src/module/checkboxes-multi-select.ts +54 -54
  80. package/src/module/field-cascade-select.ts +292 -292
  81. package/src/module/field-file-drag.ts +292 -292
  82. package/src/module/field-flatpickr.ts +127 -127
  83. package/src/module/field-modal-select.ts +174 -174
  84. package/src/module/field-modal-tree.ts +27 -27
  85. package/src/module/field-multi-uploader.ts +361 -361
  86. package/src/module/field-repeatable.ts +202 -202
  87. package/src/module/field-single-image-drag.ts +468 -468
  88. package/src/module/form.ts +223 -223
  89. package/src/module/grid.ts +465 -465
  90. package/src/module/http-client.ts +248 -243
  91. package/src/module/iframe-modal.ts +167 -167
  92. package/src/module/list-dependent.ts +321 -321
  93. package/src/module/s3-multipart-uploader.ts +300 -300
  94. package/src/module/s3-uploader.ts +234 -234
  95. package/src/module/show-on.ts +173 -173
  96. package/src/module/tinymce.ts +279 -263
  97. package/src/module/ui-bootstrap5.ts +116 -107
  98. package/src/module/validation.ts +1019 -1019
  99. package/src/plugin/index.ts +1 -1
  100. package/src/plugin/php-adapter.ts +65 -65
  101. package/src/polyfill/form-request-submit.ts +31 -31
  102. package/src/polyfill/index.ts +9 -9
  103. package/src/service/animate.ts +58 -58
  104. package/src/service/crypto.ts +27 -27
  105. package/src/service/dom-watcher.ts +62 -62
  106. package/src/service/dom.ts +265 -265
  107. package/src/service/helper.ts +48 -48
  108. package/src/service/index.ts +10 -10
  109. package/src/service/lang.ts +122 -122
  110. package/src/service/loader.ts +152 -152
  111. package/src/service/router.ts +118 -118
  112. package/src/service/ui.ts +525 -497
  113. package/src/service/uri.ts +106 -106
  114. package/src/types/base.ts +9 -9
  115. package/src/types/index.ts +4 -4
  116. package/src/types/modal-tree.ts +12 -12
  117. package/src/types/plugin.ts +6 -6
  118. package/src/types/shims.d.ts +18 -18
  119. package/src/types/ui.ts +6 -6
  120. package/src/unicorn.ts +79 -63
  121. package/src/utilities/arr.ts +25 -25
  122. package/src/utilities/base.ts +9 -9
  123. package/src/utilities/data.ts +48 -48
  124. package/src/utilities/index.ts +5 -5
  125. package/src/utilities/tree.ts +20 -20
  126. package/src/vue/components/ModalTree/ModalTreeApp.vue +175 -175
  127. package/src/vue/components/ModalTree/TreeItem.vue +262 -262
  128. package/src/vue/components/ModalTree/TreeModal.vue +225 -225
  129. package/tests/test.js +4 -4
  130. package/tsconfig.js.json +25 -25
  131. package/tsconfig.json +17 -17
  132. package/vite.assets.config.ts +61 -61
  133. package/vite.config.test.ts +36 -36
  134. package/vite.config.ts +112 -112
  135. package/dist/unicorn-next.css +0 -12
@@ -157,7 +157,7 @@ function mergeDeep(target, ...sources) {
157
157
  }
158
158
  return out;
159
159
  }
160
- function getData(element, name = void 0) {
160
+ function getData(element, name) {
161
161
  prepareData(element);
162
162
  if (name === void 0) {
163
163
  return element.__unicorn;
@@ -368,17 +368,41 @@ function animateTo(element, styles, options = {}) {
368
368
  }
369
369
  const _AlertAdapter = class _AlertAdapter {
370
370
  };
371
- _AlertAdapter.alert = async (title) => window.alert(title);
372
- _AlertAdapter.confirm = async (title) => {
371
+ _AlertAdapter.alert = async (title, text) => {
372
+ if (text) {
373
+ title += " | " + text;
374
+ }
375
+ return window.alert(title);
376
+ };
377
+ _AlertAdapter.confirm = async (title, text) => {
373
378
  return new Promise((resolve) => {
379
+ if (text) {
380
+ title += " | " + text;
381
+ }
374
382
  const v = confirm(title);
375
383
  resolve(v);
376
384
  });
377
385
  };
378
- _AlertAdapter.deleteConfirm = async (title) => _AlertAdapter.confirm(title);
379
- _AlertAdapter.confirmText = () => "確認";
380
- _AlertAdapter.cancelText = () => "取消";
381
- _AlertAdapter.deleteText = () => "刪除";
386
+ _AlertAdapter.deleteConfirm = async (title, text) => _AlertAdapter.confirm(title, text);
387
+ _AlertAdapter.notify = async (title, text, type = "log") => {
388
+ if (text) {
389
+ title += " | " + text;
390
+ }
391
+ if (type === "error") {
392
+ console.error(title);
393
+ } else if (type === "warn") {
394
+ console.warn(title);
395
+ } else {
396
+ console.log(title);
397
+ }
398
+ return async () => {
399
+ };
400
+ };
401
+ _AlertAdapter.clearNotifies = async () => {
402
+ };
403
+ _AlertAdapter.confirmText = () => "OK";
404
+ _AlertAdapter.cancelText = () => "Cancel";
405
+ _AlertAdapter.deleteText = () => "Delete";
382
406
  let AlertAdapter = _AlertAdapter;
383
407
  async function simpleAlert(title, text = "", icon = "info", extra) {
384
408
  return AlertAdapter.alert(title, text, icon, extra);
@@ -389,6 +413,12 @@ async function simpleConfirm(title, text = "", icon = "info", extra) {
389
413
  async function deleteConfirm(title, text = "", icon = "info", extra) {
390
414
  return AlertAdapter.deleteConfirm(title, text, icon, extra);
391
415
  }
416
+ async function simpleNotify(title, text = "", type = "info", extra) {
417
+ return AlertAdapter.notify(title, text, type, extra);
418
+ }
419
+ async function clearNotifies() {
420
+ return AlertAdapter.clearNotifies();
421
+ }
392
422
  function isNode() {
393
423
  return typeof window === "undefined";
394
424
  }
@@ -960,7 +990,7 @@ class UnicornLang {
960
990
  }
961
991
  function useScriptImport(src, attrs = {}) {
962
992
  const script = document.createElement("script");
963
- script.src = src;
993
+ script.src = resolveUrl(src);
964
994
  for (const key in attrs) {
965
995
  script.setAttribute(key, attrs[key]);
966
996
  }
@@ -1324,15 +1354,33 @@ AlertAdapter.alert = (title, text = "", type = "info") => {
1324
1354
  window.alert(title);
1325
1355
  return Promise.resolve();
1326
1356
  };
1327
- AlertAdapter.confirm = (message) => {
1357
+ AlertAdapter.confirm = (message, text = "", type = "info") => {
1328
1358
  message = message || "Are you sure?";
1359
+ if (text) {
1360
+ message += " | " + text;
1361
+ }
1329
1362
  return new Promise((resolve) => {
1330
1363
  resolve(window.confirm(message));
1331
1364
  });
1332
1365
  };
1366
+ AlertAdapter.notify = async (title, text, type = "log") => {
1367
+ if (text) {
1368
+ title += " | " + text;
1369
+ }
1370
+ return ui.theme?.renderMessage(title, type) ?? (() => null);
1371
+ };
1372
+ AlertAdapter.clearNotifies = async () => {
1373
+ ui.theme?.clearMessages();
1374
+ };
1333
1375
  AlertAdapter.confirmText = () => "OK";
1334
1376
  AlertAdapter.cancelText = () => "Cancel";
1335
1377
  AlertAdapter.deleteText = () => "Delete";
1378
+ function useAlertAdapter(config) {
1379
+ if (config) {
1380
+ Object.assign(AlertAdapter, config);
1381
+ }
1382
+ return AlertAdapter;
1383
+ }
1336
1384
  function useUI(instance) {
1337
1385
  if (instance) {
1338
1386
  ui = instance;
@@ -1352,7 +1400,6 @@ function useUITheme(theme) {
1352
1400
  }
1353
1401
  class UnicornUI {
1354
1402
  theme;
1355
- aliveHandle;
1356
1403
  static get defaultOptions() {
1357
1404
  return {
1358
1405
  messageSelector: ".message-wrap"
@@ -1420,16 +1467,10 @@ async function prepareAlpineDefer(callback) {
1420
1467
  await callback(window.Alpine);
1421
1468
  }
1422
1469
  function renderMessage(messages, type = "info") {
1423
- ui.theme.renderMessage(messages, type);
1470
+ return ui.theme?.renderMessage(messages, type);
1424
1471
  }
1425
1472
  function clearMessages() {
1426
- ui.theme.clearMessages();
1427
- }
1428
- function notify(messages, type = "info") {
1429
- ui.theme.renderMessage(messages, type);
1430
- }
1431
- function clearNotifies() {
1432
- ui.theme.clearMessages();
1473
+ ui.theme?.clearMessages();
1433
1474
  }
1434
1475
  async function mark(selector, keyword = "", options = {}) {
1435
1476
  const modules = await useImport("@vendor/mark.js/dist/mark.min.js");
@@ -1824,7 +1865,7 @@ function removeCloak() {
1824
1865
  }
1825
1866
  selectAll("[uni-cloak]", (el) => el.removeAttribute("uni-cloak"));
1826
1867
  }
1827
- function data(ele, name = void 0, value = void 0) {
1868
+ function data(ele, name, value) {
1828
1869
  if (!(ele instanceof HTMLElement)) {
1829
1870
  value = name;
1830
1871
  name = ele;
@@ -1834,8 +1875,7 @@ function data(ele, name = void 0, value = void 0) {
1834
1875
  return getData(ele);
1835
1876
  }
1836
1877
  if (value === void 0) {
1837
- const res = getData(ele, name);
1838
- return res;
1878
+ return getData(ele, name);
1839
1879
  }
1840
1880
  setData(ele, name, value);
1841
1881
  }
@@ -1961,11 +2001,11 @@ class UnicornApp extends (/* @__PURE__ */ Mixin(EventMixin)) {
1961
2001
  this.waits = [];
1962
2002
  return promise;
1963
2003
  }
1964
- macro(name, callback) {
2004
+ macro(name, prop) {
1965
2005
  if (this[name]) {
1966
2006
  throw new Error(`Macro: ${name} already exists.`);
1967
2007
  }
1968
- this[name] = callback;
2008
+ this[name] = prop;
1969
2009
  return this;
1970
2010
  }
1971
2011
  }
@@ -2063,8 +2103,16 @@ const useInject = (id, def) => {
2063
2103
  function pushUnicornToGlobal(app2) {
2064
2104
  window.u = app2 ?? useUnicorn();
2065
2105
  }
2066
- function useMacro(name, handler) {
2067
- useUnicorn().macro(name, handler);
2106
+ function useMacro(name, prop) {
2107
+ const app2 = useUnicorn();
2108
+ if (typeof name === "string") {
2109
+ app2.macro(name, prop);
2110
+ } else {
2111
+ for (const k in name) {
2112
+ app2.macro(k, name[k]);
2113
+ }
2114
+ }
2115
+ return app2;
2068
2116
  }
2069
2117
  async function useLegacy(app2) {
2070
2118
  app2 ??= useUnicorn();
@@ -2115,7 +2163,7 @@ export {
2115
2163
  useImport as a8,
2116
2164
  useCssImport as a9,
2117
2165
  useCssIncludes as aA,
2118
- AlertAdapter as aB,
2166
+ useAlertAdapter as aB,
2119
2167
  useUI as aC,
2120
2168
  UnicornUI as aD,
2121
2169
  useVueComponentField as aE,
@@ -2149,22 +2197,22 @@ export {
2149
2197
  createQueue as af,
2150
2198
  trans as ag,
2151
2199
  useUITheme as ah,
2152
- sleep as ai,
2153
- createUnicorn as aj,
2154
- createUnicornWithPlugins as ak,
2155
- useUnicorn as al,
2156
- useInject as am,
2157
- pushUnicornToGlobal as an,
2158
- useMacro as ao,
2159
- useLegacy as ap,
2160
- removeData as aq,
2161
- randomBytes as ar,
2162
- randomBytesString as as,
2163
- AttributeMutationObserver as at,
2164
- nextTick as au,
2165
- wait as av,
2166
- useLang as aw,
2167
- useScriptImport as ax,
2200
+ useScriptImport as ai,
2201
+ sleep as aj,
2202
+ createUnicorn as ak,
2203
+ createUnicornWithPlugins as al,
2204
+ useUnicorn as am,
2205
+ useInject as an,
2206
+ pushUnicornToGlobal as ao,
2207
+ useMacro as ap,
2208
+ useLegacy as aq,
2209
+ removeData as ar,
2210
+ randomBytes as as,
2211
+ randomBytesString as at,
2212
+ AttributeMutationObserver as au,
2213
+ nextTick as av,
2214
+ wait as aw,
2215
+ useLang as ax,
2168
2216
  doImport as ay,
2169
2217
  useSeriesImport as az,
2170
2218
  animateTo as b,
@@ -2185,12 +2233,12 @@ export {
2185
2233
  useFormValidationSync as k,
2186
2234
  loadAlpine as l,
2187
2235
  useStack as m,
2188
- notify as n,
2189
- useQueue as o,
2236
+ useQueue as n,
2237
+ useSystemUri as o,
2190
2238
  prepareAlpine as p,
2191
- useSystemUri as q,
2239
+ useAssetUri as q,
2192
2240
  route as r,
2193
- useAssetUri as s,
2241
+ simpleNotify as s,
2194
2242
  domready as t,
2195
2243
  useHttpClient as u,
2196
2244
  selectOne as v,