@ksojecki/purpose-ui 0.3.1 → 0.4.0-next.20261201202812

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.
Files changed (70) hide show
  1. package/README.md +4 -0
  2. package/dist/actions/Button.d.ts +2 -0
  3. package/dist/actions/IconActionButtons.d.ts +2 -0
  4. package/dist/actions/index.js +3 -40
  5. package/dist/actions-muI1GKgz.js +40 -0
  6. package/dist/css-C1oojmN3.js +602 -0
  7. package/dist/data/Avatar.d.ts +10 -2
  8. package/dist/data/DataTable.d.ts +5 -1
  9. package/dist/data/Metric.d.ts +15 -3
  10. package/dist/data/Table.d.ts +6 -1
  11. package/dist/feedback/Alert.d.ts +11 -2
  12. package/dist/feedback/Badge.d.ts +7 -1
  13. package/dist/feedback/ConfirmDeletePanel.d.ts +5 -1
  14. package/dist/feedback/EmptyState.d.ts +5 -1
  15. package/dist/feedback/Progress.d.ts +10 -2
  16. package/dist/feedback/Spinner.d.ts +1 -0
  17. package/dist/feedback/Toast.d.ts +6 -1
  18. package/dist/feedback/Tooltip.d.ts +1 -0
  19. package/dist/feedback/index.js +1 -1
  20. package/dist/forms/Checkbox.d.ts +1 -0
  21. package/dist/forms/ColorInput.d.ts +33 -0
  22. package/dist/forms/Field.d.ts +1 -0
  23. package/dist/forms/FileInput.d.ts +30 -5
  24. package/dist/forms/FilterRow.d.ts +1 -0
  25. package/dist/forms/FormActions.d.ts +5 -1
  26. package/dist/forms/Input.d.ts +6 -1
  27. package/dist/forms/Radio.d.ts +2 -0
  28. package/dist/forms/Range.d.ts +2 -0
  29. package/dist/forms/SegmentedControl.d.ts +5 -1
  30. package/dist/forms/Select.d.ts +6 -1
  31. package/dist/forms/Textarea.d.ts +6 -1
  32. package/dist/forms/TimePicker.d.ts +1 -0
  33. package/dist/forms/index.d.ts +1 -0
  34. package/dist/forms/index.js +464 -146
  35. package/dist/hex-BZsMkL37.js +10 -0
  36. package/dist/internal/FileDropContent.d.ts +15 -0
  37. package/dist/internal/fileAccept.d.ts +5 -0
  38. package/dist/internal/fileSize.d.ts +2 -0
  39. package/dist/internal/hex.d.ts +4 -0
  40. package/dist/internal/theme-generator/cli.d.ts +16 -0
  41. package/dist/internal/theme-generator/color.d.ts +13 -0
  42. package/dist/internal/theme-generator/config.d.ts +51 -0
  43. package/dist/internal/theme-generator/contrast.d.ts +18 -0
  44. package/dist/internal/theme-generator/css.d.ts +7 -0
  45. package/dist/internal/theme-generator/derive.d.ts +20 -0
  46. package/dist/internal/theme-generator/roles.d.ts +10 -0
  47. package/dist/internal/theme-generator/tokens.d.ts +7 -0
  48. package/dist/internal/useFileDrop.d.ts +23 -0
  49. package/dist/internal/useFileSelection.d.ts +10 -0
  50. package/dist/internal/useHexDraft.d.ts +12 -0
  51. package/dist/internal/useInputNode.d.ts +3 -0
  52. package/dist/layout/BottomSheet.d.ts +5 -1
  53. package/dist/layout/Card.d.ts +6 -1
  54. package/dist/layout/Disclosure.d.ts +1 -0
  55. package/dist/layout/Divider.d.ts +6 -1
  56. package/dist/layout/PageContainer.d.ts +1 -0
  57. package/dist/layout/PageHeader.d.ts +5 -1
  58. package/dist/layout/Section.d.ts +5 -1
  59. package/dist/navigation/Dropdown.d.ts +13 -2
  60. package/dist/navigation/Link.d.ts +7 -1
  61. package/dist/navigation/Menu.d.ts +9 -1
  62. package/dist/overlays/ModalWindow/ModalWindow.d.ts +7 -1
  63. package/dist/theme-generator/cli.d.ts +2 -0
  64. package/dist/theme-generator/cli.js +128 -0
  65. package/dist/theme-generator/index.d.ts +9 -0
  66. package/dist/theme-generator/index.js +3 -0
  67. package/dist/typography/Heading/Heading.d.ts +5 -1
  68. package/dist/typography/Paragraph.d.ts +1 -0
  69. package/package.json +16 -4
  70. package/theme-config.schema.json +124 -0
package/README.md CHANGED
@@ -10,6 +10,8 @@ Documentation, with live examples and props for every component: [sojecki.pl/ui]
10
10
  pnpm add @ksojecki/purpose-ui react react-dom react-router daisyui tailwindcss
11
11
  ```
12
12
 
13
+ Dev builds from the `next` branch are on npmjs too: `pnpm add @ksojecki/purpose-ui@next`.
14
+
13
15
  Peer dependencies: `react` and `react-dom` ^19, `react-router` ^8, `daisyui` ^5.6.0, `tailwindcss` ^4. The package is ESM only. `FormField` takes the result of react-hook-form's `register()` but does not depend on that package.
14
16
 
15
17
  ## Set up styles
@@ -27,6 +29,8 @@ Palettes: `generic`, `budget`, `traffic`, `roadsign`. Each defines a light theme
27
29
 
28
30
  To compose the pieces yourself, import `@ksojecki/purpose-ui/theme.css` and one `@ksojecki/purpose-ui/themes/<name>.css` after `@plugin 'daisyui' { themes: false; }`, and add `@source '../node_modules/@ksojecki/purpose-ui/dist';`.
29
31
 
32
+ For your own palette, keep a `purpose-ui.theme.json` in your repository and run `npx purpose-ui-theme build purpose-ui.theme.json -o src/<name>.theme.css`; the [theme generator](https://sojecki.pl/ui/theme-generator/) builds and previews the config.
33
+
30
34
  ## Use
31
35
 
32
36
  Import from a group subpath, never from the package root.
@@ -5,7 +5,9 @@ export type ButtonVariant = 'solid' | 'soft' | 'outline';
5
5
  export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
6
6
  export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
7
7
  children: ReactNode;
8
+ /** @default false */
8
9
  fullWidth?: boolean;
10
+ /** @default false */
9
11
  isLoading?: boolean;
10
12
  /** Semantic action meaning. Apps should prefer `purpose` over `tone`. */
11
13
  purpose?: ActionPurpose;
@@ -1,7 +1,9 @@
1
1
  import { type IconButtonProps } from './IconButton';
2
2
  import type { ButtonTone } from './Button';
3
3
  type IconActionButtonProps = Omit<IconButtonProps, 'icon' | 'tone' | 'variant'> & {
4
+ /** @default 'neutral' for EditButton, 'error' for DeleteButton, 'primary' for NewButton */
4
5
  tone?: ButtonTone;
6
+ /** @default 'soft', or 'solid' when tone is 'ghost' */
5
7
  variant?: IconButtonProps['variant'];
6
8
  };
7
9
  /**
@@ -1,41 +1,4 @@
1
1
  import { a as e, i as t, n, r, s as i, t as a } from "../Button-T8UI5igR.js";
2
- import { t as o } from "../classNames-x6JVYA2t.js";
3
- import { t as s } from "../IconButton-P7nSooA3.js";
4
- import { t as c } from "../icons-CMOARHwx.js";
5
- import { Children as l, cloneElement as u, isValidElement as d } from "react";
6
- import { jsx as f } from "react/jsx-runtime";
7
- // src/actions/ButtonGroup.tsx
8
- function p({ children: e, className: t, label: n }) {
9
- return /* @__PURE__ */ f("div", {
10
- "aria-label": n,
11
- className: o("join", t),
12
- role: n ? "group" : void 0,
13
- children: l.map(e, (e) => d(e) ? u(e, { className: o("join-item", e.props.className) }) : e)
14
- });
15
- }
16
- // src/actions/IconActionButtons.tsx
17
- function m({ tone: e = "neutral", variant: t = e === "ghost" ? "solid" : "soft", ...n }) {
18
- return /* @__PURE__ */ f(s, {
19
- ...n,
20
- icon: /* @__PURE__ */ f(c.TbPencil, {}),
21
- tone: e,
22
- variant: t
23
- });
24
- }
25
- function h({ tone: e = "error", variant: t = e === "ghost" ? "solid" : "soft", ...n }) {
26
- return /* @__PURE__ */ f(s, {
27
- ...n,
28
- icon: /* @__PURE__ */ f(c.TbTrash, {}),
29
- tone: e,
30
- variant: t
31
- });
32
- }
33
- function g({ tone: e = "primary", variant: t = e === "ghost" ? "solid" : "soft", ...n }) {
34
- return /* @__PURE__ */ f(s, {
35
- ...n,
36
- icon: /* @__PURE__ */ f(c.TbPlus, {}),
37
- tone: e,
38
- variant: t
39
- });
40
- }
41
- export { i as ACTION_PURPOSES, a as Button, p as ButtonGroup, n as ButtonSizeProvider, h as DeleteButton, m as EditButton, s as IconButton, g as NewButton, r as buttonClassName, t as resolveButtonStyle, e as useButtonSize };
2
+ import { i as o, n as s, r as c, t as l } from "../actions-muI1GKgz.js";
3
+ import { t as u } from "../IconButton-P7nSooA3.js";
4
+ export { i as ACTION_PURPOSES, a as Button, o as ButtonGroup, n as ButtonSizeProvider, l as DeleteButton, s as EditButton, u as IconButton, c as NewButton, r as buttonClassName, t as resolveButtonStyle, e as useButtonSize };
@@ -0,0 +1,40 @@
1
+ import { t as e } from "./classNames-x6JVYA2t.js";
2
+ import { t } from "./IconButton-P7nSooA3.js";
3
+ import { t as n } from "./icons-CMOARHwx.js";
4
+ import { Children as r, cloneElement as i, isValidElement as a } from "react";
5
+ import { jsx as o } from "react/jsx-runtime";
6
+ // src/actions/ButtonGroup.tsx
7
+ function s({ children: t, className: n, label: s }) {
8
+ return /* @__PURE__ */ o("div", {
9
+ "aria-label": s,
10
+ className: e("join", n),
11
+ role: s ? "group" : void 0,
12
+ children: r.map(t, (t) => a(t) ? i(t, { className: e("join-item", t.props.className) }) : t)
13
+ });
14
+ }
15
+ // src/actions/IconActionButtons.tsx
16
+ function c({ tone: e = "neutral", variant: r = e === "ghost" ? "solid" : "soft", ...i }) {
17
+ return /* @__PURE__ */ o(t, {
18
+ ...i,
19
+ icon: /* @__PURE__ */ o(n.TbPencil, {}),
20
+ tone: e,
21
+ variant: r
22
+ });
23
+ }
24
+ function l({ tone: e = "error", variant: r = e === "ghost" ? "solid" : "soft", ...i }) {
25
+ return /* @__PURE__ */ o(t, {
26
+ ...i,
27
+ icon: /* @__PURE__ */ o(n.TbTrash, {}),
28
+ tone: e,
29
+ variant: r
30
+ });
31
+ }
32
+ function u({ tone: e = "primary", variant: r = e === "ghost" ? "solid" : "soft", ...i }) {
33
+ return /* @__PURE__ */ o(t, {
34
+ ...i,
35
+ icon: /* @__PURE__ */ o(n.TbPlus, {}),
36
+ tone: e,
37
+ variant: r
38
+ });
39
+ }
40
+ export { s as i, c as n, u as r, l as t };