@ksojecki/purpose-ui 0.3.2 → 0.4.0-next.20261201202918

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 (39) hide show
  1. package/README.md +4 -0
  2. package/dist/NavMenu-RGC0FklO.js +127 -0
  3. package/dist/actions/index.js +3 -40
  4. package/dist/actions-muI1GKgz.js +40 -0
  5. package/dist/css-C1oojmN3.js +602 -0
  6. package/dist/feedback/index.js +1 -1
  7. package/dist/forms/ColorInput.d.ts +33 -0
  8. package/dist/forms/FileInput.d.ts +25 -5
  9. package/dist/forms/index.d.ts +1 -0
  10. package/dist/forms/index.js +464 -146
  11. package/dist/hex-BZsMkL37.js +10 -0
  12. package/dist/internal/FileDropContent.d.ts +15 -0
  13. package/dist/internal/fileAccept.d.ts +5 -0
  14. package/dist/internal/fileSize.d.ts +2 -0
  15. package/dist/internal/hex.d.ts +4 -0
  16. package/dist/internal/theme-generator/cli.d.ts +16 -0
  17. package/dist/internal/theme-generator/color.d.ts +13 -0
  18. package/dist/internal/theme-generator/config.d.ts +51 -0
  19. package/dist/internal/theme-generator/contrast.d.ts +18 -0
  20. package/dist/internal/theme-generator/css.d.ts +7 -0
  21. package/dist/internal/theme-generator/derive.d.ts +20 -0
  22. package/dist/internal/theme-generator/roles.d.ts +10 -0
  23. package/dist/internal/theme-generator/tokens.d.ts +7 -0
  24. package/dist/internal/useFileDrop.d.ts +23 -0
  25. package/dist/internal/useFileSelection.d.ts +10 -0
  26. package/dist/internal/useHexDraft.d.ts +12 -0
  27. package/dist/internal/useInputNode.d.ts +3 -0
  28. package/dist/layout/Footer.d.ts +28 -0
  29. package/dist/layout/Navbar.d.ts +33 -0
  30. package/dist/layout/PublicLayout.d.ts +33 -0
  31. package/dist/layout/index.d.ts +3 -0
  32. package/dist/layout/index.js +275 -77
  33. package/dist/navigation/index.js +3 -127
  34. package/dist/theme-generator/cli.d.ts +2 -0
  35. package/dist/theme-generator/cli.js +128 -0
  36. package/dist/theme-generator/index.d.ts +9 -0
  37. package/dist/theme-generator/index.js +3 -0
  38. package/package.json +15 -4
  39. 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.
@@ -0,0 +1,127 @@
1
+ import { t as e } from "./Button-T8UI5igR.js";
2
+ import { t } from "./classNames-x6JVYA2t.js";
3
+ import { a as n, i as r, n as i, r as a } from "./Dropdown-BZKzAbKB.js";
4
+ import { cloneElement as o, createElement as s, useEffect as c, useId as l, useRef as u, useState as d } from "react";
5
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
6
+ import { NavLink as h } from "react-router";
7
+ // src/navigation/Menu.tsx
8
+ var g = {
9
+ xs: "menu-xs",
10
+ sm: "menu-sm",
11
+ md: "",
12
+ lg: "menu-lg"
13
+ };
14
+ function _({ children: e, className: n, horizontal: r = !1, size: i = "md" }) {
15
+ return /* @__PURE__ */ p("ul", {
16
+ className: t("menu", r ? "menu-horizontal" : void 0, g[i], n),
17
+ children: e
18
+ });
19
+ }
20
+ function v(e) {
21
+ return e.type === "a" || e.props.href !== void 0 || e.props.to !== void 0;
22
+ }
23
+ function y(e, t) {
24
+ let { href: n, onClick: r, to: i, ...a } = e.props;
25
+ return s("a", {
26
+ ...a,
27
+ "aria-disabled": !0,
28
+ className: t,
29
+ role: "link"
30
+ });
31
+ }
32
+ function b({ children: e, active: n = !1, disabled: r = !1 }) {
33
+ let i = t(e.props.className, n ? "menu-active" : void 0, r ? "menu-disabled" : void 0);
34
+ return r && v(e) ? /* @__PURE__ */ p("li", { children: y(e, i) }) : r ? /* @__PURE__ */ p("li", { children: o(e, {
35
+ className: i,
36
+ disabled: !0
37
+ }) }) : /* @__PURE__ */ p("li", { children: o(e, { className: i || void 0 }) });
38
+ }
39
+ function x(e) {
40
+ return /* @__PURE__ */ p("button", {
41
+ type: "button",
42
+ ...e
43
+ });
44
+ }
45
+ function S({ children: e }) {
46
+ return /* @__PURE__ */ p("li", {
47
+ className: "menu-title",
48
+ children: e
49
+ });
50
+ }
51
+ function C({ children: e, end: t = !1, to: n }) {
52
+ return /* @__PURE__ */ p("li", { children: /* @__PURE__ */ p(h, {
53
+ className: ({ isActive: e }) => e ? "menu-active" : "",
54
+ end: t,
55
+ to: n,
56
+ children: e
57
+ }) });
58
+ }
59
+ // src/navigation/NavMenu.tsx
60
+ function w(e) {
61
+ return `${e}-${l().replaceAll(/\W/g, "")}`;
62
+ }
63
+ var T = "a, button:not([popovertarget])";
64
+ function E() {
65
+ let [e, t] = d(!1);
66
+ return {
67
+ open: e,
68
+ onToggle: (e) => t(e.newState === "open")
69
+ };
70
+ }
71
+ function D(e) {
72
+ c(() => {
73
+ let t = e.current;
74
+ if (!t) return;
75
+ let n = (e) => {
76
+ e.target instanceof Element && e.target.closest(T) && t.hidePopover?.();
77
+ };
78
+ return t.addEventListener("click", n), () => t.removeEventListener("click", n);
79
+ }, [e]);
80
+ }
81
+ function O({ children: r, className: i, label: o }) {
82
+ let s = w("megamenu"), c = u(null), l = E();
83
+ return D(c), /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(e, {
84
+ "aria-expanded": l.open,
85
+ "aria-haspopup": "true",
86
+ className: "md:hidden",
87
+ popoverTarget: s,
88
+ size: "sm",
89
+ tone: "ghost",
90
+ children: o
91
+ }), /* @__PURE__ */ m("div", {
92
+ className: t("megamenu max-md:megamenu-vertical md:gap-1 md:text-inherit max-md:rounded-box max-md:border max-md:border-base-300 max-md:bg-base-100 max-md:bg-linear-to-b max-md:from-(--surface-highlight) max-md:to-transparent max-md:fixed max-md:inset-x-3 max-md:[position-area:none] max-md:top-[4.9rem] max-md:bottom-auto max-md:m-0 max-md:w-auto max-md:p-2 max-md:text-base-content max-md:shadow-(--elevation-3)", n, a, i),
93
+ id: s,
94
+ onToggle: l.onToggle,
95
+ popover: "auto",
96
+ ref: c,
97
+ children: [/* @__PURE__ */ p("span", { className: "megamenu-active" }), r]
98
+ })] });
99
+ }
100
+ function k({ children: e, label: n }) {
101
+ let a = w("megamenu-item"), o = u(null), s = E();
102
+ return D(o), /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("button", {
103
+ "aria-expanded": s.open,
104
+ "aria-haspopup": "true",
105
+ className: "md:h-auto md:gap-2 md:border-0 md:px-3 md:py-1.5 md:text-inherit max-md:w-full max-md:justify-start max-md:pointer-events-none max-md:mt-1 max-md:h-auto max-md:min-h-0 max-md:rounded-none max-md:border-0 max-md:border-t max-md:border-base-300 max-md:px-4 max-md:py-2 max-md:shadow-none max-md:text-xs max-md:font-bold max-md:tracking-wider max-md:uppercase max-md:text-(--ink-muted)",
106
+ popoverTarget: a,
107
+ type: "button",
108
+ children: n
109
+ }), /* @__PURE__ */ p("div", {
110
+ className: t("text-base-content max-md:w-full md:[position-area:block-end_span-inline-start] md:bg-linear-to-b md:from-(--surface-highlight) md:to-transparent md:shadow-(--elevation-3)", r, i),
111
+ id: a,
112
+ onToggle: s.onToggle,
113
+ popover: "auto",
114
+ ref: o,
115
+ children: /* @__PURE__ */ p("div", {
116
+ className: "flex max-md:flex-col max-md:items-stretch items-start gap-4 p-2 max-md:p-0",
117
+ children: e
118
+ })
119
+ })] });
120
+ }
121
+ function A({ children: e, title: t }) {
122
+ return /* @__PURE__ */ m(_, {
123
+ className: "w-full",
124
+ children: [t ? /* @__PURE__ */ p(S, { children: t }) : null, e]
125
+ });
126
+ }
127
+ export { x as a, S as c, _ as i, A as n, b as o, k as r, C as s, O as t };
@@ -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 };