@efiche/design 0.1.4 → 0.1.6

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.cjs CHANGED
@@ -49,12 +49,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
49
49
  // src/components/index.ts
50
50
  var index_exports = {};
51
51
  __export(index_exports, {
52
- Accordion: () => Accordion_default2,
52
+ Accordion: () => Accordion_default,
53
53
  Alert: () => Alert_default2,
54
54
  Avatar: () => Avatar_default2,
55
55
  Badge: () => Badge_default2,
56
56
  Breadcrumb: () => Breadcrumb_default2,
57
- Button: () => Button_default2,
57
+ Button: () => Button_default,
58
58
  Card: () => Card,
59
59
  CardContent: () => CardContent,
60
60
  CardDescription: () => CardDescription,
@@ -108,11 +108,6 @@ var useTheme = () => {
108
108
  // src/components/Accordion/Accordion.tsx
109
109
  var import_react2 = require("react");
110
110
  var import_lucide_react = require("lucide-react");
111
-
112
- // src/components/Accordion/Accordion.module.css
113
- var Accordion_default = {};
114
-
115
- // src/components/Accordion/Accordion.tsx
116
111
  var import_jsx_runtime2 = require("react/jsx-runtime");
117
112
  var Accordion = ({ items, defaultValue, multiple = false }) => {
118
113
  const [open, setOpen] = (0, import_react2.useState)(() => {
@@ -120,6 +115,7 @@ var Accordion = ({ items, defaultValue, multiple = false }) => {
120
115
  if (Array.isArray(defaultValue)) return new Set(defaultValue);
121
116
  return /* @__PURE__ */ new Set([defaultValue]);
122
117
  });
118
+ const [hovered, setHovered] = (0, import_react2.useState)(null);
123
119
  const toggle = (value) => {
124
120
  setOpen((prev) => {
125
121
  const next = new Set(prev);
@@ -132,32 +128,76 @@ var Accordion = ({ items, defaultValue, multiple = false }) => {
132
128
  return next;
133
129
  });
134
130
  };
135
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: Accordion_default.root, children: items.map((item) => {
131
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
132
+ border: "1px solid var(--ds-border, #e2e8f0)",
133
+ borderRadius: "0.5rem",
134
+ overflow: "hidden"
135
+ }, children: items.map((item, index) => {
136
136
  const isOpen = open.has(item.value);
137
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: Accordion_default.item, children: [
138
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
139
- "button",
140
- {
141
- className: Accordion_default.trigger,
142
- onClick: () => toggle(item.value),
143
- "aria-expanded": isOpen,
144
- children: [
145
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: item.trigger }),
146
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
147
- import_lucide_react.ChevronDown,
148
- {
149
- size: 16,
150
- className: `${Accordion_default.chevron} ${isOpen ? Accordion_default["chevron-open"] : ""}`
151
- }
152
- )
153
- ]
154
- }
155
- ),
156
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: `${Accordion_default.panel} ${isOpen ? Accordion_default["panel-open"] : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: Accordion_default.content, children: item.content }) })
157
- ] }, item.value);
137
+ const isHovered = hovered === item.value;
138
+ const isLast = index === items.length - 1;
139
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
140
+ "div",
141
+ {
142
+ style: {
143
+ borderBottom: isLast ? "none" : "1px solid var(--ds-border, #e2e8f0)"
144
+ },
145
+ children: [
146
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
147
+ "button",
148
+ {
149
+ style: {
150
+ display: "flex",
151
+ alignItems: "center",
152
+ justifyContent: "space-between",
153
+ width: "100%",
154
+ padding: "1rem",
155
+ fontSize: "0.875rem",
156
+ fontWeight: 500,
157
+ background: isHovered ? "var(--ds-muted, #f1f5f9)" : "transparent",
158
+ border: "none",
159
+ cursor: "pointer",
160
+ textAlign: "left",
161
+ color: "var(--ds-text-primary, #0f172a)",
162
+ transition: "background-color 0.15s"
163
+ },
164
+ onClick: () => toggle(item.value),
165
+ onMouseEnter: () => setHovered(item.value),
166
+ onMouseLeave: () => setHovered(null),
167
+ "aria-expanded": isOpen,
168
+ children: [
169
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: item.trigger }),
170
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
171
+ import_lucide_react.ChevronDown,
172
+ {
173
+ size: 16,
174
+ style: {
175
+ flexShrink: 0,
176
+ color: "var(--ds-text-secondary, #64748b)",
177
+ transition: "transform 0.2s ease",
178
+ transform: isOpen ? "rotate(180deg)" : "rotate(0deg)"
179
+ }
180
+ }
181
+ )
182
+ ]
183
+ }
184
+ ),
185
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
186
+ maxHeight: isOpen ? "300px" : "0",
187
+ overflow: "hidden",
188
+ transition: "max-height 0.25s ease"
189
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
190
+ padding: "0 1rem 1rem",
191
+ fontSize: "0.875rem",
192
+ color: "var(--ds-text-secondary, #64748b)"
193
+ }, children: item.content }) })
194
+ ]
195
+ },
196
+ item.value
197
+ );
158
198
  }) });
159
199
  };
160
- var Accordion_default2 = Accordion;
200
+ var Accordion_default = Accordion;
161
201
 
162
202
  // src/components/Alert/Alert.tsx
163
203
  var import_lucide_react2 = require("lucide-react");
@@ -225,12 +265,39 @@ var Breadcrumb_default2 = Breadcrumb;
225
265
 
226
266
  // src/components/Button/Button.tsx
227
267
  var import_lucide_react4 = require("lucide-react");
228
-
229
- // src/components/Button/Button.module.css
230
- var Button_default = {};
231
-
232
- // src/components/Button/Button.tsx
268
+ var import_react3 = require("react");
233
269
  var import_jsx_runtime7 = require("react/jsx-runtime");
270
+ var variantStyles = {
271
+ solid: { backgroundColor: "var(--ds-primary, #3b82f6)", color: "#fff", borderColor: "transparent" },
272
+ outline: { backgroundColor: "transparent", color: "var(--ds-primary, #3b82f6)", borderColor: "var(--ds-primary, #3b82f6)" },
273
+ ghost: { backgroundColor: "var(--ds-muted, #f1f5f9)", color: "var(--ds-text-primary, #0f172a)", borderColor: "transparent" },
274
+ danger: { backgroundColor: "var(--ds-danger, #ef4444)", color: "#fff", borderColor: "transparent" },
275
+ warning: { backgroundColor: "var(--ds-warning, #f59e0b)", color: "#fff", borderColor: "transparent" },
276
+ info: { backgroundColor: "var(--ds-info, #3b82f6)", color: "#fff", borderColor: "transparent" },
277
+ success: { backgroundColor: "var(--ds-success, #22c55e)", color: "#fff", borderColor: "transparent" }
278
+ };
279
+ var variantHoverStyles = {
280
+ solid: { opacity: 0.88 },
281
+ outline: { backgroundColor: "var(--ds-muted, #f1f5f9)" },
282
+ ghost: { backgroundColor: "var(--ds-card, #ffffff)" },
283
+ danger: { opacity: 0.88 },
284
+ warning: { opacity: 0.88 },
285
+ info: { opacity: 0.88 },
286
+ success: { opacity: 0.88 }
287
+ };
288
+ var sizeStyles = {
289
+ sm: { padding: "0.25rem 0.625rem", fontSize: "0.8rem" },
290
+ md: { padding: "0.5rem 1rem", fontSize: "0.875rem" },
291
+ lg: { padding: "0.75rem 1.5rem", fontSize: "1rem" }
292
+ };
293
+ function injectSpinKeyframe() {
294
+ if (typeof document === "undefined") return;
295
+ if (document.getElementById("ds-spin-keyframe")) return;
296
+ const style = document.createElement("style");
297
+ style.id = "ds-spin-keyframe";
298
+ style.textContent = "@keyframes ds-spin { to { transform: rotate(360deg); } }";
299
+ document.head.appendChild(style);
300
+ }
234
301
  var Button = (_a) => {
235
302
  var _b = _a, {
236
303
  text,
@@ -249,7 +316,7 @@ var Button = (_a) => {
249
316
  small = false,
250
317
  large = false,
251
318
  size,
252
- className
319
+ style: styleProp
253
320
  } = _b, props = __objRest(_b, [
254
321
  "text",
255
322
  "children",
@@ -267,27 +334,45 @@ var Button = (_a) => {
267
334
  "small",
268
335
  "large",
269
336
  "size",
270
- "className"
337
+ "style"
271
338
  ]);
339
+ const [hovered, setHovered] = (0, import_react3.useState)(false);
340
+ (0, import_react3.useEffect)(() => {
341
+ injectSpinKeyframe();
342
+ }, []);
272
343
  const resolvedVariant = variant != null ? variant : danger ? "danger" : warning ? "warning" : info ? "info" : success ? "success" : ghost ? "ghost" : outline ? "outline" : "solid";
273
344
  const resolvedSize = size != null ? size : small ? "sm" : large ? "lg" : "md";
345
+ const isDisabled = disabled || loading;
274
346
  const content = children != null ? children : text;
275
347
  const showIcon = icon && !loading;
276
- const classes = [
277
- Button_default.button,
278
- Button_default[resolvedVariant],
279
- Button_default[resolvedSize],
280
- loading ? Button_default.loading : "",
281
- className != null ? className : ""
282
- ].filter(Boolean).join(" ");
348
+ const computedStyle = __spreadValues(__spreadValues(__spreadValues(__spreadValues({
349
+ display: "inline-flex",
350
+ alignItems: "center",
351
+ gap: "0.5rem",
352
+ border: "1px solid transparent",
353
+ borderRadius: "0.375rem",
354
+ fontWeight: 500,
355
+ cursor: isDisabled ? "not-allowed" : "pointer",
356
+ transition: "opacity 0.15s, background-color 0.15s",
357
+ opacity: isDisabled ? 0.5 : 1,
358
+ pointerEvents: loading ? "none" : void 0
359
+ }, variantStyles[resolvedVariant]), sizeStyles[resolvedSize]), hovered && !isDisabled ? variantHoverStyles[resolvedVariant] : {}), styleProp);
283
360
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
284
361
  "button",
285
362
  __spreadProps(__spreadValues({
286
- disabled: disabled || loading,
287
- className: classes
363
+ disabled: isDisabled,
364
+ style: computedStyle,
365
+ onMouseEnter: () => setHovered(true),
366
+ onMouseLeave: () => setHovered(false)
288
367
  }, props), {
289
368
  children: [
290
- loading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react4.LoaderCircle, { className: Button_default.spinner, "aria-hidden": true }) : null,
369
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
370
+ import_lucide_react4.LoaderCircle,
371
+ {
372
+ "aria-hidden": true,
373
+ style: { width: "1em", height: "1em", animation: "ds-spin 0.75s linear infinite" }
374
+ }
375
+ ) : null,
291
376
  showIcon && iconPosition === "left" ? icon : null,
292
377
  content,
293
378
  showIcon && iconPosition === "right" ? icon : null
@@ -295,7 +380,7 @@ var Button = (_a) => {
295
380
  })
296
381
  );
297
382
  };
298
- var Button_default2 = Button;
383
+ var Button_default = Button;
299
384
 
300
385
  // src/components/Card/Card.module.css
301
386
  var Card_default = {};
@@ -328,7 +413,7 @@ var CardFooter = (_a) => {
328
413
  };
329
414
 
330
415
  // src/components/Checkbox/Checkbox.tsx
331
- var import_react3 = require("react");
416
+ var import_react4 = require("react");
332
417
 
333
418
  // src/components/Checkbox/Checkbox.module.css
334
419
  var Checkbox_default = {};
@@ -343,7 +428,7 @@ var Checkbox = ({
343
428
  id,
344
429
  onChange
345
430
  }) => {
346
- const [internal, setInternal] = (0, import_react3.useState)(defaultChecked);
431
+ const [internal, setInternal] = (0, import_react4.useState)(defaultChecked);
347
432
  const isChecked = checked !== void 0 ? checked : internal;
348
433
  const handleChange = () => {
349
434
  if (disabled) return;
@@ -371,7 +456,7 @@ var Checkbox_default2 = Checkbox;
371
456
 
372
457
  // src/components/CopyButton/CopyButton.tsx
373
458
  var import_lucide_react5 = require("lucide-react");
374
- var import_react4 = require("react");
459
+ var import_react5 = require("react");
375
460
 
376
461
  // src/components/CopyButton/CopyButton.module.css
377
462
  var CopyButton_default = {};
@@ -379,7 +464,7 @@ var CopyButton_default = {};
379
464
  // src/components/CopyButton/CopyButton.tsx
380
465
  var import_jsx_runtime10 = require("react/jsx-runtime");
381
466
  var CopyButton = ({ text }) => {
382
- const [copied, setCopied] = (0, import_react4.useState)(false);
467
+ const [copied, setCopied] = (0, import_react5.useState)(false);
383
468
  const handleCopy = () => {
384
469
  navigator.clipboard.writeText(text);
385
470
  setCopied(true);
@@ -399,7 +484,7 @@ var CopyButton_default2 = CopyButton;
399
484
 
400
485
  // src/components/FileUpload/FileUpload.tsx
401
486
  var import_lucide_react6 = require("lucide-react");
402
- var import_react5 = require("react");
487
+ var import_react6 = require("react");
403
488
 
404
489
  // src/components/FileUpload/FileUpload.module.css
405
490
  var FileUpload_default = {};
@@ -407,9 +492,9 @@ var FileUpload_default = {};
407
492
  // src/components/FileUpload/FileUpload.tsx
408
493
  var import_jsx_runtime11 = require("react/jsx-runtime");
409
494
  var FileUpload = ({ accept, multiple, disabled, onFileSelect }) => {
410
- const [isDragging, setIsDragging] = (0, import_react5.useState)(false);
411
- const [fileNames, setFileNames] = (0, import_react5.useState)([]);
412
- const inputRef = (0, import_react5.useRef)(null);
495
+ const [isDragging, setIsDragging] = (0, import_react6.useState)(false);
496
+ const [fileNames, setFileNames] = (0, import_react6.useState)([]);
497
+ const inputRef = (0, import_react6.useRef)(null);
413
498
  const handleFiles = (list) => {
414
499
  setFileNames(Array.from(list).map((f) => f.name));
415
500
  onFileSelect == null ? void 0 : onFileSelect(list);
@@ -507,10 +592,10 @@ var Label_default2 = Label;
507
592
 
508
593
  // src/components/PasswordInput/PasswordInput.tsx
509
594
  var import_lucide_react7 = require("lucide-react");
510
- var import_react6 = require("react");
595
+ var import_react7 = require("react");
511
596
  var import_jsx_runtime14 = require("react/jsx-runtime");
512
597
  var PasswordInput = (props) => {
513
- const [visible, setVisible] = (0, import_react6.useState)(false);
598
+ const [visible, setVisible] = (0, import_react7.useState)(false);
514
599
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
515
600
  Input_default2,
516
601
  __spreadProps(__spreadValues({}, props), {
@@ -552,7 +637,7 @@ var Progress = ({ value = 0 }) => {
552
637
  var Progress_default2 = Progress;
553
638
 
554
639
  // src/components/RadioGroup/RadioGroup.tsx
555
- var import_react7 = require("react");
640
+ var import_react8 = require("react");
556
641
 
557
642
  // src/components/RadioGroup/RadioGroup.module.css
558
643
  var RadioGroup_default = {};
@@ -567,7 +652,7 @@ var RadioGroup = ({
567
652
  disabled,
568
653
  onChange
569
654
  }) => {
570
- const [internal, setInternal] = (0, import_react7.useState)(defaultValue);
655
+ const [internal, setInternal] = (0, import_react8.useState)(defaultValue);
571
656
  const selected = value !== void 0 ? value : internal;
572
657
  const handleChange = (val) => {
573
658
  if (disabled) return;
@@ -602,7 +687,7 @@ var RadioGroup_default2 = RadioGroup;
602
687
 
603
688
  // src/components/Select/Select.tsx
604
689
  var import_lucide_react8 = require("lucide-react");
605
- var import_react8 = require("react");
690
+ var import_react9 = require("react");
606
691
 
607
692
  // src/components/Select/Select.module.css
608
693
  var Select_default = {};
@@ -618,9 +703,9 @@ var Select = ({
618
703
  onChange
619
704
  }) => {
620
705
  var _a;
621
- const [internal, setInternal] = (0, import_react8.useState)(defaultValue);
622
- const [open, setOpen] = (0, import_react8.useState)(false);
623
- const ref = (0, import_react8.useRef)(null);
706
+ const [internal, setInternal] = (0, import_react9.useState)(defaultValue);
707
+ const [open, setOpen] = (0, import_react9.useState)(false);
708
+ const ref = (0, import_react9.useRef)(null);
624
709
  const selected = value !== void 0 ? value : internal;
625
710
  const selectedLabel = (_a = options.find((o) => o.value === selected)) == null ? void 0 : _a.label;
626
711
  const handleSelect = (val) => {
@@ -628,7 +713,7 @@ var Select = ({
628
713
  setOpen(false);
629
714
  onChange == null ? void 0 : onChange(val);
630
715
  };
631
- (0, import_react8.useEffect)(() => {
716
+ (0, import_react9.useEffect)(() => {
632
717
  const handleOutside = (e) => {
633
718
  if (ref.current && !ref.current.contains(e.target)) setOpen(false);
634
719
  };
@@ -681,7 +766,7 @@ var Skeleton = ({ height = "1rem", width = "100%", circle = false }) => /* @__PU
681
766
  var Skeleton_default2 = Skeleton;
682
767
 
683
768
  // src/components/Slider/Slider.tsx
684
- var import_react9 = require("react");
769
+ var import_react10 = require("react");
685
770
 
686
771
  // src/components/Slider/Slider.module.css
687
772
  var Slider_default = {};
@@ -697,7 +782,7 @@ var Slider = ({
697
782
  disabled,
698
783
  onChange
699
784
  }) => {
700
- const [internal, setInternal] = (0, import_react9.useState)(defaultValue);
785
+ const [internal, setInternal] = (0, import_react10.useState)(defaultValue);
701
786
  const current = value !== void 0 ? value : internal;
702
787
  const fill = `${(current - min) / (max - min) * 100}%`;
703
788
  const handleChange = (e) => {
@@ -735,7 +820,7 @@ var Spinner = ({ size = "md" }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)
735
820
  var Spinner_default2 = Spinner;
736
821
 
737
822
  // src/components/Switch/Switch.tsx
738
- var import_react10 = require("react");
823
+ var import_react11 = require("react");
739
824
 
740
825
  // src/components/Switch/Switch.module.css
741
826
  var Switch_default = {};
@@ -750,7 +835,7 @@ var Switch = ({
750
835
  id,
751
836
  onChange
752
837
  }) => {
753
- const [internal, setInternal] = (0, import_react10.useState)(defaultChecked);
838
+ const [internal, setInternal] = (0, import_react11.useState)(defaultChecked);
754
839
  const isOn = checked !== void 0 ? checked : internal;
755
840
  const handleToggle = () => {
756
841
  if (disabled) return;
@@ -801,7 +886,7 @@ var TableCell = (_a) => {
801
886
  };
802
887
 
803
888
  // src/components/Tabs/Tabs.tsx
804
- var import_react11 = require("react");
889
+ var import_react12 = require("react");
805
890
 
806
891
  // src/components/Tabs/Tabs.module.css
807
892
  var Tabs_default = {};
@@ -810,7 +895,7 @@ var Tabs_default = {};
810
895
  var import_jsx_runtime23 = require("react/jsx-runtime");
811
896
  var Tabs = ({ tabs, defaultValue }) => {
812
897
  var _a, _b;
813
- const [active, setActive] = (0, import_react11.useState)((_b = defaultValue != null ? defaultValue : (_a = tabs[0]) == null ? void 0 : _a.value) != null ? _b : "");
898
+ const [active, setActive] = (0, import_react12.useState)((_b = defaultValue != null ? defaultValue : (_a = tabs[0]) == null ? void 0 : _a.value) != null ? _b : "");
814
899
  const activeTab = tabs.find((t) => t.value === active);
815
900
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: Tabs_default.root, children: [
816
901
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: Tabs_default.list, role: "tablist", children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(