@trops/dash-core 0.1.778 → 0.1.779

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.esm.js CHANGED
@@ -2780,6 +2780,30 @@ function useWidgetRegistryVersion() {
2780
2780
  return version;
2781
2781
  }
2782
2782
 
2783
+ /**
2784
+ * draftPackage.js — is a widget package a Widget Builder draft?
2785
+ *
2786
+ * Drafts are in-progress widgets the Widget Builder saves as it goes, in
2787
+ * `@ai-built/draft-<draft id>/` (older ones: `@ai-built/<name>-draft-<shortId>/`).
2788
+ * They're registered like any widget so they can preview, but they belong
2789
+ * in Manage › Widgets (Resume / Delete), not in the sidebar or pickers.
2790
+ */
2791
+
2792
+ var DRAFT_DIR = /(?:^|\/)(draft-[A-Za-z0-9][A-Za-z0-9-]*)$/;
2793
+ var LEGACY_DRAFT_DIR = /-draft-[A-Za-z0-9]+$/;
2794
+
2795
+ /** @param {string} pkg a package name or its folder ("@ai-built/draft-…") */
2796
+ function isDraftPackage(pkg) {
2797
+ var name = String(pkg || "");
2798
+ return DRAFT_DIR.test(name) || LEGACY_DRAFT_DIR.test(name);
2799
+ }
2800
+
2801
+ /** The draft's id for an id-keyed draft package, else null. */
2802
+ function draftIdOf(pkg) {
2803
+ var m = String(pkg || "").match(DRAFT_DIR);
2804
+ return m ? m[1] : null;
2805
+ }
2806
+
2783
2807
  function _createForOfIteratorHelper$1b(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1b(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
2784
2808
  function _unsupportedIterableToArray$1b(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1b(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1b(r, a) : void 0; } }
2785
2809
  function _arrayLikeToArray$1b(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
@@ -2884,12 +2908,13 @@ var useInstalledWidgets = function useInstalledWidgets() {
2884
2908
  draftId: draftsByPackageDir.get(path).id
2885
2909
  };
2886
2910
  }
2887
- // 2. Fallback: the dir name follows `<base>-draft-<shortId>`;
2888
- // pluck the shortId and look it up in the drafts list.
2889
- var m = String(name).match(/-draft-([A-Za-z0-9]+)$/);
2890
- if (m) {
2891
- var _shortId = m[1].slice(0, 8);
2892
- var draftId = draftShortIdToId.get(_shortId) || null;
2911
+ // 2. Fallback: a draft folder by name — today's `draft-<id>`
2912
+ // is the draft's id; an older `<base>-draft-<shortId>` is
2913
+ // looked up by its shortId.
2914
+ if (isDraftPackage(name)) {
2915
+ var id = draftIdOf(name);
2916
+ var m = String(name).match(/-draft-([A-Za-z0-9]+)$/);
2917
+ var draftId = id ? id : m && draftShortIdToId.get(m[1].slice(0, 8)) || null;
2893
2918
  return {
2894
2919
  kind: "draft",
2895
2920
  draftId: draftId
@@ -18731,16 +18756,11 @@ var EnhancedWidgetDropdown = function EnhancedWidgetDropdown(_ref) {
18731
18756
  // Filter widgets based on search, author, and provider
18732
18757
  var getFilteredWidgets = function getFilteredWidgets() {
18733
18758
  var filtered = widgets.filter(function (widget) {
18734
- // Drafts are in-progress widgets — they live under
18735
- // `@ai-built/<name>-draft-<shortId>/` on disk and shouldn't
18736
- // appear in the placement picker. EnhancedWidgetDropdown
18737
- // reads from ComponentManager directly, so we detect drafts
18738
- // via the `_sourcePackage` name pattern (mirrors the
18739
- // matching backstop in useInstalledWidgets#classifyWidget).
18740
- // useInstalledWidgets sets `widget.kind` for consumers that
18741
- // go through that hook; check it too for forward-compat.
18742
- var sourcePackage = widget._sourcePackage || "";
18743
- if (widget.kind === "draft" || /-draft-[A-Za-z0-9]+$/.test(sourcePackage)) {
18759
+ // Drafts are in-progress widgets (`@ai-built/draft-<id>/`) and
18760
+ // shouldn't appear in the placement picker. This picker reads
18761
+ // ComponentManager, so drafts are found by their source package;
18762
+ // useInstalledWidgets' `kind` is checked too.
18763
+ if (widget.kind === "draft" || isDraftPackage(widget._sourcePackage)) {
18744
18764
  return false;
18745
18765
  }
18746
18766
 
@@ -64178,6 +64198,22 @@ var splitWords = function splitWords(s) {
64178
64198
  return String(s).replace(/([a-z])([A-Z0-9])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/([0-9])([A-Za-z])/g, "$1 $2");
64179
64199
  };
64180
64200
 
64201
+ /**
64202
+ * The sidebar's widgets: every widget component, by key — not Widget Builder
64203
+ * drafts, which live in Manage › Widgets.
64204
+ */
64205
+ function sidebarWidgets(componentMap) {
64206
+ var map = componentMap || {};
64207
+ return Object.keys(map).sort().filter(function (key) {
64208
+ return map[key] && map[key].type === "widget" && !isDraftPackage(map[key]._sourcePackage);
64209
+ }).map(function (key) {
64210
+ return {
64211
+ key: key,
64212
+ widget: map[key]
64213
+ };
64214
+ });
64215
+ }
64216
+
64181
64217
  /**
64182
64218
  * The title for a widget row: its displayName, else its own name (unless
64183
64219
  * that's the model default), else its component name as words.
@@ -64734,15 +64770,7 @@ var WidgetSidebar = function WidgetSidebar(_ref4) {
64734
64770
 
64735
64771
  // Flat list of all widgets
64736
64772
  var allWidgets = useMemo(function () {
64737
- var componentMap = ComponentManager.map();
64738
- return Object.keys(componentMap).sort().filter(function (key) {
64739
- return componentMap[key].type === "widget";
64740
- }).map(function (key) {
64741
- return {
64742
- key: key,
64743
- widget: componentMap[key]
64744
- };
64745
- });
64773
+ return sidebarWidgets(ComponentManager.map());
64746
64774
  }, [widgetVersion]);
64747
64775
 
64748
64776
  // Set of installed package identifiers for "Installed" badge in Discover tab.