@crystallize/design-system 1.23.5 → 1.24.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.
- package/CHANGELOG.md +12 -0
- package/dist/{chunk-HTAQYJ4Y.mjs → chunk-FWRBC56V.mjs} +4 -2
- package/dist/index.css +42 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +442 -396
- package/dist/index.mjs +109 -68
- package/dist/{rich-text-editor-EN3ZWHSO.mjs → rich-text-editor-6PGBZV6U.mjs} +1 -1
- package/package.json +3 -1
- package/src/collapsible/collapsible.css +19 -0
- package/src/collapsible/collapsible.stories.tsx +61 -0
- package/src/collapsible/collapsible.tsx +44 -0
- package/src/collapsible/index.ts +1 -0
- package/src/dropdown-menu/DropdownMenu.stories.tsx +2 -4
- package/src/iconography/folder.tsx +2 -0
- package/src/index.ts +1 -0
- package/tailwind.config.cjs +11 -1
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
showError,
|
|
18
18
|
showInfo,
|
|
19
19
|
showWarning
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-FWRBC56V.mjs";
|
|
21
21
|
import "./chunk-NIH5ZMPE.mjs";
|
|
22
22
|
|
|
23
23
|
// src/card/card.tsx
|
|
@@ -115,10 +115,49 @@ var Checkbox = forwardRef2((props, ref) => {
|
|
|
115
115
|
});
|
|
116
116
|
Checkbox.displayName = "Checkbox";
|
|
117
117
|
|
|
118
|
+
// src/collapsible/collapsible.tsx
|
|
119
|
+
import { cx } from "class-variance-authority";
|
|
120
|
+
import * as CollapsiblePrimitives from "@radix-ui/react-collapsible";
|
|
121
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
122
|
+
function Content2({ className, ...delegated }) {
|
|
123
|
+
return /* @__PURE__ */ jsx4(CollapsiblePrimitives.Content, {
|
|
124
|
+
...delegated,
|
|
125
|
+
className: cx("c-collapsible-content", className)
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function CollapsibleTrigger({
|
|
129
|
+
children,
|
|
130
|
+
arrowPosition,
|
|
131
|
+
className,
|
|
132
|
+
...delegated
|
|
133
|
+
}) {
|
|
134
|
+
return /* @__PURE__ */ jsx4(CollapsiblePrimitives.Trigger, {
|
|
135
|
+
asChild: true,
|
|
136
|
+
...delegated,
|
|
137
|
+
className: cx("c-collapsible-trigger", arrowPosition === "right" ? "arrow-right" : "", className),
|
|
138
|
+
children: /* @__PURE__ */ jsxs2("div", {
|
|
139
|
+
children: [
|
|
140
|
+
arrowPosition && /* @__PURE__ */ jsx4(Icon.Caret, {
|
|
141
|
+
className: "c-collapsible-arrow",
|
|
142
|
+
fill: "purple-50-900",
|
|
143
|
+
width: 10,
|
|
144
|
+
height: 10
|
|
145
|
+
}),
|
|
146
|
+
children
|
|
147
|
+
]
|
|
148
|
+
})
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
var Collapsible = {
|
|
152
|
+
Root: CollapsiblePrimitives.Root,
|
|
153
|
+
Trigger: CollapsibleTrigger,
|
|
154
|
+
Content: Content2
|
|
155
|
+
};
|
|
156
|
+
|
|
118
157
|
// src/inline-radio/inline-radio.tsx
|
|
119
|
-
import { cx, cva as cva3 } from "class-variance-authority";
|
|
158
|
+
import { cx as cx2, cva as cva3 } from "class-variance-authority";
|
|
120
159
|
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
121
|
-
import { jsx as
|
|
160
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
122
161
|
var inlineRadioGroupStyles = cva3("c-inline-radio-group", {
|
|
123
162
|
variants: {
|
|
124
163
|
size: {
|
|
@@ -133,16 +172,16 @@ var inlineRadioGroupStyles = cva3("c-inline-radio-group", {
|
|
|
133
172
|
}
|
|
134
173
|
});
|
|
135
174
|
function InlineRadioGroup({ size, className, ...delegated }) {
|
|
136
|
-
return /* @__PURE__ */
|
|
175
|
+
return /* @__PURE__ */ jsx5(RadioGroupPrimitive.Root, {
|
|
137
176
|
...delegated,
|
|
138
177
|
className: inlineRadioGroupStyles({ size, className })
|
|
139
178
|
});
|
|
140
179
|
}
|
|
141
180
|
function InlineRadioItem({ children, className, ...delegated }) {
|
|
142
|
-
return /* @__PURE__ */
|
|
181
|
+
return /* @__PURE__ */ jsx5(RadioGroupPrimitive.Item, {
|
|
143
182
|
...delegated,
|
|
144
|
-
className:
|
|
145
|
-
children: /* @__PURE__ */
|
|
183
|
+
className: cx2("c-inline-radio", className),
|
|
184
|
+
children: /* @__PURE__ */ jsx5(RadioGroupPrimitive.Indicator, {
|
|
146
185
|
forceMount: true,
|
|
147
186
|
children
|
|
148
187
|
})
|
|
@@ -154,14 +193,14 @@ var InlineRadio = {
|
|
|
154
193
|
};
|
|
155
194
|
|
|
156
195
|
// src/progress/progress.tsx
|
|
157
|
-
import { cx as
|
|
196
|
+
import { cx as cx3 } from "class-variance-authority";
|
|
158
197
|
import * as ProgressPrimitives from "@radix-ui/react-progress";
|
|
159
|
-
import { jsx as
|
|
198
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
160
199
|
function Progress({ className, value }) {
|
|
161
|
-
return /* @__PURE__ */
|
|
162
|
-
className:
|
|
200
|
+
return /* @__PURE__ */ jsx6(ProgressPrimitives.Root, {
|
|
201
|
+
className: cx3(className, "c-progress-root"),
|
|
163
202
|
value,
|
|
164
|
-
children: /* @__PURE__ */
|
|
203
|
+
children: /* @__PURE__ */ jsx6(ProgressPrimitives.Indicator, {
|
|
165
204
|
className: "c-progress-indicator",
|
|
166
205
|
style: { transform: `translateX(-${100 - (value ?? 0)}%)` }
|
|
167
206
|
})
|
|
@@ -170,12 +209,12 @@ function Progress({ className, value }) {
|
|
|
170
209
|
|
|
171
210
|
// src/radio/radio.tsx
|
|
172
211
|
import * as RadioGroupPrimitive2 from "@radix-ui/react-radio-group";
|
|
173
|
-
import { jsx as
|
|
212
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
174
213
|
function RadioGroupItem(props) {
|
|
175
|
-
return /* @__PURE__ */
|
|
214
|
+
return /* @__PURE__ */ jsx7(RadioGroupPrimitive2.Item, {
|
|
176
215
|
...props,
|
|
177
216
|
className: "c-radio-item",
|
|
178
|
-
children: /* @__PURE__ */
|
|
217
|
+
children: /* @__PURE__ */ jsx7(RadioGroupPrimitive2.Indicator, {
|
|
179
218
|
className: "c-radio-indicator"
|
|
180
219
|
})
|
|
181
220
|
});
|
|
@@ -188,18 +227,18 @@ var Radio = {
|
|
|
188
227
|
// src/select/select-item.tsx
|
|
189
228
|
import { forwardRef as forwardRef3 } from "react";
|
|
190
229
|
import * as SelectPrimitives from "@radix-ui/react-select";
|
|
191
|
-
import { jsx as
|
|
230
|
+
import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
192
231
|
var SelectItem = forwardRef3((props, ref) => {
|
|
193
232
|
const { children, ...delegated } = props;
|
|
194
|
-
return /* @__PURE__ */
|
|
233
|
+
return /* @__PURE__ */ jsxs3(SelectPrimitives.Item, {
|
|
195
234
|
className: "c-select-item",
|
|
196
235
|
ref,
|
|
197
236
|
...delegated,
|
|
198
237
|
children: [
|
|
199
|
-
/* @__PURE__ */
|
|
238
|
+
/* @__PURE__ */ jsx8(SelectPrimitives.ItemText, {
|
|
200
239
|
children
|
|
201
240
|
}),
|
|
202
|
-
/* @__PURE__ */
|
|
241
|
+
/* @__PURE__ */ jsx8(SelectPrimitives.ItemIndicator, {})
|
|
203
242
|
]
|
|
204
243
|
});
|
|
205
244
|
});
|
|
@@ -209,7 +248,7 @@ SelectItem.displayName = "SelectItem";
|
|
|
209
248
|
import { forwardRef as forwardRef4 } from "react";
|
|
210
249
|
import { cva as cva4 } from "class-variance-authority";
|
|
211
250
|
import * as SelectPrimitives2 from "@radix-ui/react-select";
|
|
212
|
-
import { jsx as
|
|
251
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
213
252
|
var selectTriggerStyles = cva4("c-select-trigger", {
|
|
214
253
|
variants: {
|
|
215
254
|
size: {
|
|
@@ -225,34 +264,34 @@ var selectTriggerStyles = cva4("c-select-trigger", {
|
|
|
225
264
|
});
|
|
226
265
|
var SelectContainer = forwardRef4(
|
|
227
266
|
({ children, id, placeholder, disabled, size, triggerClassName, ...delegated }, ref) => {
|
|
228
|
-
return /* @__PURE__ */
|
|
267
|
+
return /* @__PURE__ */ jsxs4(SelectPrimitives2.Root, {
|
|
229
268
|
...delegated,
|
|
230
269
|
children: [
|
|
231
|
-
/* @__PURE__ */
|
|
270
|
+
/* @__PURE__ */ jsxs4(SelectPrimitives2.Trigger, {
|
|
232
271
|
ref,
|
|
233
272
|
className: selectTriggerStyles({ size, className: triggerClassName }),
|
|
234
273
|
disabled,
|
|
235
274
|
id,
|
|
236
275
|
children: [
|
|
237
|
-
/* @__PURE__ */
|
|
238
|
-
placeholder: /* @__PURE__ */
|
|
276
|
+
/* @__PURE__ */ jsx9(SelectPrimitives2.Value, {
|
|
277
|
+
placeholder: /* @__PURE__ */ jsx9("span", {
|
|
239
278
|
className: "c-select-value",
|
|
240
279
|
children: placeholder ?? "Select..."
|
|
241
280
|
})
|
|
242
281
|
}),
|
|
243
|
-
/* @__PURE__ */
|
|
282
|
+
/* @__PURE__ */ jsx9(Icon.Arrow, {})
|
|
244
283
|
]
|
|
245
284
|
}),
|
|
246
|
-
/* @__PURE__ */
|
|
247
|
-
children: /* @__PURE__ */
|
|
285
|
+
/* @__PURE__ */ jsx9(SelectPrimitives2.Portal, {
|
|
286
|
+
children: /* @__PURE__ */ jsxs4(SelectPrimitives2.Content, {
|
|
248
287
|
className: "c-select-content",
|
|
249
288
|
children: [
|
|
250
|
-
/* @__PURE__ */
|
|
251
|
-
/* @__PURE__ */
|
|
289
|
+
/* @__PURE__ */ jsx9(SelectPrimitives2.ScrollUpButton, {}),
|
|
290
|
+
/* @__PURE__ */ jsx9(SelectPrimitives2.Viewport, {
|
|
252
291
|
className: "c-select-viewport",
|
|
253
292
|
children
|
|
254
293
|
}),
|
|
255
|
-
/* @__PURE__ */
|
|
294
|
+
/* @__PURE__ */ jsx9(SelectPrimitives2.ScrollDownButton, {})
|
|
256
295
|
]
|
|
257
296
|
})
|
|
258
297
|
})
|
|
@@ -270,22 +309,22 @@ var Select = {
|
|
|
270
309
|
|
|
271
310
|
// src/slider/slider.tsx
|
|
272
311
|
import { forwardRef as forwardRef5 } from "react";
|
|
273
|
-
import { cx as
|
|
312
|
+
import { cx as cx4 } from "class-variance-authority";
|
|
274
313
|
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
275
|
-
import { jsx as
|
|
314
|
+
import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
276
315
|
var Slider = forwardRef5(({ className, transparentRange, ...delegated }, ref) => {
|
|
277
|
-
return /* @__PURE__ */
|
|
278
|
-
className:
|
|
316
|
+
return /* @__PURE__ */ jsxs5(SliderPrimitive.Root, {
|
|
317
|
+
className: cx4("c-slider-root", className),
|
|
279
318
|
ref,
|
|
280
319
|
...delegated,
|
|
281
320
|
children: [
|
|
282
|
-
/* @__PURE__ */
|
|
321
|
+
/* @__PURE__ */ jsx10(SliderPrimitive.Track, {
|
|
283
322
|
className: "c-slider-track",
|
|
284
|
-
children: /* @__PURE__ */
|
|
323
|
+
children: /* @__PURE__ */ jsx10(SliderPrimitive.Range, {
|
|
285
324
|
className: `c-slider-range ${transparentRange ? "c-slider-range-transparent" : ""}`
|
|
286
325
|
})
|
|
287
326
|
}),
|
|
288
|
-
/* @__PURE__ */
|
|
327
|
+
/* @__PURE__ */ jsx10(SliderPrimitive.Thumb, {
|
|
289
328
|
className: "c-slider-thumb"
|
|
290
329
|
})
|
|
291
330
|
]
|
|
@@ -293,15 +332,15 @@ var Slider = forwardRef5(({ className, transparentRange, ...delegated }, ref) =>
|
|
|
293
332
|
});
|
|
294
333
|
|
|
295
334
|
// src/stack-icon/stack-icon.tsx
|
|
296
|
-
import { jsx as
|
|
335
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
297
336
|
function StackIcon({ type, children, size = 18 }) {
|
|
298
|
-
return /* @__PURE__ */
|
|
337
|
+
return /* @__PURE__ */ jsxs6("span", {
|
|
299
338
|
className: "c-stack-icon",
|
|
300
339
|
children: [
|
|
301
|
-
type === "create" && /* @__PURE__ */
|
|
340
|
+
type === "create" && /* @__PURE__ */ jsx11("span", {
|
|
302
341
|
style: { width: size, height: size },
|
|
303
342
|
className: "c-stack-icon__icon",
|
|
304
|
-
children: /* @__PURE__ */
|
|
343
|
+
children: /* @__PURE__ */ jsx11(Icon.Add, {
|
|
305
344
|
width: size - 4,
|
|
306
345
|
height: size - 4
|
|
307
346
|
})
|
|
@@ -312,8 +351,8 @@ function StackIcon({ type, children, size = 18 }) {
|
|
|
312
351
|
}
|
|
313
352
|
|
|
314
353
|
// src/tag/tag.tsx
|
|
315
|
-
import { cva as cva5, cx as
|
|
316
|
-
import { jsx as
|
|
354
|
+
import { cva as cva5, cx as cx5 } from "class-variance-authority";
|
|
355
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
317
356
|
var tagStyles = cva5("c-tag", {
|
|
318
357
|
variants: {
|
|
319
358
|
variant: {
|
|
@@ -343,28 +382,28 @@ function Tag({
|
|
|
343
382
|
showRemoveOnHover,
|
|
344
383
|
...delegated
|
|
345
384
|
}) {
|
|
346
|
-
return /* @__PURE__ */
|
|
385
|
+
return /* @__PURE__ */ jsxs7("div", {
|
|
347
386
|
className: tagStyles({ className, variant, size }),
|
|
348
387
|
...delegated,
|
|
349
388
|
children: [
|
|
350
|
-
!prepend ? null : /* @__PURE__ */
|
|
389
|
+
!prepend ? null : /* @__PURE__ */ jsx12("span", {
|
|
351
390
|
className: "c-tag__prepend",
|
|
352
391
|
children: prepend
|
|
353
392
|
}),
|
|
354
393
|
children,
|
|
355
|
-
onRemove && /* @__PURE__ */
|
|
394
|
+
onRemove && /* @__PURE__ */ jsxs7("button", {
|
|
356
395
|
type: "button",
|
|
357
|
-
className:
|
|
396
|
+
className: cx5("c-tag__remove-button", showRemoveOnHover ? "c-tag__remove-button--hover" : ""),
|
|
358
397
|
onClick: (e) => {
|
|
359
398
|
e.stopPropagation();
|
|
360
399
|
onRemove();
|
|
361
400
|
},
|
|
362
401
|
children: [
|
|
363
|
-
/* @__PURE__ */
|
|
402
|
+
/* @__PURE__ */ jsx12(Icon.Cancel, {
|
|
364
403
|
width: 12,
|
|
365
404
|
height: 12
|
|
366
405
|
}),
|
|
367
|
-
/* @__PURE__ */
|
|
406
|
+
/* @__PURE__ */ jsx12("span", {
|
|
368
407
|
className: "c-tag__remove-button-text",
|
|
369
408
|
children: "Remove"
|
|
370
409
|
})
|
|
@@ -376,12 +415,12 @@ function Tag({
|
|
|
376
415
|
|
|
377
416
|
// src/rich-text-editor/index.tsx
|
|
378
417
|
import { lazy, Suspense } from "react";
|
|
379
|
-
import { jsx as
|
|
380
|
-
var LazyRichTextEditor = lazy(() => import("./rich-text-editor-
|
|
418
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
419
|
+
var LazyRichTextEditor = lazy(() => import("./rich-text-editor-6PGBZV6U.mjs"));
|
|
381
420
|
var RichTextEditor = (props) => {
|
|
382
|
-
return /* @__PURE__ */
|
|
421
|
+
return /* @__PURE__ */ jsx13(Suspense, {
|
|
383
422
|
fallback: null,
|
|
384
|
-
children: /* @__PURE__ */
|
|
423
|
+
children: /* @__PURE__ */ jsx13(LazyRichTextEditor, {
|
|
385
424
|
...props
|
|
386
425
|
})
|
|
387
426
|
});
|
|
@@ -391,9 +430,9 @@ var RichTextEditor = (props) => {
|
|
|
391
430
|
import { Toaster } from "sonner";
|
|
392
431
|
|
|
393
432
|
// src/toast/toast.tsx
|
|
394
|
-
import { cva as cva6, cx as
|
|
433
|
+
import { cva as cva6, cx as cx6 } from "class-variance-authority";
|
|
395
434
|
import { toast as sonnerToast } from "sonner";
|
|
396
|
-
import { jsx as
|
|
435
|
+
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
397
436
|
var toastStyles = cva6("c-toast", {
|
|
398
437
|
variants: {
|
|
399
438
|
type: {
|
|
@@ -418,34 +457,34 @@ var toast = ({ title, message, type = "success", timeout = 6e3 }) => {
|
|
|
418
457
|
const withMessage = !!message;
|
|
419
458
|
const toastId = Date.now().toString();
|
|
420
459
|
sonnerToast.custom(
|
|
421
|
-
(id) => /* @__PURE__ */
|
|
460
|
+
(id) => /* @__PURE__ */ jsxs8("div", {
|
|
422
461
|
"data-testid": `toast-${type}`,
|
|
423
|
-
className:
|
|
462
|
+
className: cx6(toastStyles({ type }), withMessage ? "c-toast-with-message" : "c-toast-title-only"),
|
|
424
463
|
children: [
|
|
425
|
-
/* @__PURE__ */
|
|
426
|
-
children: /* @__PURE__ */
|
|
464
|
+
/* @__PURE__ */ jsx14("div", {
|
|
465
|
+
children: /* @__PURE__ */ jsx14(ToastIcon, {
|
|
427
466
|
width: 26,
|
|
428
467
|
height: 26
|
|
429
468
|
})
|
|
430
469
|
}),
|
|
431
|
-
/* @__PURE__ */
|
|
470
|
+
/* @__PURE__ */ jsxs8("div", {
|
|
432
471
|
children: [
|
|
433
|
-
/* @__PURE__ */
|
|
472
|
+
/* @__PURE__ */ jsx14("div", {
|
|
434
473
|
className: "c-toast-title",
|
|
435
474
|
children: title
|
|
436
475
|
}),
|
|
437
|
-
!!message && /* @__PURE__ */
|
|
476
|
+
!!message && /* @__PURE__ */ jsx14("div", {
|
|
438
477
|
className: "c-toast-message",
|
|
439
478
|
children: message
|
|
440
479
|
})
|
|
441
480
|
]
|
|
442
481
|
}),
|
|
443
|
-
/* @__PURE__ */
|
|
482
|
+
/* @__PURE__ */ jsx14("div", {
|
|
444
483
|
className: "c-toast-close",
|
|
445
|
-
children: /* @__PURE__ */
|
|
484
|
+
children: /* @__PURE__ */ jsx14(IconButton, {
|
|
446
485
|
onClick: () => sonnerToast.dismiss(id),
|
|
447
486
|
size: "xs",
|
|
448
|
-
children: /* @__PURE__ */
|
|
487
|
+
children: /* @__PURE__ */ jsx14(Icon.Cancel, {
|
|
449
488
|
width: 12,
|
|
450
489
|
height: 12
|
|
451
490
|
})
|
|
@@ -466,7 +505,7 @@ toast.dismiss = sonnerToast.dismiss;
|
|
|
466
505
|
// src/switch/switch.tsx
|
|
467
506
|
import { cva as cva7 } from "class-variance-authority";
|
|
468
507
|
import * as RadixSwitch from "@radix-ui/react-switch";
|
|
469
|
-
import { jsx as
|
|
508
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
470
509
|
var switchStyles = cva7(["c-switch-root"], {
|
|
471
510
|
variants: {
|
|
472
511
|
size: {
|
|
@@ -479,10 +518,10 @@ var switchStyles = cva7(["c-switch-root"], {
|
|
|
479
518
|
}
|
|
480
519
|
});
|
|
481
520
|
function Switch({ size, ...props }) {
|
|
482
|
-
return /* @__PURE__ */
|
|
521
|
+
return /* @__PURE__ */ jsx15(RadixSwitch.Root, {
|
|
483
522
|
...props,
|
|
484
523
|
className: switchStyles({ size }),
|
|
485
|
-
children: /* @__PURE__ */
|
|
524
|
+
children: /* @__PURE__ */ jsx15(RadixSwitch.Thumb, {
|
|
486
525
|
className: "c-switch-thumb"
|
|
487
526
|
})
|
|
488
527
|
});
|
|
@@ -499,6 +538,8 @@ export {
|
|
|
499
538
|
Button,
|
|
500
539
|
Card,
|
|
501
540
|
Checkbox,
|
|
541
|
+
Collapsible,
|
|
542
|
+
CollapsibleTrigger,
|
|
502
543
|
Dialog,
|
|
503
544
|
DropdownMenu,
|
|
504
545
|
Icon,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crystallize/design-system",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@lexical/utils": "0.12.4",
|
|
39
39
|
"@lexical/yjs": "0.12.4",
|
|
40
40
|
"@radix-ui/react-checkbox": "1.0.1",
|
|
41
|
+
"@radix-ui/react-collapsible": "1.0.0",
|
|
41
42
|
"@radix-ui/react-dialog": "1.0.2",
|
|
42
43
|
"@radix-ui/react-dropdown-menu": "2.0.1",
|
|
43
44
|
"@radix-ui/react-popover": "1.0.0",
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
"class-variance-authority": "^0.4.0",
|
|
51
52
|
"lexical": "0.12.4",
|
|
52
53
|
"sonner": "^0.6.2",
|
|
54
|
+
"tailwindcss-radix": "^2.6.1",
|
|
53
55
|
"use-debounce": "8.0.4"
|
|
54
56
|
},
|
|
55
57
|
"peerDependencies": {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.c-collapsible-content {
|
|
2
|
+
@apply overflow-hidden radix-state-closed:animate-collapsible-close radix-state-open:animate-collapsible-open;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.c-collapsible-trigger {
|
|
6
|
+
@apply flex gap-2 items-center;
|
|
7
|
+
|
|
8
|
+
&.arrow-right {
|
|
9
|
+
@apply flex-row-reverse justify-end;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.c-collapsible-arrow {
|
|
14
|
+
transition: 0.3s;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.c-collapsible-trigger[data-state='open'] .c-collapsible-arrow {
|
|
18
|
+
transform: rotate(180deg);
|
|
19
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Card } from '../card';
|
|
5
|
+
import { Collapsible, CollapsibleTrigger } from './collapsible';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof CollapsibleTrigger> = {
|
|
8
|
+
title: 'Components/Collapsible',
|
|
9
|
+
component: CollapsibleTrigger,
|
|
10
|
+
argTypes: {
|
|
11
|
+
arrowPosition: {
|
|
12
|
+
options: ['right', 'left', undefined],
|
|
13
|
+
description: 'Trigger prop to control arrow visibility and position',
|
|
14
|
+
defaultValue: undefined,
|
|
15
|
+
control: {
|
|
16
|
+
type: 'select',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export default meta;
|
|
22
|
+
type Story = StoryObj<typeof CollapsibleTrigger>;
|
|
23
|
+
|
|
24
|
+
export const Example: Story = {
|
|
25
|
+
args: {
|
|
26
|
+
arrowPosition: 'right',
|
|
27
|
+
},
|
|
28
|
+
render: args => (
|
|
29
|
+
<Card style={{ padding: 0 }}>
|
|
30
|
+
<Collapsible.Root>
|
|
31
|
+
<div style={{ cursor: 'pointer', padding: '32px' }}>
|
|
32
|
+
<Collapsible.Trigger arrowPosition={args.arrowPosition}>
|
|
33
|
+
<div>Expand</div>
|
|
34
|
+
</Collapsible.Trigger>
|
|
35
|
+
</div>
|
|
36
|
+
<Collapsible.Content>
|
|
37
|
+
<p style={{ padding: '0 32px' }}>
|
|
38
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam dui sem, fermentum vitae, sagittis id,
|
|
39
|
+
malesuada in, quam. Cras elementum. Curabitur ligula sapien, pulvinar a vestibulum quis, facilisis vel
|
|
40
|
+
sapien. Ut tempus purus at lorem. Pellentesque ipsum. Sed elit dui, pellentesque a, faucibus vel, interdum
|
|
41
|
+
nec, diam. Maecenas sollicitudin. Praesent id justo in neque elementum ultrices. Etiam neque. Integer
|
|
42
|
+
tempor. Fusce nibh.
|
|
43
|
+
</p>
|
|
44
|
+
</Collapsible.Content>
|
|
45
|
+
</Collapsible.Root>
|
|
46
|
+
</Card>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Controlled = () => {
|
|
51
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Collapsible.Root open={isOpen} onOpenChange={o => setIsOpen(o)}>
|
|
55
|
+
<Collapsible.Trigger>Click me</Collapsible.Trigger>
|
|
56
|
+
<Collapsible.Content>
|
|
57
|
+
<div>Content</div>
|
|
58
|
+
</Collapsible.Content>
|
|
59
|
+
</Collapsible.Root>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { cx } from 'class-variance-authority';
|
|
3
|
+
import * as CollapsiblePrimitives from '@radix-ui/react-collapsible';
|
|
4
|
+
import type { CollapsibleTriggerProps } from '@radix-ui/react-collapsible';
|
|
5
|
+
|
|
6
|
+
import './collapsible.css';
|
|
7
|
+
|
|
8
|
+
import { Icon } from '../iconography';
|
|
9
|
+
|
|
10
|
+
type CollapsibleContentProps = ComponentProps<typeof CollapsiblePrimitives.Content>;
|
|
11
|
+
|
|
12
|
+
function Content({ className, ...delegated }: CollapsibleContentProps) {
|
|
13
|
+
return <CollapsiblePrimitives.Content {...delegated} className={cx('c-collapsible-content', className)} />;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type CollapsibleTriggerPropsExtendedProps = CollapsibleTriggerProps & {
|
|
17
|
+
arrowPosition?: 'left' | 'right';
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function CollapsibleTrigger({
|
|
21
|
+
children,
|
|
22
|
+
arrowPosition,
|
|
23
|
+
className,
|
|
24
|
+
...delegated
|
|
25
|
+
}: CollapsibleTriggerPropsExtendedProps) {
|
|
26
|
+
return (
|
|
27
|
+
<CollapsiblePrimitives.Trigger
|
|
28
|
+
asChild
|
|
29
|
+
{...delegated}
|
|
30
|
+
className={cx('c-collapsible-trigger', arrowPosition === 'right' ? 'arrow-right' : '', className)}
|
|
31
|
+
>
|
|
32
|
+
<div>
|
|
33
|
+
{arrowPosition && <Icon.Caret className="c-collapsible-arrow" fill="purple-50-900" width={10} height={10} />}
|
|
34
|
+
{children}
|
|
35
|
+
</div>
|
|
36
|
+
</CollapsiblePrimitives.Trigger>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Collapsible = {
|
|
41
|
+
Root: CollapsiblePrimitives.Root,
|
|
42
|
+
Trigger: CollapsibleTrigger,
|
|
43
|
+
Content,
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './collapsible';
|
|
@@ -9,8 +9,8 @@ export default {
|
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
10
|
} as Meta<any>;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
export const WithOpenState = () => {
|
|
13
|
+
const ContentWithIcon = () => (
|
|
14
14
|
<>
|
|
15
15
|
<DropdownMenu.Label>View</DropdownMenu.Label>
|
|
16
16
|
<DropdownMenu.Item>
|
|
@@ -27,9 +27,7 @@ function ContentWithIcon() {
|
|
|
27
27
|
</DropdownMenu.Item>
|
|
28
28
|
</>
|
|
29
29
|
);
|
|
30
|
-
}
|
|
31
30
|
|
|
32
|
-
export const WithOpenState = () => {
|
|
33
31
|
return (
|
|
34
32
|
<DropdownMenu.Root content={<ContentWithIcon />}>
|
|
35
33
|
<Button prepend={<Icon.NailPolish width={20} height={20} />}>Pretty</Button>
|
|
@@ -10,6 +10,7 @@ export const Folder = forwardRef<FolderRef, FolderProps>((delegated, ref) => {
|
|
|
10
10
|
<path
|
|
11
11
|
d="M2.604 4.108v13.146a.6.6 0 00.6.6h11.968c.59 0 1.166-.255 1.429-.784 1.374-2.77 1.642-8.38 1.166-10.692-.114-.555-.706-.927-1.272-.927l-7.091.067-2-1.41h-4.8z"
|
|
12
12
|
fill="#BFF6F8"
|
|
13
|
+
className="c-icon-fill"
|
|
13
14
|
/>
|
|
14
15
|
<path
|
|
15
16
|
fillRule="evenodd"
|
|
@@ -20,6 +21,7 @@ export const Folder = forwardRef<FolderRef, FolderProps>((delegated, ref) => {
|
|
|
20
21
|
<path
|
|
21
22
|
d="M4.659 10.021L3.502 17.17a.6.6 0 00.594.685h12.076c.59 0 1.164-.254 1.46-.765 1.419-2.445 2.065-6 1.765-7.956-.086-.56-.617-.829-1.184-.829H6.64a2 2 0 00-1.98 1.717z"
|
|
22
23
|
fill="#BFF6F8"
|
|
24
|
+
className="c-icon-fill"
|
|
23
25
|
/>
|
|
24
26
|
<path
|
|
25
27
|
fillRule="evenodd"
|
package/src/index.ts
CHANGED
package/tailwind.config.cjs
CHANGED
|
@@ -40,6 +40,14 @@ module.exports = {
|
|
|
40
40
|
inherit: 'inherit',
|
|
41
41
|
},
|
|
42
42
|
keyframes: {
|
|
43
|
+
'collapsible-open': {
|
|
44
|
+
'0%': { height: '0' },
|
|
45
|
+
'100%': { height: 'var(--radix-collapsible-content-height)' },
|
|
46
|
+
},
|
|
47
|
+
'collapsible-close': {
|
|
48
|
+
'0%': { height: 'var(--radix-collapsible-content-height)' },
|
|
49
|
+
'100%': { height: '0' },
|
|
50
|
+
},
|
|
43
51
|
spin: {
|
|
44
52
|
'0%': {
|
|
45
53
|
transform: 'rotate(0deg)',
|
|
@@ -56,6 +64,8 @@ module.exports = {
|
|
|
56
64
|
},
|
|
57
65
|
},
|
|
58
66
|
animation: {
|
|
67
|
+
'collapsible-open': 'collapsible-open 300ms ease-out forwards',
|
|
68
|
+
'collapsible-close': 'collapsible-close 300ms ease-out forwards',
|
|
59
69
|
spin: 'spin 2s linear infinite',
|
|
60
70
|
},
|
|
61
71
|
boxShadow: {
|
|
@@ -64,5 +74,5 @@ module.exports = {
|
|
|
64
74
|
},
|
|
65
75
|
},
|
|
66
76
|
},
|
|
67
|
-
plugins: [colorsPlugin],
|
|
77
|
+
plugins: [colorsPlugin, require('tailwindcss-radix')(), require('@tailwindcss/container-queries')],
|
|
68
78
|
};
|