@usefidel/design-system 0.6.0 → 0.8.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/dist/admin.css CHANGED
@@ -47,11 +47,14 @@
47
47
  --font-display: 'Rethink Sans', system-ui, -apple-system, sans-serif;
48
48
  --font-body: 'Rethink Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
49
49
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
50
- --radius-xs: 4px;
51
- --radius-sm: 6px;
52
- --radius-md: 8px;
53
- --radius-lg: 12px;
54
- --radius-xl: 16px;
50
+ --radius-none: 0px;
51
+ --radius-xs: 2px;
52
+ --radius-sm: 4px;
53
+ --radius-md: 6px;
54
+ --radius-lg: 8px;
55
+ --radius-xl: 12px;
56
+ --radius-2xl: 16px;
57
+ --radius-3xl: 24px;
55
58
  --radius-pill: 9999px;
56
59
  --radius-full: 9999px;
57
60
  --spacing-1: 4px;
@@ -47,11 +47,14 @@
47
47
  --font-display: 'Rethink Sans', system-ui, -apple-system, sans-serif;
48
48
  --font-body: 'Rethink Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
49
49
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
50
- --radius-xs: 4px;
51
- --radius-sm: 6px;
52
- --radius-md: 8px;
53
- --radius-lg: 12px;
54
- --radius-xl: 16px;
50
+ --radius-none: 0px;
51
+ --radius-xs: 2px;
52
+ --radius-sm: 4px;
53
+ --radius-md: 6px;
54
+ --radius-lg: 8px;
55
+ --radius-xl: 12px;
56
+ --radius-2xl: 16px;
57
+ --radius-3xl: 24px;
55
58
  --radius-pill: 20px;
56
59
  --radius-full: 9999px;
57
60
  --spacing-1: 4px;
@@ -10,6 +10,6 @@
10
10
  "webapp.css"
11
11
  ],
12
12
  "storybookUrl": null,
13
- "packageVersion": "0.6.0",
14
- "resolvedSha": "e08dca273c717cf832900a20e846f8e5e955a1e3"
13
+ "packageVersion": "0.8.0",
14
+ "resolvedSha": "1a2e0a8e9eade08e784d399b84e42bea85723137"
15
15
  }
package/dist/icons.cjs ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+
17
+ // src/icons.ts
18
+ var icons_exports = {};
19
+ module.exports = __toCommonJS(icons_exports);
20
+ __reExport(icons_exports, require("lucide-react"), module.exports);
21
+ // Annotate the CommonJS export names for ESM import in node:
22
+ 0 && (module.exports = {
23
+ ...require("lucide-react")
24
+ });
@@ -0,0 +1 @@
1
+ export * from 'lucide-react';
@@ -0,0 +1 @@
1
+ export * from 'lucide-react';
package/dist/icons.js ADDED
@@ -0,0 +1,2 @@
1
+ // src/icons.ts
2
+ export * from "lucide-react";
package/dist/index.cjs CHANGED
@@ -21,8 +21,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  Button: () => Button,
24
+ DiffPropertyList: () => DiffPropertyList,
24
25
  DiffSection: () => DiffSection,
25
- MismatchCard: () => MismatchCard
26
+ MismatchCard: () => MismatchCard,
27
+ Select: () => Select,
28
+ Toggle: () => Toggle
26
29
  });
27
30
  module.exports = __toCommonJS(index_exports);
28
31
 
@@ -202,14 +205,7 @@ function ElementRow({
202
205
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "fds-diff-section__element-count", children: plural(element.properties.length, "property", "properties") }),
203
206
  hasDetail && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Chevron2, { open, className: "fds-diff-section__element-caret" })
204
207
  ] }),
205
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "fds-diff-section__lines", children: element.properties.map((line, li) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "fds-diff-section__line", children: [
206
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "fds-diff-section__prop", children: line.property }),
207
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "fds-diff-section__delta", children: [
208
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "fds-diff-section__live", children: line.live }),
209
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Arrow, {}),
210
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "fds-diff-section__design", children: line.design })
211
- ] })
212
- ] }, `${line.property}-${li}`)) })
208
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DiffPropertyList, { properties: element.properties })
213
209
  ] });
214
210
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
215
211
  "div",
@@ -236,6 +232,18 @@ function ElementRow({
236
232
  }
237
233
  );
238
234
  }
235
+ function DiffPropertyList({ properties, className, ...rest }) {
236
+ const classes = ["fds-diff-section__lines", className].filter(Boolean).join(" ");
237
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: classes, ...rest, children: properties.map((line, li) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "fds-diff-section__line", children: [
238
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "fds-diff-section__prop", children: line.property }),
239
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "fds-diff-section__delta", children: [
240
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "fds-diff-section__live", children: line.live }),
241
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Arrow, {}),
242
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "fds-diff-section__design", children: line.design })
243
+ ] }),
244
+ line.trailing != null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "fds-diff-section__trailing", children: line.trailing })
245
+ ] }, `${line.property}-${li}`)) });
246
+ }
239
247
  function Chevron2({ open, className }) {
240
248
  const classes = [
241
249
  "fds-diff-section__chevron",
@@ -276,9 +284,274 @@ function Arrow() {
276
284
  }
277
285
  );
278
286
  }
287
+
288
+ // src/components/Select/Select.tsx
289
+ var import_react3 = require("react");
290
+ var import_jsx_runtime4 = require("react/jsx-runtime");
291
+ function ChevronIcon() {
292
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { viewBox: "0 0 20 20", width: "18", height: "18", fill: "none", "aria-hidden": "true", className: "fds-select__chevronIcon", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M6 8l4 4 4-4", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) });
293
+ }
294
+ function CheckIcon() {
295
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { viewBox: "0 0 20 20", width: "18", height: "18", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M4.5 10.5l3 3 8-8.5", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) });
296
+ }
297
+ var Select = (0, import_react3.forwardRef)(function Select2({
298
+ options,
299
+ value,
300
+ onChange,
301
+ placeholder = "Select\u2026",
302
+ label,
303
+ hint,
304
+ error,
305
+ disabled = false,
306
+ searchable = false,
307
+ searchPlaceholder = "Search\u2026",
308
+ leadingIcon,
309
+ id,
310
+ name,
311
+ className,
312
+ containerClassName
313
+ }, ref) {
314
+ const genId = (0, import_react3.useId)();
315
+ const triggerId = id ?? genId;
316
+ const listId = `${genId}-list`;
317
+ const msgId = `${genId}-msg`;
318
+ const rootRef = (0, import_react3.useRef)(null);
319
+ const triggerRef = (0, import_react3.useRef)(null);
320
+ const listRef = (0, import_react3.useRef)(null);
321
+ const searchRef = (0, import_react3.useRef)(null);
322
+ (0, import_react3.useImperativeHandle)(ref, () => triggerRef.current, []);
323
+ const [open, setOpen] = (0, import_react3.useState)(false);
324
+ const [query, setQuery] = (0, import_react3.useState)("");
325
+ const [activeIndex, setActiveIndex] = (0, import_react3.useState)(-1);
326
+ const selected = options.find((o) => o.value === value) ?? null;
327
+ const filtered = (0, import_react3.useMemo)(() => {
328
+ if (!searchable || !query.trim()) return options;
329
+ const q = query.trim().toLowerCase();
330
+ return options.filter(
331
+ (o) => o.label.toLowerCase().includes(q) || (o.secondary?.toLowerCase().includes(q) ?? false)
332
+ );
333
+ }, [options, searchable, query]);
334
+ const hasMessage = Boolean(error ?? hint);
335
+ const firstEnabled = (list) => list.findIndex((o) => !o.disabled);
336
+ (0, import_react3.useEffect)(() => {
337
+ if (!open) return;
338
+ const onDown = (e) => {
339
+ if (rootRef.current && !rootRef.current.contains(e.target)) setOpen(false);
340
+ };
341
+ document.addEventListener("mousedown", onDown);
342
+ return () => document.removeEventListener("mousedown", onDown);
343
+ }, [open]);
344
+ (0, import_react3.useEffect)(() => {
345
+ if (!open) {
346
+ setQuery("");
347
+ return;
348
+ }
349
+ const selIdx = filtered.findIndex((o) => o.value === value);
350
+ setActiveIndex(selIdx >= 0 ? selIdx : firstEnabled(filtered));
351
+ const raf = requestAnimationFrame(() => {
352
+ if (searchable) searchRef.current?.focus();
353
+ else listRef.current?.focus();
354
+ });
355
+ return () => cancelAnimationFrame(raf);
356
+ }, [open]);
357
+ const close = () => {
358
+ setOpen(false);
359
+ triggerRef.current?.focus();
360
+ };
361
+ const move = (dir) => {
362
+ setActiveIndex((prev) => {
363
+ if (filtered.length === 0) return -1;
364
+ let i = prev;
365
+ for (let k = 0; k < filtered.length; k++) {
366
+ i = (i + dir + filtered.length) % filtered.length;
367
+ if (!filtered[i].disabled) return i;
368
+ }
369
+ return prev;
370
+ });
371
+ };
372
+ const choose = (i) => {
373
+ const o = filtered[i];
374
+ if (o && !o.disabled) {
375
+ onChange?.(o.value);
376
+ close();
377
+ }
378
+ };
379
+ const onKeyDown = (e) => {
380
+ if (!open) {
381
+ if (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Enter" || e.key === " ") {
382
+ e.preventDefault();
383
+ setOpen(true);
384
+ }
385
+ return;
386
+ }
387
+ if (e.key === "ArrowDown") {
388
+ e.preventDefault();
389
+ move(1);
390
+ } else if (e.key === "ArrowUp") {
391
+ e.preventDefault();
392
+ move(-1);
393
+ } else if (e.key === "Home") {
394
+ e.preventDefault();
395
+ setActiveIndex(firstEnabled(filtered));
396
+ } else if (e.key === "End") {
397
+ e.preventDefault();
398
+ for (let i = filtered.length - 1; i >= 0; i--) {
399
+ if (!filtered[i].disabled) {
400
+ setActiveIndex(i);
401
+ break;
402
+ }
403
+ }
404
+ } else if (e.key === "Enter") {
405
+ e.preventDefault();
406
+ choose(activeIndex);
407
+ } else if (e.key === "Escape") {
408
+ e.preventDefault();
409
+ close();
410
+ }
411
+ };
412
+ const triggerClasses = [
413
+ "fds-select__trigger",
414
+ error ? "fds-select__trigger--error" : "",
415
+ open ? "fds-select__trigger--open" : "",
416
+ className
417
+ ].filter(Boolean).join(" ");
418
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
419
+ "div",
420
+ {
421
+ ref: rootRef,
422
+ className: ["fds-select-field", containerClassName].filter(Boolean).join(" "),
423
+ children: [
424
+ label != null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: triggerId, className: "fds-select__label", children: label }),
425
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "fds-select", children: [
426
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
427
+ "button",
428
+ {
429
+ type: "button",
430
+ id: triggerId,
431
+ ref: triggerRef,
432
+ className: triggerClasses,
433
+ disabled,
434
+ "aria-haspopup": "listbox",
435
+ "aria-expanded": open,
436
+ "aria-controls": open ? listId : void 0,
437
+ "aria-invalid": error ? true : void 0,
438
+ "aria-describedby": hasMessage ? msgId : void 0,
439
+ onClick: () => !disabled && setOpen((o) => !o),
440
+ onKeyDown,
441
+ children: [
442
+ (selected?.avatar ?? leadingIcon) != null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "fds-select__lead", children: selected?.avatar ?? leadingIcon }),
443
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
444
+ "span",
445
+ {
446
+ className: `fds-select__value${selected ? "" : " fds-select__value--placeholder"}`,
447
+ children: selected ? selected.label : placeholder
448
+ }
449
+ ),
450
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "fds-select__chevron", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChevronIcon, {}) })
451
+ ]
452
+ }
453
+ ),
454
+ open && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "fds-select__popover", children: [
455
+ searchable && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "fds-select__search", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
456
+ "input",
457
+ {
458
+ ref: searchRef,
459
+ className: "fds-select__searchInput",
460
+ placeholder: searchPlaceholder,
461
+ value: query,
462
+ onChange: (e) => setQuery(e.target.value),
463
+ onKeyDown,
464
+ role: "combobox",
465
+ "aria-expanded": true,
466
+ "aria-controls": listId,
467
+ "aria-autocomplete": "list"
468
+ }
469
+ ) }),
470
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
471
+ "div",
472
+ {
473
+ ref: listRef,
474
+ id: listId,
475
+ role: "listbox",
476
+ tabIndex: searchable ? -1 : 0,
477
+ className: "fds-select__list",
478
+ "aria-activedescendant": activeIndex >= 0 ? `${listId}-opt-${activeIndex}` : void 0,
479
+ onKeyDown: searchable ? void 0 : onKeyDown,
480
+ children: [
481
+ filtered.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "fds-select__empty", children: "No results" }),
482
+ filtered.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
483
+ "div",
484
+ {
485
+ id: `${listId}-opt-${i}`,
486
+ role: "option",
487
+ "aria-selected": o.value === value,
488
+ "aria-disabled": o.disabled || void 0,
489
+ className: [
490
+ "fds-select__option",
491
+ i === activeIndex ? "fds-select__option--active" : "",
492
+ o.disabled ? "fds-select__option--disabled" : ""
493
+ ].filter(Boolean).join(" "),
494
+ onMouseEnter: () => !o.disabled && setActiveIndex(i),
495
+ onMouseDown: (e) => e.preventDefault(),
496
+ onClick: () => choose(i),
497
+ children: [
498
+ o.avatar != null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "fds-select__optAvatar", children: o.avatar }),
499
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "fds-select__optText", children: [
500
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "fds-select__optLabel", children: o.label }),
501
+ o.secondary != null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "fds-select__optSecondary", children: o.secondary })
502
+ ] }),
503
+ o.value === value && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "fds-select__check", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckIcon, {}) })
504
+ ]
505
+ },
506
+ o.value
507
+ ))
508
+ ]
509
+ }
510
+ )
511
+ ] })
512
+ ] }),
513
+ hasMessage && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { id: msgId, className: error ? "fds-select__error" : "fds-select__hint", children: error ?? hint }),
514
+ name != null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "hidden", name, value: value ?? "" })
515
+ ]
516
+ }
517
+ );
518
+ });
519
+
520
+ // src/components/Toggle/Toggle.tsx
521
+ var import_react4 = require("react");
522
+ var import_jsx_runtime5 = require("react/jsx-runtime");
523
+ var Toggle = (0, import_react4.forwardRef)(function Toggle2({ size = "medium", label, description, className, id, disabled, ...rest }, ref) {
524
+ const generatedId = (0, import_react4.useId)();
525
+ const inputId = id ?? generatedId;
526
+ const classes = ["fds-toggle", `fds-toggle--${size}`, className].filter(Boolean).join(" ");
527
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: classes, "data-disabled": disabled ? "" : void 0, children: [
528
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
529
+ "input",
530
+ {
531
+ ...rest,
532
+ id: inputId,
533
+ ref,
534
+ type: "checkbox",
535
+ role: "switch",
536
+ disabled,
537
+ className: "fds-toggle__input"
538
+ }
539
+ ),
540
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { htmlFor: inputId, className: "fds-toggle__control", children: [
541
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "fds-toggle__track", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "fds-toggle__thumb" }) }),
542
+ (label != null || description != null) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "fds-toggle__text", children: [
543
+ label != null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "fds-toggle__label", children: label }),
544
+ description != null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "fds-toggle__description", children: description })
545
+ ] })
546
+ ] })
547
+ ] });
548
+ });
279
549
  // Annotate the CommonJS export names for ESM import in node:
280
550
  0 && (module.exports = {
281
551
  Button,
552
+ DiffPropertyList,
282
553
  DiffSection,
283
- MismatchCard
554
+ MismatchCard,
555
+ Select,
556
+ Toggle
284
557
  });