@still-forest/canopy 0.28.2 → 0.29.0

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.
@@ -0,0 +1,330 @@
1
+ import { jsx as e, jsxs as u } from "react/jsx-runtime";
2
+ import { Flex as m, Grid as L } from "@/layout";
3
+ import { cn as h } from "@/utils";
4
+ import { Button as w } from "@/components/ui/button";
5
+ import { Trash2 as k, Send as v, Save as F, Loader as G, Calendar as D, Check as E, ChevronsUpDown as j } from "lucide-react";
6
+ import { Button as C, Label as f, TextInput as P, InputError as b, InputGroup as z } from "@/forms";
7
+ import { useState as I, useEffect as O, useMemo as R } from "react";
8
+ import { Checkbox as V } from "@/components/ui/checkbox";
9
+ import { Calendar as M } from "@/components/ui/calendar";
10
+ import { Popover as y, PopoverTrigger as T, PopoverContent as $ } from "@/components/ui/popover";
11
+ import { Text as x } from "@/typography";
12
+ import { Label as U } from "@/components/ui/label";
13
+ import { TextInput as _ } from "@/forms/TextInput";
14
+ import { RadioGroup as A, RadioGroupItem as X } from "@/components/ui/radio-group";
15
+ import { Select as Y, SelectTrigger as q, SelectValue as H, SelectContent as J, SelectItem as K } from "@/components/ui/select";
16
+ import { Command as Q, CommandInput as W, CommandList as Z, CommandEmpty as ee, CommandGroup as te, CommandItem as ae } from "@/components/ui/command";
17
+ import { Textarea as re } from "@/components/ui/textarea";
18
+ import { Input as ne } from "@/components/ui/input";
19
+ const le = ({
20
+ children: t,
21
+ onClick: a,
22
+ variant: r = "default",
23
+ size: n = "default",
24
+ icon: l,
25
+ disabled: s = !1,
26
+ className: o = "",
27
+ type: c = "button",
28
+ asChild: d = !1,
29
+ full: i = !1,
30
+ fit: p = !1,
31
+ ...g
32
+ }) => {
33
+ const S = () => r === "primary" ? "default" : r === "subtle" ? "secondary" : r, B = () => n === "md" ? "default" : n === "xs" ? "sm" : r === "unstyled" ? "unstyled" : n;
34
+ return /* @__PURE__ */ e(
35
+ w,
36
+ {
37
+ asChild: d,
38
+ className: h(o, p && "w-fit", i && "w-full", r === "unstyled" && "justify-start"),
39
+ disabled: s,
40
+ onClick: a,
41
+ size: B(),
42
+ type: c,
43
+ variant: S(),
44
+ ...g,
45
+ children: l && t ? /* @__PURE__ */ u(m, { align: "center", gap: "2", children: [
46
+ /* @__PURE__ */ e("span", { children: l }, "icon"),
47
+ /* @__PURE__ */ e("span", { children: t }, "children")
48
+ ] }) : l || t
49
+ }
50
+ );
51
+ }, se = ({ children: t, className: a = "" }) => /* @__PURE__ */ e(m, { className: a, children: t });
52
+ se.Button = ({ children: t, className: a, ...r }) => /* @__PURE__ */ e(le, { className: h("not-first:-ml-1 not-last:rounded-r-none not-first:rounded-l-none", a), ...r, children: t });
53
+ const Te = ({ disabled: t = !1, handleDelete: a, ...r }) => /* @__PURE__ */ e(
54
+ C,
55
+ {
56
+ disabled: t,
57
+ icon: /* @__PURE__ */ e(k, {}),
58
+ onClick: a,
59
+ variant: "outline",
60
+ ...r,
61
+ className: "border-destructive text-destructive hover:bg-destructive hover:text-white",
62
+ children: "Delete"
63
+ }
64
+ ), N = {
65
+ default: { label: "Submit", submittingLabel: "Submitting", IconComponent: v },
66
+ submit: { label: "Submit", submittingLabel: "Submitting", IconComponent: v },
67
+ save: { label: "Save", submittingLabel: "Saving", IconComponent: F },
68
+ send: { label: "Send", submittingLabel: "Sending", IconComponent: v }
69
+ }, $e = ({
70
+ submitting: t = !1,
71
+ disabled: a = !1,
72
+ submittingIcon: r,
73
+ action: n = "default",
74
+ noIcon: l = !1,
75
+ ...s
76
+ }) => {
77
+ const o = r || G;
78
+ if (!N[n])
79
+ throw new Error(`Invalid action: ${n}`);
80
+ const { label: c, submittingLabel: d, IconComponent: i } = N[n];
81
+ return /* @__PURE__ */ e(
82
+ C,
83
+ {
84
+ disabled: a || t,
85
+ icon: l ? void 0 : t ? /* @__PURE__ */ e(o, { className: "animate-spin" }) : /* @__PURE__ */ e(i, {}),
86
+ type: "submit",
87
+ variant: "primary",
88
+ ...s,
89
+ children: t ? d : c
90
+ }
91
+ );
92
+ }, Be = ({ label: t, name: a, value: r, checked: n, onCheckedChange: l }) => {
93
+ const [s, o] = I(n);
94
+ O(() => {
95
+ o(n);
96
+ }, [n]);
97
+ let c = a;
98
+ const d = r || a;
99
+ return r && (c += `[${r}]`), /* @__PURE__ */ u(m, { align: "center", gap: "2", children: [
100
+ /* @__PURE__ */ e(
101
+ V,
102
+ {
103
+ checked: s,
104
+ id: c,
105
+ name: a,
106
+ onCheckedChange: (p) => {
107
+ o(p), l?.(p);
108
+ },
109
+ value: d
110
+ }
111
+ ),
112
+ /* @__PURE__ */ e(f, { className: "cursor-pointer", htmlFor: c, children: t })
113
+ ] });
114
+ }, Le = ({ name: t, label: a, placeholder: r, note: n, className: l, ...s }) => /* @__PURE__ */ e(
115
+ P,
116
+ {
117
+ className: h("max-w-[150px]", l),
118
+ label: a,
119
+ name: t,
120
+ note: n,
121
+ placeholder: r,
122
+ type: "date",
123
+ ...s
124
+ }
125
+ ), ke = ({ onDateSelection: t, initialValue: a, className: r, size: n = "default", error: l }) => {
126
+ const [s, o] = I(a), c = (d) => {
127
+ o(d), d && t(d);
128
+ };
129
+ return /* @__PURE__ */ u(m, { direction: "col", gap: "2", children: [
130
+ /* @__PURE__ */ u(y, { children: [
131
+ /* @__PURE__ */ e(T, { asChild: !0, children: /* @__PURE__ */ u(
132
+ C,
133
+ {
134
+ className: h("w-[280px] justify-start text-left font-normal", !s && "text-muted-foreground", r),
135
+ size: n,
136
+ variant: "outline",
137
+ children: [
138
+ /* @__PURE__ */ e(D, { className: "mr-2 h-4 w-4" }),
139
+ s ? s.toISOString().split("T")[0] : /* @__PURE__ */ e("span", { children: "Select a date" })
140
+ ]
141
+ }
142
+ ) }),
143
+ /* @__PURE__ */ e($, { className: "w-auto p-0", children: /* @__PURE__ */ e(M, { autoFocus: !0, mode: "single", onSelect: c, selected: s }) })
144
+ ] }),
145
+ l && /* @__PURE__ */ e(b, { message: l })
146
+ ] });
147
+ }, Fe = ({ message: t }) => /* @__PURE__ */ e(x, { size: "xs", variant: "destructive", children: t }), Ge = ({ label: t, labelFor: a, className: r = "", labelClassName: n = "", children: l }) => /* @__PURE__ */ u(m, { direction: "col", gap: "2", children: [
148
+ t && /* @__PURE__ */ e(f, { className: n, htmlFor: a, children: t }),
149
+ /* @__PURE__ */ e(m, { className: `rounded-md border border-input bg-card p-2 shadow-xs ${r}`, gapY: "1", children: l })
150
+ ] }), De = ({ htmlFor: t, value: a, children: r, className: n = "", ...l }) => /* @__PURE__ */ e(
151
+ U,
152
+ {
153
+ className: h("font-display font-normal text-base text-foreground", n),
154
+ htmlFor: t,
155
+ ...l,
156
+ children: a || r
157
+ }
158
+ ), Ee = ({
159
+ name: t,
160
+ label: a,
161
+ placeholder: r,
162
+ note: n,
163
+ // Default to two decimal places for currency and general decimal values
164
+ step: l = ".01",
165
+ className: s,
166
+ ...o
167
+ }) => /* @__PURE__ */ e(
168
+ _,
169
+ {
170
+ className: s,
171
+ label: a,
172
+ name: t,
173
+ note: n,
174
+ placeholder: r,
175
+ step: l,
176
+ type: "number",
177
+ ...o
178
+ }
179
+ ), je = ({ label: t, name: a, options: r, value: n, onChange: l, error: s }) => /* @__PURE__ */ u(z, { className: "flex flex-col gap-4 px-2 py-1", label: t, labelFor: a, children: [
180
+ /* @__PURE__ */ e(A, { className: "w-full", name: a, onValueChange: l, value: n, children: /* @__PURE__ */ e(L, { cols: "2", children: r.map((o, c) => /* @__PURE__ */ u(m, { align: "center", gap: "2", justify: "start", children: [
181
+ /* @__PURE__ */ e(X, { id: o.value, value: o.value }),
182
+ /* @__PURE__ */ e(f, { htmlFor: o.value, children: o.label })
183
+ ] }, c)) }) }),
184
+ s && /* @__PURE__ */ e(b, { message: s })
185
+ ] }), Pe = ({
186
+ name: t,
187
+ defaultValue: a,
188
+ options: r,
189
+ label: n,
190
+ placeholder: l,
191
+ note: s,
192
+ className: o,
193
+ value: c,
194
+ onValueChange: d,
195
+ error: i,
196
+ ...p
197
+ }) => /* @__PURE__ */ u(m, { className: "w-full", direction: "col", gap: "2", children: [
198
+ n && /* @__PURE__ */ e(f, { htmlFor: t, children: n }),
199
+ /* @__PURE__ */ u(
200
+ Y,
201
+ {
202
+ defaultValue: a,
203
+ name: t,
204
+ onValueChange: d,
205
+ value: c,
206
+ ...p,
207
+ children: [
208
+ /* @__PURE__ */ e(q, { className: h("min-w-[180px]", o), "data-testid": `select-input-${t}`, children: /* @__PURE__ */ e(H, { placeholder: l }) }),
209
+ /* @__PURE__ */ e(J, { children: r.map(({ value: g, label: S }) => /* @__PURE__ */ e(K, { value: g, children: S }, `option-${g}`)) })
210
+ ]
211
+ }
212
+ ),
213
+ s && /* @__PURE__ */ e(x, { size: "sm", variant: "muted", children: s }),
214
+ i && /* @__PURE__ */ e(b, { message: i })
215
+ ] }), oe = ({
216
+ placeholder: t,
217
+ selected: a,
218
+ className: r,
219
+ open: n,
220
+ renderSelected: l = (s) => s.label
221
+ }) => /* @__PURE__ */ e(T, { asChild: !0, children: /* @__PURE__ */ u(w, { "aria-expanded": n, className: `justify-between ${r}`, role: "combobox", variant: "outline", children: [
222
+ l(a || { label: t, value: "" }),
223
+ /* @__PURE__ */ e(j, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
224
+ ] }) }), ze = ({
225
+ options: t,
226
+ value: a = "",
227
+ placeholder: r = "Select a value...",
228
+ className: n = "",
229
+ onSelect: l = () => {
230
+ },
231
+ renderSelected: s = (o) => o.label
232
+ }) => {
233
+ const [o, c] = I(!1), d = R(() => t.find((i) => i.value === a), [t, a]);
234
+ return /* @__PURE__ */ u(y, { onOpenChange: c, open: o, children: [
235
+ /* @__PURE__ */ e(
236
+ oe,
237
+ {
238
+ className: `w-full ${n}`,
239
+ open: o,
240
+ placeholder: r,
241
+ renderSelected: s,
242
+ selected: d
243
+ }
244
+ ),
245
+ /* @__PURE__ */ e($, { className: "w-full p-0", children: /* @__PURE__ */ u(Q, { value: a, children: [
246
+ /* @__PURE__ */ e(W, { "aria-label": "Search options", className: "h-9", placeholder: "Search" }),
247
+ /* @__PURE__ */ u(Z, { children: [
248
+ /* @__PURE__ */ e(ee, { children: "No results found" }),
249
+ /* @__PURE__ */ e(te, { children: t.map((i) => /* @__PURE__ */ u(
250
+ ae,
251
+ {
252
+ onSelect: () => {
253
+ c(!1), l(i.value);
254
+ },
255
+ value: i.value,
256
+ children: [
257
+ i.icon ? /* @__PURE__ */ e("span", { className: "mr-2", children: i.icon }) : "",
258
+ i.label,
259
+ /* @__PURE__ */ e(E, { className: h("ml-auto", i.value === a ? "opacity-100" : "opacity-0") })
260
+ ]
261
+ },
262
+ i.value
263
+ )) })
264
+ ] })
265
+ ] }) })
266
+ ] });
267
+ };
268
+ function Oe({ label: t, name: a, note: r, placeholder: n, className: l, error: s, ...o }) {
269
+ return /* @__PURE__ */ u(m, { className: "w-full", direction: "col", gap: "2", children: [
270
+ t && /* @__PURE__ */ e(f, { htmlFor: a, children: t }),
271
+ /* @__PURE__ */ e(
272
+ re,
273
+ {
274
+ "aria-label": t || a,
275
+ className: l,
276
+ id: a,
277
+ name: a,
278
+ placeholder: n,
279
+ ...o
280
+ }
281
+ ),
282
+ r && /* @__PURE__ */ e(x, { size: "sm", variant: "muted", children: r }),
283
+ s && /* @__PURE__ */ e(b, { message: s })
284
+ ] });
285
+ }
286
+ const Re = ({
287
+ name: t,
288
+ type: a = "text",
289
+ placeholder: r,
290
+ label: n,
291
+ labelOrientation: l = "top",
292
+ note: s,
293
+ className: o,
294
+ error: c,
295
+ ...d
296
+ }) => /* @__PURE__ */ u(m, { className: "w-full", direction: l === "left" ? "row" : "col", gap: "2", children: [
297
+ n && /* @__PURE__ */ e(f, { className: l === "left" ? "text-nowrap" : "", htmlFor: t, children: n }),
298
+ /* @__PURE__ */ e(
299
+ ne,
300
+ {
301
+ "aria-label": n || t,
302
+ className: o,
303
+ id: t,
304
+ name: t,
305
+ placeholder: r,
306
+ type: a,
307
+ ...d
308
+ }
309
+ ),
310
+ s && /* @__PURE__ */ e(x, { size: "sm", variant: "muted", children: s }),
311
+ c && /* @__PURE__ */ e(b, { message: c })
312
+ ] });
313
+ export {
314
+ le as B,
315
+ Be as C,
316
+ Te as D,
317
+ Fe as I,
318
+ De as L,
319
+ Ee as N,
320
+ je as R,
321
+ $e as S,
322
+ Oe as T,
323
+ se as a,
324
+ Le as b,
325
+ ke as c,
326
+ Ge as d,
327
+ Pe as e,
328
+ ze as f,
329
+ Re as g
330
+ };
@@ -0,0 +1,8 @@
1
+ import { clsx as o } from "clsx";
2
+ import { twMerge as t } from "tailwind-merge";
3
+ function m(...r) {
4
+ return t(o(r));
5
+ }
6
+ export {
7
+ m as c
8
+ };
package/dist/forms.js CHANGED
@@ -1,21 +1,19 @@
1
- import { B as e, a as s } from "./calendar.js";
2
- import { C as r, a as u, b as p, D as n, I as c, c as I, L as x, N as S, R as b, d as l, S as m, T as B } from "./SelectInput.js";
3
- import { S as D, T } from "./Textarea.js";
1
+ import { B as e, a as s, C as u, b as o, c as r, D as n, I as p, d as c, L as I, N as b, R as l, e as B, f as S, S as i, g as x, T as D } from "./chunks/TextInput-NfG9yrGJ.js";
4
2
  export {
5
3
  e as Button,
6
4
  s as ButtonGroup,
7
- r as Checkbox,
8
- u as DateInput,
9
- p as DatePicker,
5
+ u as Checkbox,
6
+ o as DateInput,
7
+ r as DatePicker,
10
8
  n as DeleteButton,
11
- c as InputError,
12
- I as InputGroup,
13
- x as Label,
14
- S as NumberInput,
15
- b as RadioSelect,
16
- l as SelectInput,
17
- D as SelectPicker,
18
- m as SubmitButton,
19
- B as TextInput,
20
- T as Textarea
9
+ p as InputError,
10
+ c as InputGroup,
11
+ I as Label,
12
+ b as NumberInput,
13
+ l as RadioSelect,
14
+ B as SelectInput,
15
+ S as SelectPicker,
16
+ i as SubmitButton,
17
+ x as TextInput,
18
+ D as Textarea
21
19
  };
package/dist/index.d.ts CHANGED
@@ -1,21 +1,41 @@
1
- import { Accordion as Accordion_2 } from 'radix-ui';
1
+ import { Accordion as Accordion_3 } from 'radix-ui';
2
2
  import { ClassProp } from 'class-variance-authority/types';
3
3
  import { ClassValue } from 'clsx';
4
+ import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
4
5
  import { ComponentProps } from 'react';
5
6
  import { default as default_2 } from 'react';
6
7
  import { JSX } from 'react/jsx-runtime';
7
8
  import { Popover as Popover_3 } from 'radix-ui';
8
9
  import * as React_2 from 'react';
10
+ import { ReactNode } from 'react';
9
11
  import { Tabs as Tabs_2 } from 'radix-ui';
10
12
  import { VariantProps } from 'class-variance-authority';
11
13
 
12
- export declare function Accordion({ ...props }: React_2.ComponentProps<typeof Accordion_2.Root>): JSX.Element;
14
+ export declare const Accordion: AccordionComponent;
13
15
 
14
- export declare function AccordionContent({ className, children, ...props }: React_2.ComponentProps<typeof Accordion_2.Content>): JSX.Element;
16
+ declare function Accordion_2({ ...props }: React_2.ComponentProps<typeof Accordion_3.Root>): JSX.Element;
15
17
 
16
- export declare function AccordionItem({ className, ...props }: React_2.ComponentProps<typeof Accordion_2.Item>): JSX.Element;
18
+ declare type AccordionComponent = React.FC<AccordionProps> & {
19
+ Item: React.FC<AccordionItemProps>;
20
+ Trigger: React.FC<AccordionTriggerProps>;
21
+ Content: React.FC<AccordionContentProps>;
22
+ };
23
+
24
+ declare function AccordionContent({ className, children, ...props }: React_2.ComponentProps<typeof Accordion_3.Content>): JSX.Element;
25
+
26
+ declare type AccordionContentProps = React.ComponentProps<typeof AccordionContent>;
17
27
 
18
- export declare function AccordionTrigger({ className, children, ...props }: React_2.ComponentProps<typeof Accordion_2.Trigger>): JSX.Element;
28
+ declare function AccordionItem({ className, ...props }: React_2.ComponentProps<typeof Accordion_3.Item>): JSX.Element;
29
+
30
+ declare type AccordionItemProps = React.ComponentProps<typeof AccordionItem>;
31
+
32
+ export declare type AccordionProps = React.ComponentProps<typeof Accordion_2> & {
33
+ children: ReactNode;
34
+ };
35
+
36
+ declare function AccordionTrigger({ className, children, ...props }: React_2.ComponentProps<typeof Accordion_3.Trigger>): JSX.Element;
37
+
38
+ declare type AccordionTriggerProps = React.ComponentProps<typeof AccordionTrigger>;
19
39
 
20
40
  export declare const Alert: ({ type, title, message, className }: AlertProps) => JSX.Element;
21
41
 
@@ -28,7 +48,7 @@ export declare interface AlertProps {
28
48
 
29
49
  export declare const Badge: ({ label, onClick, className, variant, color }: BadgeProps) => JSX.Element;
30
50
 
31
- declare interface BadgeProps {
51
+ export declare interface BadgeProps {
32
52
  variant?: "default" | "secondary" | "destructive" | "outline";
33
53
  color?: TailwindColor;
34
54
  label: string;
@@ -141,6 +161,25 @@ export declare function cn(...inputs: ClassValue[]): string;
141
161
 
142
162
  export declare const Code: ({ children, ...props }: TextProps) => JSX.Element;
143
163
 
164
+ export declare const Collapsible: CollapsibleComponent;
165
+
166
+ declare function Collapsible_2({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.Root>): JSX.Element;
167
+
168
+ declare type CollapsibleComponent = React.FC<CollapsibleProps> & {
169
+ Trigger: React.FC<CollapsibleTriggerProps>;
170
+ Content: React.FC<CollapsibleContentProps>;
171
+ };
172
+
173
+ declare function CollapsibleContent({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>): JSX.Element;
174
+
175
+ declare type CollapsibleContentProps = React.ComponentProps<typeof CollapsibleContent>;
176
+
177
+ export declare type CollapsibleProps = React.ComponentProps<typeof Collapsible_2>;
178
+
179
+ declare function CollapsibleTrigger({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>): JSX.Element;
180
+
181
+ declare type CollapsibleTriggerProps = React.ComponentProps<typeof CollapsibleTrigger>;
182
+
144
183
  export declare const Container: ({ children, className, direction, ...props }: ContainerProps) => JSX.Element;
145
184
 
146
185
  export declare interface ContainerProps extends FlexProps {