@orion-ds/react 5.3.0 → 5.3.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.
@@ -1,98 +1,102 @@
1
1
  import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
- import oe, { useState as u, useRef as le } from "react";
3
- import { ChevronDown as R, MoreHorizontal as ie } from "lucide-react";
4
- import { MissingDependencyError as se } from "../MissingDependencyError.mjs";
2
+ import se, { useState as s, useRef as de, useEffect as ce } from "react";
3
+ import { ChevronDown as z, MoreHorizontal as me } from "lucide-react";
4
+ import { MissingDependencyError as pe } from "../MissingDependencyError.mjs";
5
+ import { checkComponent as fe } from "../../utils/optionalDeps.mjs";
5
6
  import r from "./CollapsibleFolder.module.css.mjs";
6
- import { Collapsible as v } from "../Collapsible/Collapsible.mjs";
7
- import { Badge as de } from "../Badge/Badge.mjs";
8
- import { Dropdown as w } from "../Dropdown/Dropdown.mjs";
9
- import { Button as z } from "../Button/Button.mjs";
10
- let A, O = null;
7
+ import { Collapsible as D } from "../Collapsible/Collapsible.mjs";
8
+ import { Badge as ge } from "../Badge/Badge.mjs";
9
+ import { Dropdown as A } from "../Dropdown/Dropdown.mjs";
10
+ import { Button as O } from "../Button/Button.mjs";
11
+ let B;
11
12
  try {
12
- A = require("@dnd-kit/core").useDroppable;
13
- } catch (l) {
14
- O = l instanceof Error ? l : new Error("@dnd-kit/core not found");
13
+ B = require("@dnd-kit/core").useDroppable;
14
+ } catch {
15
15
  }
16
- function ce(l) {
17
- if (O)
18
- return /* @__PURE__ */ t(
19
- se,
20
- {
21
- available: !1,
22
- componentName: "CollapsibleFolder",
23
- depName: ["@dnd-kit/core", "@dnd-kit/sortable", "@dnd-kit/utilities"],
24
- installCommand: "npm install @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities",
25
- pnpmCommand: "pnpm add @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities",
26
- docsUrl: "https://docs.orion-ds.dev/components/collapsible-folder"
27
- }
28
- );
16
+ function he(p) {
29
17
  const {
30
- id: p,
31
- title: B,
32
- itemCount: D,
18
+ id: f,
19
+ title: j,
20
+ itemCount: b,
33
21
  items: i,
34
- renderItem: j,
35
- itemLabel: K = "Item",
36
- itemLabelPlural: $ = "Items",
37
- emptyText: q = "No items in this folder",
38
- sortLabel: b = "Sort",
39
- defaultExpanded: M = !0,
22
+ renderItem: $,
23
+ itemLabel: q = "Item",
24
+ itemLabelPlural: K = "Items",
25
+ emptyText: M = "No items in this folder",
26
+ sortLabel: N = "Sort",
27
+ defaultExpanded: P = !0,
40
28
  sortOptions: d,
41
29
  selectedSort: Y,
42
30
  onSortChange: H,
43
- onDrop: N,
44
- onFolderEdit: C,
45
- onFolderDelete: k,
31
+ onDrop: C,
32
+ onFolderEdit: y,
33
+ onFolderDelete: I,
46
34
  onFolderInvite: T,
47
- isDropTarget: P = !1,
48
- isDropCompleted: U = !1,
49
- onDragEnter: Z,
35
+ isDropTarget: Z = !1,
36
+ isDropCompleted: G = !1,
37
+ onDragEnter: J,
50
38
  onDragLeaveFolder: x,
51
- className: G,
52
- ...J
53
- } = l, [g, Q] = u(M), [f, c] = u(null), [y, h] = u(!1), I = le(null), { setNodeRef: V } = A({ id: p }), W = (e) => {
54
- if (e.preventDefault(), e.dataTransfer.dropEffect = "move", y || (h(!0), Z?.()), !g || i.length === 0) {
39
+ className: Q,
40
+ ...U
41
+ } = p, [L, g] = s(), [V, W] = s(!0), [h, X] = s(P), [u, c] = s(null), [E, v] = s(!1), k = de(null), { setNodeRef: _ } = B({ id: f });
42
+ if (ce(() => {
43
+ (async () => {
44
+ try {
45
+ const n = fe("CollapsibleFolder");
46
+ n instanceof Promise ? g(await n) : g(n);
47
+ } catch {
48
+ g(void 0);
49
+ } finally {
50
+ W(!1);
51
+ }
52
+ })();
53
+ }, []), L)
54
+ return /* @__PURE__ */ t(pe, { ...L });
55
+ if (V)
56
+ return /* @__PURE__ */ t("div", { children: "Loading folder..." });
57
+ const ee = (e) => {
58
+ if (e.preventDefault(), e.dataTransfer.dropEffect = "move", E || (v(!0), J?.()), !h || i.length === 0) {
55
59
  c(0);
56
60
  return;
57
61
  }
58
- const n = I.current;
62
+ const n = k.current;
59
63
  if (!n) return;
60
64
  const o = Array.from(
61
65
  n.querySelectorAll("[data-item-id]")
62
- ), ae = e.clientY;
63
- let E = o.length;
66
+ ), le = e.clientY;
67
+ let S = o.length;
64
68
  for (let m = 0; m < o.length; m++) {
65
- const F = o[m];
66
- if (!F) continue;
67
- const S = F.getBoundingClientRect();
68
- if (ae < S.top + S.height / 2) {
69
- E = m;
69
+ const R = o[m];
70
+ if (!R) continue;
71
+ const w = R.getBoundingClientRect();
72
+ if (le < w.top + w.height / 2) {
73
+ S = m;
70
74
  break;
71
75
  }
72
76
  }
73
- c(E);
74
- }, X = (e) => {
75
- e.currentTarget.contains(e.relatedTarget) || (h(!1), c(null), x?.());
76
- }, _ = (e) => {
77
+ c(S);
78
+ }, te = (e) => {
79
+ e.currentTarget.contains(e.relatedTarget) || (v(!1), c(null), x?.());
80
+ }, re = (e) => {
77
81
  e.preventDefault();
78
82
  const n = e.dataTransfer.getData("text/plain") || e.dataTransfer.getData("itemId");
79
- if (n && N) {
80
- const o = f ?? i.length;
81
- N(n, p, o);
83
+ if (n && C) {
84
+ const o = u ?? i.length;
85
+ C(n, f, o);
82
86
  }
83
- h(!1), c(null), x?.();
84
- }, ee = (e, n) => {
87
+ v(!1), c(null), x?.();
88
+ }, ne = (e, n) => {
85
89
  e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", n);
86
- }, te = d?.map((e) => ({
90
+ }, ae = d?.map((e) => ({
87
91
  id: e.value,
88
92
  label: e.label,
89
93
  onClick: () => H?.(e.value)
90
- })), L = [
91
- ...C ? [
94
+ })), F = [
95
+ ...y ? [
92
96
  {
93
97
  id: "rename",
94
98
  label: "Rename",
95
- onClick: C
99
+ onClick: y
96
100
  }
97
101
  ] : [],
98
102
  ...T ? [
@@ -102,90 +106,90 @@ function ce(l) {
102
106
  onClick: T
103
107
  }
104
108
  ] : [],
105
- ...k ? [
109
+ ...I ? [
106
110
  {
107
111
  id: "delete",
108
112
  label: "Delete folder",
109
113
  danger: !0,
110
- onClick: k
114
+ onClick: I
111
115
  }
112
116
  ] : []
113
- ], s = P || y, re = [
117
+ ], l = Z || E, oe = [
114
118
  r.folder,
115
- s && r.dropTarget,
116
- U && r.dropCompleted,
117
- G
118
- ].filter(Boolean).join(" "), ne = D === 1 ? K : $;
119
+ l && r.dropTarget,
120
+ G && r.dropCompleted,
121
+ Q
122
+ ].filter(Boolean).join(" "), ie = b === 1 ? q : K;
119
123
  return /* @__PURE__ */ t(
120
124
  "div",
121
125
  {
122
- ref: V,
123
- className: re,
124
- "data-folder-id": p,
125
- "data-drop-active": s,
126
- onDragOver: W,
127
- onDragLeave: X,
128
- onDrop: _,
129
- ...J,
130
- children: /* @__PURE__ */ a(v, { open: g, onOpenChange: Q, children: [
126
+ ref: _,
127
+ className: oe,
128
+ "data-folder-id": f,
129
+ "data-drop-active": l,
130
+ onDragOver: ee,
131
+ onDragLeave: te,
132
+ onDrop: re,
133
+ ...U,
134
+ children: /* @__PURE__ */ a(D, { open: h, onOpenChange: X, children: [
131
135
  /* @__PURE__ */ a("div", { className: r.header, children: [
132
- /* @__PURE__ */ a(v.Trigger, { className: r.trigger, children: [
136
+ /* @__PURE__ */ a(D.Trigger, { className: r.trigger, children: [
133
137
  /* @__PURE__ */ t(
134
- R,
138
+ z,
135
139
  {
136
140
  size: 20,
137
- className: `${r.chevron} ${g ? r.expanded : ""}`
141
+ className: `${r.chevron} ${h ? r.expanded : ""}`
138
142
  }
139
143
  ),
140
- /* @__PURE__ */ t("h2", { className: r.title, children: B }),
141
- /* @__PURE__ */ a(de, { variant: "secondary", className: r.badge, children: [
142
- D,
144
+ /* @__PURE__ */ t("h2", { className: r.title, children: j }),
145
+ /* @__PURE__ */ a(ge, { variant: "secondary", className: r.badge, children: [
146
+ b,
143
147
  /* @__PURE__ */ a("span", { className: r.badgeLabel, children: [
144
148
  " ",
145
- ne
149
+ ie
146
150
  ] })
147
151
  ] })
148
152
  ] }),
149
153
  /* @__PURE__ */ a("div", { className: r.actions, children: [
150
154
  d && d.length > 0 && /* @__PURE__ */ t("div", { className: r.sortDropdown, children: /* @__PURE__ */ t(
151
- w,
155
+ A,
152
156
  {
153
157
  trigger: /* @__PURE__ */ t(
154
- z,
158
+ O,
155
159
  {
156
160
  variant: "ghost",
157
161
  size: "sm",
158
- iconRight: /* @__PURE__ */ t(R, { size: 16 }),
159
- "aria-label": `Sort by ${b}`,
160
- children: d.find((e) => e.value === Y)?.label || b
162
+ iconRight: /* @__PURE__ */ t(z, { size: 16 }),
163
+ "aria-label": `Sort by ${N}`,
164
+ children: d.find((e) => e.value === Y)?.label || N
161
165
  }
162
166
  ),
163
- items: te,
167
+ items: ae,
164
168
  placement: "bottom-end"
165
169
  }
166
170
  ) }),
167
- L.length > 0 && /* @__PURE__ */ t(
168
- w,
171
+ F.length > 0 && /* @__PURE__ */ t(
172
+ A,
169
173
  {
170
174
  trigger: /* @__PURE__ */ t(
171
- z,
175
+ O,
172
176
  {
173
177
  variant: "ghost",
174
178
  size: "sm",
175
179
  iconOnly: !0,
176
- icon: /* @__PURE__ */ t(ie, { size: 20 }),
180
+ icon: /* @__PURE__ */ t(me, { size: 20 }),
177
181
  "aria-label": "Folder actions"
178
182
  }
179
183
  ),
180
- items: L,
184
+ items: F,
181
185
  placement: "bottom-end"
182
186
  }
183
187
  )
184
188
  ] })
185
189
  ] }),
186
- /* @__PURE__ */ t(v.Content, { children: /* @__PURE__ */ t("div", { className: r.content, children: i.length === 0 ? s ? /* @__PURE__ */ t("div", { className: r.emptyDropZone, children: /* @__PURE__ */ t("div", { className: r.insertionLine, role: "presentation" }) }) : /* @__PURE__ */ t("div", { className: r.emptyState, children: /* @__PURE__ */ t("p", { className: r.emptyText, children: q }) }) : /* @__PURE__ */ a("div", { className: r.grid, ref: I, children: [
187
- i.map((e, n) => /* @__PURE__ */ a(oe.Fragment, { children: [
188
- s && f === n && /* @__PURE__ */ t(
190
+ /* @__PURE__ */ t(D.Content, { children: /* @__PURE__ */ t("div", { className: r.content, children: i.length === 0 ? l ? /* @__PURE__ */ t("div", { className: r.emptyDropZone, children: /* @__PURE__ */ t("div", { className: r.insertionLine, role: "presentation" }) }) : /* @__PURE__ */ t("div", { className: r.emptyState, children: /* @__PURE__ */ t("p", { className: r.emptyText, children: M }) }) : /* @__PURE__ */ a("div", { className: r.grid, ref: k, children: [
191
+ i.map((e, n) => /* @__PURE__ */ a(se.Fragment, { children: [
192
+ l && u === n && /* @__PURE__ */ t(
189
193
  "div",
190
194
  {
191
195
  className: r.insertionLine,
@@ -197,18 +201,18 @@ function ce(l) {
197
201
  {
198
202
  "data-item-id": e.id,
199
203
  draggable: e.draggable,
200
- onDragStart: (o) => ee(o, e.id),
201
- children: j(e, n)
204
+ onDragStart: (o) => ne(o, e.id),
205
+ children: $(e, n)
202
206
  }
203
207
  )
204
208
  ] }, e.id)),
205
- s && f === i.length && /* @__PURE__ */ t("div", { className: r.insertionLine, role: "presentation" })
209
+ l && u === i.length && /* @__PURE__ */ t("div", { className: r.insertionLine, role: "presentation" })
206
210
  ] }) }) })
207
211
  ] })
208
212
  }
209
213
  );
210
214
  }
211
- ce.displayName = "CollapsibleFolder";
215
+ he.displayName = "CollapsibleFolder";
212
216
  export {
213
- ce as CollapsibleFolder
217
+ he as CollapsibleFolder
214
218
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),d=require("react"),F=require("lucide-react"),M=require("../MissingDependencyError.cjs"),l=require("./DatePicker.module.css.cjs"),j=require("../Calendar/Calendar.cjs"),O=require("../Popover/Popover.cjs"),R=require("../Button/Button.cjs");let o,v=null;try{o=require("date-fns").format}catch(e){v=e instanceof Error?e:new Error("date-fns not found")}const x=e=>{if(v)return t.jsx(M.MissingDependencyError,{available:!1,componentName:"DatePicker",depName:"date-fns",installCommand:"npm install date-fns",pnpmCommand:"pnpm add date-fns",docsUrl:"https://docs.orion-ds.dev/components/date-picker"});const{mode:n="single",min:C,max:b,disabledDates:P,placeholder:u="Pick a date",presets:i,format:r="PPP",disabled:S=!1,triggerClassName:N,className:k}=e,[D,c]=d.useState(!1),f=d.useMemo(()=>n==="single"&&e.mode!=="range"?e.selected?o(e.selected,r):null:n==="range"&&e.mode==="range"&&e.selected?.from?e.selected.to?`${o(e.selected.from,r)} - ${o(e.selected.to,r)}`:o(e.selected.from,r):null,[n,e,r]),g=d.useCallback(a=>{if(n==="single"&&e.mode!=="range"){const s=e.onSelect;s?.(a),c(!1)}else if(n==="range"&&e.mode==="range"){const s=e.onSelect,m=a;s?.(m),m?.from&&m?.to&&c(!1)}},[n,e]),q=d.useCallback(a=>{if(n==="single"&&e.mode!=="range"){const s=e.onSelect;s?.(a.value)}else if(n==="range"&&e.mode==="range"){const s=e.onSelect;s?.(a.value)}c(!1)},[n,e]),y=[l.default.trigger,N].filter(Boolean).join(" "),w=[l.default.wrapper,k].filter(Boolean).join(" "),h={min:C,max:b,disabled:P},B=t.jsxs("div",{className:l.default.popoverContent,children:[i&&i.length>0&&t.jsx("div",{className:l.default.presets,children:i.map(a=>t.jsx("button",{type:"button",className:l.default.presetButton,onClick:()=>q(a),children:a.label},a.label))}),n==="single"?t.jsx(j.Calendar,{mode:"single",selected:e.mode!=="range"?e.selected:void 0,onSelect:g,...h}):t.jsx(j.Calendar,{mode:"range",selected:e.mode==="range"?e.selected:void 0,onSelect:g,...h})]}),E=t.jsx(R.Button,{variant:"secondary",className:y,disabled:S,"aria-label":u,icon:t.jsx(F.Calendar,{size:16,className:l.default.triggerIcon}),children:f?t.jsx("span",{children:f}):t.jsx("span",{className:l.default.placeholder,children:u})});return t.jsx("div",{className:w,children:t.jsx(O.Popover,{trigger:E,content:B,placement:"bottom-start",open:D,onOpenChange:c,showArrow:!1,offset:4,className:l.default.popover})})};x.displayName="DatePicker";exports.DatePicker=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("react"),R=require("lucide-react"),I=require("../MissingDependencyError.cjs"),T=require("../../utils/optionalDeps.cjs"),l=require("./DatePicker.module.css.cjs"),C=require("../Calendar/Calendar.cjs"),$=require("../Popover/Popover.cjs"),z=require("../Button/Button.cjs");let o;try{o=require("date-fns").format}catch{}const S=e=>{const{mode:a="single",min:k,max:v,disabledDates:P,placeholder:m="Pick a date",presets:d,format:c="PPP",disabled:b=!1,triggerClassName:D,className:y}=e,[g,u]=r.useState(),[N,q]=r.useState(!0),[w,i]=r.useState(!1),h=r.useMemo(()=>a==="single"&&e.mode!=="range"?e.selected?o(e.selected,c):null:a==="range"&&e.mode==="range"&&e.selected?.from?e.selected.to?`${o(e.selected.from,c)} - ${o(e.selected.to,c)}`:o(e.selected.from,c):null,[a,e,c]),j=r.useCallback(s=>{if(a==="single"&&e.mode!=="range"){const n=e.onSelect;n?.(s),i(!1)}else if(a==="range"&&e.mode==="range"){const n=e.onSelect,f=s;n?.(f),f?.from&&f?.to&&i(!1)}},[a,e]),B=r.useCallback(s=>{if(a==="single"&&e.mode!=="range"){const n=e.onSelect;n?.(s.value)}else if(a==="range"&&e.mode==="range"){const n=e.onSelect;n?.(s.value)}i(!1)},[a,e]);if(r.useEffect(()=>{(async()=>{try{const n=T.checkComponent("DatePicker");n instanceof Promise?u(await n):u(n)}catch{u(void 0)}finally{q(!1)}})()},[]),g)return t.jsx(I.MissingDependencyError,{...g});if(N)return t.jsx("div",{children:"Loading date picker..."});const E=[l.default.trigger,D].filter(Boolean).join(" "),M=[l.default.wrapper,y].filter(Boolean).join(" "),x={min:k,max:v,disabled:P},F=t.jsxs("div",{className:l.default.popoverContent,children:[d&&d.length>0&&t.jsx("div",{className:l.default.presets,children:d.map(s=>t.jsx("button",{type:"button",className:l.default.presetButton,onClick:()=>B(s),children:s.label},s.label))}),a==="single"?t.jsx(C.Calendar,{mode:"single",selected:e.mode!=="range"?e.selected:void 0,onSelect:j,...x}):t.jsx(C.Calendar,{mode:"range",selected:e.mode==="range"?e.selected:void 0,onSelect:j,...x})]}),O=t.jsx(z.Button,{variant:"secondary",className:E,disabled:b,"aria-label":m,icon:t.jsx(R.Calendar,{size:16,className:l.default.triggerIcon}),children:h?t.jsx("span",{children:h}):t.jsx("span",{className:l.default.placeholder,children:m})});return t.jsx("div",{className:M,children:t.jsx($.Popover,{trigger:O,content:F,placement:"bottom-start",open:w,onOpenChange:i,showArrow:!1,offset:4,className:l.default.popover})})};S.displayName="DatePicker";exports.DatePicker=S;
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAyC,MAAM,OAAO,CAAC;AAO9D,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,oBAAoB,CAAC;AAe5E,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAsKhD,CAAC"}
1
+ {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAoD,MAAM,OAAO,CAAC;AAWzE,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,oBAAoB,CAAC;AAc5E,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA0LhD,CAAC"}
@@ -1,114 +1,118 @@
1
- import { jsxs as F, jsx as n } from "react/jsx-runtime";
2
- import { useState as $, useMemo as M, useCallback as h } from "react";
3
- import { Calendar as O } from "lucide-react";
4
- import { MissingDependencyError as q } from "../MissingDependencyError.mjs";
1
+ import { jsx as n, jsxs as O } from "react/jsx-runtime";
2
+ import { useState as f, useMemo as q, useCallback as k, useEffect as z } from "react";
3
+ import { Calendar as A } from "lucide-react";
4
+ import { MissingDependencyError as L } from "../MissingDependencyError.mjs";
5
+ import { checkComponent as T } from "../../utils/optionalDeps.mjs";
5
6
  import l from "./DatePicker.module.css.mjs";
6
- import { Calendar as v } from "../Calendar/Calendar.mjs";
7
- import { Popover as z } from "../Popover/Popover.mjs";
8
- import { Button as A } from "../Button/Button.mjs";
9
- let s, C = null;
7
+ import { Calendar as S } from "../Calendar/Calendar.mjs";
8
+ import { Popover as G } from "../Popover/Popover.mjs";
9
+ import { Button as H } from "../Button/Button.mjs";
10
+ let s;
10
11
  try {
11
12
  s = require("date-fns").format;
12
- } catch (e) {
13
- C = e instanceof Error ? e : new Error("date-fns not found");
13
+ } catch {
14
14
  }
15
- const I = (e) => {
16
- if (C)
17
- return /* @__PURE__ */ n(
18
- q,
19
- {
20
- available: !1,
21
- componentName: "DatePicker",
22
- depName: "date-fns",
23
- installCommand: "npm install date-fns",
24
- pnpmCommand: "pnpm add date-fns",
25
- docsUrl: "https://docs.orion-ds.dev/components/date-picker"
26
- }
27
- );
15
+ const J = (e) => {
28
16
  const {
29
- mode: t = "single",
17
+ mode: a = "single",
30
18
  min: N,
31
- max: S,
19
+ max: P,
32
20
  disabledDates: b,
33
- placeholder: m = "Pick a date",
34
- presets: d,
35
- format: r = "PPP",
36
- disabled: P = !1,
37
- triggerClassName: k,
38
- className: y
39
- } = e, [D, c] = $(!1), f = M(() => t === "single" && e.mode !== "range" ? e.selected ? s(e.selected, r) : null : t === "range" && e.mode === "range" && e.selected?.from ? e.selected.to ? `${s(e.selected.from, r)} - ${s(e.selected.to, r)}` : s(e.selected.from, r) : null, [t, e, r]), g = h(
40
- (a) => {
41
- if (t === "single" && e.mode !== "range") {
42
- const o = e.onSelect;
43
- o?.(a), c(!1);
44
- } else if (t === "range" && e.mode === "range") {
45
- const o = e.onSelect, i = a;
46
- o?.(i), i?.from && i?.to && c(!1);
21
+ placeholder: g = "Pick a date",
22
+ presets: i,
23
+ format: o = "PPP",
24
+ disabled: y = !1,
25
+ triggerClassName: D,
26
+ className: w
27
+ } = e, [u, d] = f(), [x, j] = f(!0), [B, c] = f(!1), h = q(() => a === "single" && e.mode !== "range" ? e.selected ? s(e.selected, o) : null : a === "range" && e.mode === "range" && e.selected?.from ? e.selected.to ? `${s(e.selected.from, o)} - ${s(e.selected.to, o)}` : s(e.selected.from, o) : null, [a, e, o]), C = k(
28
+ (r) => {
29
+ if (a === "single" && e.mode !== "range") {
30
+ const t = e.onSelect;
31
+ t?.(r), c(!1);
32
+ } else if (a === "range" && e.mode === "range") {
33
+ const t = e.onSelect, m = r;
34
+ t?.(m), m?.from && m?.to && c(!1);
47
35
  }
48
36
  },
49
- [t, e]
50
- ), w = h(
51
- (a) => {
52
- if (t === "single" && e.mode !== "range") {
53
- const o = e.onSelect;
54
- o?.(a.value);
55
- } else if (t === "range" && e.mode === "range") {
56
- const o = e.onSelect;
57
- o?.(a.value);
37
+ [a, e]
38
+ ), E = k(
39
+ (r) => {
40
+ if (a === "single" && e.mode !== "range") {
41
+ const t = e.onSelect;
42
+ t?.(r.value);
43
+ } else if (a === "range" && e.mode === "range") {
44
+ const t = e.onSelect;
45
+ t?.(r.value);
58
46
  }
59
47
  c(!1);
60
48
  },
61
- [t, e]
62
- ), x = [l.trigger, k].filter(Boolean).join(" "), j = [l.wrapper, y].filter(Boolean).join(" "), u = {
49
+ [a, e]
50
+ );
51
+ if (z(() => {
52
+ (async () => {
53
+ try {
54
+ const t = T("DatePicker");
55
+ t instanceof Promise ? d(await t) : d(t);
56
+ } catch {
57
+ d(void 0);
58
+ } finally {
59
+ j(!1);
60
+ }
61
+ })();
62
+ }, []), u)
63
+ return /* @__PURE__ */ n(L, { ...u });
64
+ if (x)
65
+ return /* @__PURE__ */ n("div", { children: "Loading date picker..." });
66
+ const F = [l.trigger, D].filter(Boolean).join(" "), $ = [l.wrapper, w].filter(Boolean).join(" "), v = {
63
67
  min: N,
64
- max: S,
68
+ max: P,
65
69
  disabled: b
66
- }, B = /* @__PURE__ */ F("div", { className: l.popoverContent, children: [
67
- d && d.length > 0 && /* @__PURE__ */ n("div", { className: l.presets, children: d.map((a) => /* @__PURE__ */ n(
70
+ }, I = /* @__PURE__ */ O("div", { className: l.popoverContent, children: [
71
+ i && i.length > 0 && /* @__PURE__ */ n("div", { className: l.presets, children: i.map((r) => /* @__PURE__ */ n(
68
72
  "button",
69
73
  {
70
74
  type: "button",
71
75
  className: l.presetButton,
72
- onClick: () => w(a),
73
- children: a.label
76
+ onClick: () => E(r),
77
+ children: r.label
74
78
  },
75
- a.label
79
+ r.label
76
80
  )) }),
77
- t === "single" ? /* @__PURE__ */ n(
78
- v,
81
+ a === "single" ? /* @__PURE__ */ n(
82
+ S,
79
83
  {
80
84
  mode: "single",
81
85
  selected: e.mode !== "range" ? e.selected : void 0,
82
- onSelect: g,
83
- ...u
86
+ onSelect: C,
87
+ ...v
84
88
  }
85
89
  ) : /* @__PURE__ */ n(
86
- v,
90
+ S,
87
91
  {
88
92
  mode: "range",
89
93
  selected: e.mode === "range" ? e.selected : void 0,
90
- onSelect: g,
91
- ...u
94
+ onSelect: C,
95
+ ...v
92
96
  }
93
97
  )
94
- ] }), E = /* @__PURE__ */ n(
95
- A,
98
+ ] }), M = /* @__PURE__ */ n(
99
+ H,
96
100
  {
97
101
  variant: "secondary",
98
- className: x,
99
- disabled: P,
100
- "aria-label": m,
101
- icon: /* @__PURE__ */ n(O, { size: 16, className: l.triggerIcon }),
102
- children: f ? /* @__PURE__ */ n("span", { children: f }) : /* @__PURE__ */ n("span", { className: l.placeholder, children: m })
102
+ className: F,
103
+ disabled: y,
104
+ "aria-label": g,
105
+ icon: /* @__PURE__ */ n(A, { size: 16, className: l.triggerIcon }),
106
+ children: h ? /* @__PURE__ */ n("span", { children: h }) : /* @__PURE__ */ n("span", { className: l.placeholder, children: g })
103
107
  }
104
108
  );
105
- return /* @__PURE__ */ n("div", { className: j, children: /* @__PURE__ */ n(
106
- z,
109
+ return /* @__PURE__ */ n("div", { className: $, children: /* @__PURE__ */ n(
110
+ G,
107
111
  {
108
- trigger: E,
109
- content: B,
112
+ trigger: M,
113
+ content: I,
110
114
  placement: "bottom-start",
111
- open: D,
115
+ open: B,
112
116
  onOpenChange: c,
113
117
  showArrow: !1,
114
118
  offset: 4,
@@ -116,7 +120,7 @@ const I = (e) => {
116
120
  }
117
121
  ) });
118
122
  };
119
- I.displayName = "DatePicker";
123
+ J.displayName = "DatePicker";
120
124
  export {
121
- I as DatePicker
125
+ J as DatePicker
122
126
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(o){return(Array.isArray(o)?o:[o]).every(r=>{try{return require(r),!0}catch{return!1}})}function s(o,e,r){const n=(Array.isArray(e)?e:[e]).join(" ");return{available:a(e),componentName:o,depName:e,installCommand:`npm install ${n}`,pnpmCommand:`pnpm add ${n}`,docsUrl:r}}const d={Chart:{depName:"recharts",docsUrl:"https://docs.orion-ds.dev/components/chart"},Calendar:{depName:"date-fns",docsUrl:"https://docs.orion-ds.dev/components/calendar"},DatePicker:{depName:"date-fns",docsUrl:"https://docs.orion-ds.dev/components/date-picker"},CodeEditor:{depName:"react-syntax-highlighter",docsUrl:"https://docs.orion-ds.dev/components/code-editor"},Chat:{depName:["react-markdown","remark-gfm"],docsUrl:"https://docs.orion-ds.dev/components/chat"},CollapsibleFolder:{depName:["@dnd-kit/core","@dnd-kit/sortable","@dnd-kit/utilities"],docsUrl:"https://docs.orion-ds.dev/components/collapsible-folder"}};function c(o){const e=d[o],r=Array.isArray(e.depName)?[...e.depName]:e.depName,t=s(o,r,e.docsUrl);return t.available?void 0:t}exports.OPTIONAL_DEP_COMPONENTS=d;exports.checkComponent=c;exports.getOptionalDepError=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=new Map,a=new Map;async function d(t){const e=Array.isArray(t)?t:[t];return(await Promise.all(e.map(async r=>{if(o.has(r))return o.get(r)??!1;if(a.has(r))return a.get(r);const n=(async()=>{try{return await import(r),o.set(r,!0),!0}catch{return o.set(r,!1),!1}})();a.set(r,n);const c=await n;return a.delete(r),c}))).every(Boolean)}function p(t){return(Array.isArray(t)?t:[t]).every(s=>o.has(s)?o.get(s)??!1:!0)}async function i(t,e,s){const n=(Array.isArray(e)?e:[e]).join(" ");return{available:await d(e),componentName:t,depName:e,installCommand:`npm install ${n}`,pnpmCommand:`pnpm add ${n}`,docsUrl:s}}const l={Chart:{depName:"recharts",docsUrl:"https://docs.orion-ds.dev/components/chart"},Calendar:{depName:"date-fns",docsUrl:"https://docs.orion-ds.dev/components/calendar"},DatePicker:{depName:"date-fns",docsUrl:"https://docs.orion-ds.dev/components/date-picker"},CodeEditor:{depName:"react-syntax-highlighter",docsUrl:"https://docs.orion-ds.dev/components/code-editor"},Chat:{depName:["react-markdown","remark-gfm"],docsUrl:"https://docs.orion-ds.dev/components/chat"},CollapsibleFolder:{depName:["@dnd-kit/core","@dnd-kit/sortable","@dnd-kit/utilities"],docsUrl:"https://docs.orion-ds.dev/components/collapsible-folder"}};function u(t){const e=l[t],s=Array.isArray(e.depName)?[...e.depName]:e.depName;if(!p(s))return i(t,s,e.docsUrl).then(n=>n.available?void 0:n)}exports.OPTIONAL_DEP_COMPONENTS=l;exports.checkComponent=u;exports.getOptionalDepError=i;
@@ -1,9 +1,14 @@
1
1
  /**
2
- * Optional Dependency Error Handling
2
+ * Optional Dependency Error Handling (ESM-Safe v5.3.1+)
3
3
  *
4
4
  * Provides helpful error messages when users try to use components
5
5
  * that require optional peer dependencies (recharts, date-fns, etc.)
6
6
  * without having them installed.
7
+ *
8
+ * Uses async import() instead of require() for ESM spec compliance.
9
+ * Results are cached for performance (cache hit = O(1) lookup).
10
+ *
11
+ * @see V5_3_0_ESM_REQUIRE_BUG_ANALYSIS.md for RCA of v5.3.0 regression
7
12
  */
8
13
  /**
9
14
  * Metadata for an optional dependency error
@@ -17,13 +22,14 @@ export interface OptionalDepError {
17
22
  docsUrl: string;
18
23
  }
19
24
  /**
20
- * Get error information for a missing optional dependency
25
+ * Get error information for a missing optional dependency (async)
26
+ *
21
27
  * @param componentName - Name of the Orion component
22
28
  * @param depName - NPM package name or array of package names
23
29
  * @param docsUrl - URL to component documentation
24
- * @returns OptionalDepError with installation instructions
30
+ * @returns Promise<OptionalDepError> with installation instructions
25
31
  */
26
- export declare function getOptionalDepError(componentName: string, depName: string | string[], docsUrl: string): OptionalDepError;
32
+ export declare function getOptionalDepError(componentName: string, depName: string | string[], docsUrl: string): Promise<OptionalDepError>;
27
33
  /**
28
34
  * Registry of all optional-dependency components
29
35
  * Used to validate component registrations
@@ -56,8 +62,20 @@ export declare const OPTIONAL_DEP_COMPONENTS: {
56
62
  };
57
63
  /**
58
64
  * Type-safe way to get optional dependency info
65
+ *
66
+ * Returns synchronously if result is cached (dependency already checked).
67
+ * Returns Promise if result needs async validation.
68
+ *
59
69
  * @param componentName - One of the optional-dependency component names
60
- * @returns Error info if dependency is missing, undefined if available
70
+ * @returns Error info if dependency is missing, undefined if available,
71
+ * or Promise for async validation
72
+ *
73
+ * @example
74
+ * // Sync usage (cache hit or assumed available)
75
+ * const error = checkComponent('Calendar');
76
+ * if (error instanceof Promise) {
77
+ * const resolvedError = await error;
78
+ * }
61
79
  */
62
- export declare function checkComponent(componentName: keyof typeof OPTIONAL_DEP_COMPONENTS): OptionalDepError | undefined;
80
+ export declare function checkComponent(componentName: keyof typeof OPTIONAL_DEP_COMPONENTS): OptionalDepError | Promise<OptionalDepError | undefined> | undefined;
63
81
  //# sourceMappingURL=optionalDeps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"optionalDeps.d.ts","sourceRoot":"","sources":["../../src/utils/optionalDeps.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAmBD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,OAAO,EAAE,MAAM,GACd,gBAAgB,CAYlB;AAGD;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;CAyB1B,CAAC;AAEX;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,aAAa,EAAE,MAAM,OAAO,uBAAuB,GAClD,gBAAgB,GAAG,SAAS,CAS9B"}
1
+ {"version":3,"file":"optionalDeps.d.ts","sourceRoot":"","sources":["../../src/utils/optionalDeps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAyFD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,CAAC,CAa3B;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;CAyB1B,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAC5B,aAAa,EAAE,MAAM,OAAO,uBAAuB,GAClD,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,GAAG,SAAS,CAiBtE"}