@alexandregme/zljs 1.6.0 → 1.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/README.md CHANGED
@@ -43,6 +43,30 @@ import { FormProvider, FormInput } from "@alexandregme/zljs/rhf";
43
43
  <Button onClick={handleClick}>Submit</Button>;
44
44
  ```
45
45
 
46
+ ## Colors
47
+
48
+ The components work with no setup, using the default colors. To use your own, redefine the values you want after importing the styles:
49
+
50
+ ```css
51
+ @import "tailwindcss";
52
+ @import "@alexandregme/zljs/styles.css";
53
+
54
+ @theme {
55
+ --color-zl-primary: #2e7d32;
56
+ }
57
+ ```
58
+
59
+ `primary`, `success`, `danger`, `warning`, `info` and `muted` each take one value (`--color-zl-<color>`), used for text and the focus outline. The others follow it, and you can redefine them too:
60
+
61
+ | Value | Used for | Default |
62
+ | --------------------------- | ---------------------- | ------------------------------------------ |
63
+ | `--color-zl-<color>-strong` | Link hover | 30% darker |
64
+ | `--color-zl-<color>-bg` | Button background | The color itself (`warning`: `yellow-500`) |
65
+ | `--color-zl-<color>-hover` | Button hover | The background, 15% darker |
66
+ | `--color-zl-<color>-on` | Text on the background | White (`warning`: `gray-900`) |
67
+
68
+ Only the defaults are checked for contrast. Check your own choice: 4.5:1 for text, on `--color-zl-<color>` against the page and on `-on` against `-bg`, and 3:1 for the focus outline. A value set on a nested element doesn't reach the values derived from it, so set them in `@theme` or `:root`.
69
+
46
70
  ## Getting Started
47
71
 
48
72
  ```bash
@@ -28,16 +28,16 @@ import { forwardRef, useId } from "react";
28
28
  // core/forms/error/error.styles.ts
29
29
  import { tv } from "tailwind-variants";
30
30
  var error = tv({
31
- base: "text-sm text-red-600"
31
+ base: "text-sm text-zl-danger"
32
32
  });
33
33
 
34
34
  // core/forms/error/error.tsx
35
35
  import { jsx as jsx2 } from "react/jsx-runtime";
36
- var Error = ({ message }) => {
36
+ var Error = ({ id, message }) => {
37
37
  if (!message) {
38
38
  return null;
39
39
  }
40
- return /* @__PURE__ */ jsx2("span", { role: "alert", className: error(), children: message });
40
+ return /* @__PURE__ */ jsx2("span", { id, role: "alert", className: error(), children: message });
41
41
  };
42
42
 
43
43
  // core/forms/input/input.styles.ts
package/dist/index.d.ts CHANGED
@@ -69,21 +69,26 @@ interface DataGridProps<T extends Record<string, unknown> = Record<string, unkno
69
69
 
70
70
  declare const DataGrid: <T extends Record<string, unknown> = Record<string, unknown>>({ columns, data, showSearch, }: DataGridProps<T>) => react.JSX.Element;
71
71
 
72
+ type CheckboxVariant = "default" | "card";
72
73
  interface CheckboxProps {
73
- label: string;
74
+ label: ReactNode;
75
+ "aria-label"?: string;
76
+ variant?: CheckboxVariant;
77
+ size?: Size;
74
78
  checked?: boolean;
75
79
  disabled?: boolean;
76
80
  error?: string;
77
81
  onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
78
82
  }
79
83
 
80
- declare const Checkbox: ({ label: labelText, checked, disabled, error, onChange, }: CheckboxProps) => react.JSX.Element;
84
+ declare const Checkbox: ({ label: labelText, "aria-label": ariaLabel, variant, size, checked, disabled, error, onChange, }: CheckboxProps) => react.JSX.Element;
81
85
 
82
86
  interface ErrorProps {
87
+ id?: string;
83
88
  message: string;
84
89
  }
85
90
 
86
- declare const Error: ({ message }: ErrorProps) => react.JSX.Element | null;
91
+ declare const Error: ({ id, message }: ErrorProps) => react.JSX.Element | null;
87
92
 
88
93
  interface FormProps {
89
94
  children: ReactNode;
@@ -459,4 +464,4 @@ declare class HTTPClient {
459
464
  }
460
465
 
461
466
  export { AppWrapper, Button, Checkbox, ConnectedModal, DataGrid, DocumentWrapper, Error, Form, GlobalState, HTTPClient, Heading, Icon, Input, Loader, Modal, PageWrapper, Radio, Select, Sidebar, Spinner, StatsCard, Tag, Text, TextArea, Toaster, WhatsAppButton, splitURLasPath, useAppStore, useModalStore, usePageStore, useRouterStore, useToastStore };
462
- export type { AppState, AppWrapperProps, ButtonColor, ButtonProps, ButtonVariant, CheckboxProps, ConnectedModalProps, DataColor, DataGridColumn, DataGridProps, DocumentWrapperProps, ErrorProps, ExtendedStore, FormProps, GlobalStateProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, IconProps, InitPageFunction, InputProps, LoaderProps, ModalEntry, ModalProps, ModalState, PageState, PageWrapperProps, RadioProps, RouterState, SelectOption, SelectProps, SemanticColor, SidebarItem, SidebarProps, SidebarSection, SidebarUser, Size, SpinnerProps, SpinnerVariant, StatsCardProps, TagProps, TextAreaProps, TextProps, TextVariant, Toast, ToastState, ToastType, WhatsAppButtonProps };
467
+ export type { AppState, AppWrapperProps, ButtonColor, ButtonProps, ButtonVariant, CheckboxProps, CheckboxVariant, ConnectedModalProps, DataColor, DataGridColumn, DataGridProps, DocumentWrapperProps, ErrorProps, ExtendedStore, FormProps, GlobalStateProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, IconProps, InitPageFunction, InputProps, LoaderProps, ModalEntry, ModalProps, ModalState, PageState, PageWrapperProps, RadioProps, RouterState, SelectOption, SelectProps, SemanticColor, SidebarItem, SidebarProps, SidebarSection, SidebarUser, Size, SpinnerProps, SpinnerVariant, StatsCardProps, TagProps, TextAreaProps, TextProps, TextVariant, Toast, ToastState, ToastType, WhatsAppButtonProps };
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  FormInput,
5
5
  FormProvider,
6
6
  Input
7
- } from "./chunk-WAQLH7A5.js";
7
+ } from "./chunk-WZNUKE6S.js";
8
8
 
9
9
  // core/icon/icon.tsx
10
10
  import * as LucideIcons from "lucide-react";
@@ -51,18 +51,18 @@ var button = tv({
51
51
  base: "cursor-pointer font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center justify-center",
52
52
  variants: {
53
53
  variant: {
54
- default: "px-4 py-2 text-white text-sm gap-2 rounded-md",
54
+ default: "px-4 py-2 text-sm gap-2 rounded-md",
55
55
  icon: "p-1 bg-transparent text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-md",
56
56
  // The invisible ::after grows the touch target to 44px without changing the layout.
57
57
  link: "relative text-xs hover:underline rounded-sm after:absolute after:top-1/2 after:left-1/2 after:h-11 after:w-full after:min-w-11 after:-translate-x-1/2 after:-translate-y-1/2"
58
58
  },
59
59
  color: {
60
- primary: "bg-blue-600 hover:bg-blue-700 focus-visible:outline-blue-600",
61
- success: "bg-green-700 hover:bg-green-800 focus-visible:outline-green-700",
62
- danger: "bg-red-600 hover:bg-red-700 focus-visible:outline-red-600",
63
- warning: "bg-yellow-500 hover:bg-yellow-600 focus-visible:outline-yellow-700 text-gray-900",
64
- info: "bg-cyan-700 hover:bg-cyan-800 focus-visible:outline-cyan-700",
65
- muted: "bg-gray-500 hover:bg-gray-600 focus-visible:outline-gray-500",
60
+ primary: "bg-zl-primary-bg hover:bg-zl-primary-hover text-zl-primary-on focus-visible:outline-zl-primary",
61
+ success: "bg-zl-success-bg hover:bg-zl-success-hover text-zl-success-on focus-visible:outline-zl-success",
62
+ danger: "bg-zl-danger-bg hover:bg-zl-danger-hover text-zl-danger-on focus-visible:outline-zl-danger",
63
+ warning: "bg-zl-warning-bg hover:bg-zl-warning-hover text-zl-warning-on focus-visible:outline-zl-warning",
64
+ info: "bg-zl-info-bg hover:bg-zl-info-hover text-zl-info-on focus-visible:outline-zl-info",
65
+ muted: "bg-zl-muted-bg hover:bg-zl-muted-hover text-zl-muted-on focus-visible:outline-zl-muted",
66
66
  ghost: "bg-transparent text-current hover:text-current hover:bg-neutral-500/20",
67
67
  none: ""
68
68
  },
@@ -104,32 +104,32 @@ var button = tv({
104
104
  {
105
105
  variant: "link",
106
106
  color: "primary",
107
- class: "text-blue-600 hover:text-blue-800"
107
+ class: "text-zl-primary hover:text-zl-primary-strong"
108
108
  },
109
109
  {
110
110
  variant: "link",
111
111
  color: "success",
112
- class: "text-green-700 hover:text-green-900"
112
+ class: "text-zl-success hover:text-zl-success-strong"
113
113
  },
114
114
  {
115
115
  variant: "link",
116
116
  color: "danger",
117
- class: "text-red-600 hover:text-red-800"
117
+ class: "text-zl-danger hover:text-zl-danger-strong"
118
118
  },
119
119
  {
120
120
  variant: "link",
121
121
  color: "warning",
122
- class: "text-yellow-700 hover:text-yellow-900"
122
+ class: "text-zl-warning hover:text-zl-warning-strong"
123
123
  },
124
124
  {
125
125
  variant: "link",
126
126
  color: "info",
127
- class: "text-cyan-700 hover:text-cyan-900"
127
+ class: "text-zl-info hover:text-zl-info-strong"
128
128
  },
129
129
  {
130
130
  variant: "link",
131
131
  color: "muted",
132
- class: "text-gray-500 hover:text-gray-700"
132
+ class: "text-zl-muted hover:text-zl-muted-strong"
133
133
  },
134
134
  {
135
135
  variant: "link",
@@ -220,27 +220,50 @@ var wrapper = tv2({
220
220
  base: "flex flex-col gap-1"
221
221
  });
222
222
  var innerWrapper = tv2({
223
- base: "flex items-center gap-2"
223
+ base: "flex cursor-pointer has-disabled:cursor-not-allowed",
224
+ variants: {
225
+ variant: {
226
+ default: "w-fit items-center gap-2",
227
+ card: "items-start gap-3 rounded-lg border border-gray-500 p-3 has-checked:border-zl-primary has-checked:ring-1 has-checked:ring-zl-primary has-disabled:bg-gray-100"
228
+ }
229
+ },
230
+ defaultVariants: {
231
+ variant: "default"
232
+ }
224
233
  });
225
234
  var checkbox = tv2({
226
- base: "w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-2 focus:ring-blue-500 disabled:cursor-not-allowed"
235
+ base: "shrink-0 text-blue-600 border-gray-300 rounded focus:ring-2 focus:ring-blue-500 disabled:cursor-not-allowed",
236
+ variants: {
237
+ size: {
238
+ sm: "w-3.5 h-3.5",
239
+ md: "w-4 h-4",
240
+ lg: "w-5 h-5"
241
+ }
242
+ },
243
+ defaultVariants: {
244
+ size: "md"
245
+ }
227
246
  });
228
247
  var label = tv2({
229
- base: "text-sm text-gray-700 select-none cursor-pointer"
248
+ base: "min-w-0 flex-1 text-sm text-gray-700 select-none"
230
249
  });
231
250
 
232
251
  // core/forms/checkbox/checkbox.tsx
233
252
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
234
253
  var Checkbox = ({
235
254
  label: labelText,
255
+ "aria-label": ariaLabel,
256
+ variant,
257
+ size,
236
258
  checked,
237
259
  disabled,
238
260
  error,
239
261
  onChange
240
262
  }) => {
241
263
  const id = useId();
264
+ const errorId = `${id}-error`;
242
265
  return /* @__PURE__ */ jsxs2("div", { className: wrapper(), children: [
243
- /* @__PURE__ */ jsxs2("div", { className: innerWrapper(), children: [
266
+ /* @__PURE__ */ jsxs2("label", { htmlFor: id, className: innerWrapper({ variant }), children: [
244
267
  /* @__PURE__ */ jsx3(
245
268
  "input",
246
269
  {
@@ -249,12 +272,15 @@ var Checkbox = ({
249
272
  checked,
250
273
  disabled,
251
274
  onChange,
252
- className: checkbox()
275
+ "aria-label": ariaLabel,
276
+ "aria-invalid": error ? true : void 0,
277
+ "aria-describedby": error ? errorId : void 0,
278
+ className: checkbox({ size })
253
279
  }
254
280
  ),
255
- /* @__PURE__ */ jsx3("label", { htmlFor: id, className: label(), children: labelText })
281
+ /* @__PURE__ */ jsx3("span", { className: label(), children: labelText })
256
282
  ] }),
257
- error && /* @__PURE__ */ jsx3(Error, { message: error })
283
+ error && /* @__PURE__ */ jsx3(Error, { id: errorId, message: error })
258
284
  ] });
259
285
  };
260
286
 
@@ -652,6 +678,19 @@ var DataGrid = ({
652
678
 
653
679
  // core/text/text.styles.ts
654
680
  import { tv as tv8 } from "tailwind-variants";
681
+
682
+ // core/types/colors.const.ts
683
+ var semanticTextColors = {
684
+ primary: "text-zl-primary",
685
+ success: "text-zl-success",
686
+ danger: "text-zl-danger",
687
+ warning: "text-zl-warning",
688
+ info: "text-zl-info",
689
+ muted: "text-zl-muted",
690
+ none: ""
691
+ };
692
+
693
+ // core/text/text.styles.ts
655
694
  var text = tv8({
656
695
  variants: {
657
696
  variant: {
@@ -659,15 +698,7 @@ var text = tv8({
659
698
  caption: "text-sm",
660
699
  display: "text-3xl font-bold"
661
700
  },
662
- color: {
663
- primary: "text-blue-600",
664
- success: "text-green-700",
665
- danger: "text-red-600",
666
- warning: "text-yellow-700",
667
- info: "text-sky-700",
668
- muted: "text-gray-500",
669
- none: ""
670
- }
701
+ color: semanticTextColors
671
702
  },
672
703
  defaultVariants: {
673
704
  variant: "body"
@@ -832,15 +863,7 @@ var heading = tv11({
832
863
  5: "text-base font-medium",
833
864
  6: "text-sm font-medium"
834
865
  },
835
- color: {
836
- primary: "text-blue-600",
837
- success: "text-green-700",
838
- danger: "text-red-600",
839
- warning: "text-yellow-700",
840
- info: "text-sky-700",
841
- muted: "text-gray-500",
842
- none: ""
843
- }
866
+ color: semanticTextColors
844
867
  },
845
868
  defaultVariants: {
846
869
  level: 1
package/dist/rhf/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  FormInput,
4
4
  FormProvider
5
- } from "../chunk-WAQLH7A5.js";
5
+ } from "../chunk-WZNUKE6S.js";
6
6
  export {
7
7
  FormInput,
8
8
  FormProvider
@@ -0,0 +1,32 @@
1
+ /* AG Grid Custom Styles */
2
+ .ag-theme-alpine {
3
+ --ag-header-background-color: #f8fafc;
4
+ --ag-header-foreground-color: #334155;
5
+ --ag-header-cell-hover-background-color: #e2e8f0;
6
+ --ag-odd-row-background-color: #f8fafc;
7
+ --ag-row-hover-color: #e0f2fe;
8
+ --ag-selected-row-background-color: #dbeafe;
9
+ --ag-border-color: #e2e8f0;
10
+ --ag-font-family: inherit;
11
+ --ag-font-size: 14px;
12
+ }
13
+
14
+ .ag-theme-alpine .ag-header-cell {
15
+ font-weight: 600;
16
+ text-transform: uppercase;
17
+ font-size: 12px;
18
+ letter-spacing: 0.05em;
19
+ border-right: 1px solid #475569;
20
+ }
21
+
22
+ .ag-theme-alpine .ag-header-cell:last-child {
23
+ border-right: none;
24
+ }
25
+
26
+ .ag-theme-alpine .ag-row {
27
+ border-bottom: 1px solid #f1f5f9;
28
+ }
29
+
30
+ .ag-theme-alpine .ag-row:hover {
31
+ background-color: var(--ag-row-hover-color);
32
+ }
@@ -0,0 +1,57 @@
1
+ /* The semantic colors of the components. Works with no setup; an app changes a
2
+ color by redefining its --color-zl-* value in its own @theme, after importing
3
+ the styles. Only the defaults are checked for contrast.
4
+
5
+ Each color has five values, and the others follow the first unless redefined:
6
+ --color-zl-<color> text and focus outline
7
+ --color-zl-<color>-strong link hover
8
+ --color-zl-<color>-bg button background
9
+ --color-zl-<color>-hover button hover
10
+ --color-zl-<color>-on text on the background
11
+
12
+ Prettier is off for this block to keep one value per line. */
13
+
14
+ /* prettier-ignore */
15
+ @theme {
16
+ /* Primary */
17
+ --color-zl-primary: var(--color-blue-600);
18
+ --color-zl-primary-strong: color-mix(in oklab, var(--color-zl-primary), black 30%);
19
+ --color-zl-primary-bg: var(--color-zl-primary);
20
+ --color-zl-primary-hover: color-mix(in oklab, var(--color-zl-primary-bg), black 15%);
21
+ --color-zl-primary-on: var(--color-white);
22
+
23
+ /* Success */
24
+ --color-zl-success: var(--color-green-700);
25
+ --color-zl-success-strong: color-mix(in oklab, var(--color-zl-success), black 30%);
26
+ --color-zl-success-bg: var(--color-zl-success);
27
+ --color-zl-success-hover: color-mix(in oklab, var(--color-zl-success-bg), black 15%);
28
+ --color-zl-success-on: var(--color-white);
29
+
30
+ /* Danger */
31
+ --color-zl-danger: var(--color-red-600);
32
+ --color-zl-danger-strong: color-mix(in oklab, var(--color-zl-danger), black 30%);
33
+ --color-zl-danger-bg: var(--color-zl-danger);
34
+ --color-zl-danger-hover: color-mix(in oklab, var(--color-zl-danger-bg), black 15%);
35
+ --color-zl-danger-on: var(--color-white);
36
+
37
+ /* Warning */
38
+ --color-zl-warning: var(--color-yellow-700);
39
+ --color-zl-warning-strong: color-mix(in oklab, var(--color-zl-warning), black 30%);
40
+ --color-zl-warning-bg: var(--color-yellow-500);
41
+ --color-zl-warning-hover: color-mix(in oklab, var(--color-zl-warning-bg), black 15%);
42
+ --color-zl-warning-on: var(--color-gray-900);
43
+
44
+ /* Info */
45
+ --color-zl-info: var(--color-cyan-700);
46
+ --color-zl-info-strong: color-mix(in oklab, var(--color-zl-info), black 30%);
47
+ --color-zl-info-bg: var(--color-zl-info);
48
+ --color-zl-info-hover: color-mix(in oklab, var(--color-zl-info-bg), black 15%);
49
+ --color-zl-info-on: var(--color-white);
50
+
51
+ /* Muted */
52
+ --color-zl-muted: var(--color-gray-500);
53
+ --color-zl-muted-strong: color-mix(in oklab, var(--color-zl-muted), black 30%);
54
+ --color-zl-muted-bg: var(--color-zl-muted);
55
+ --color-zl-muted-hover: color-mix(in oklab, var(--color-zl-muted-bg), black 15%);
56
+ --color-zl-muted-on: var(--color-white);
57
+ }
@@ -0,0 +1,17 @@
1
+ /* Global Scrollbar */
2
+ ::-webkit-scrollbar {
3
+ width: 4px;
4
+ }
5
+
6
+ ::-webkit-scrollbar-track {
7
+ background: transparent;
8
+ }
9
+
10
+ ::-webkit-scrollbar-thumb {
11
+ background-color: rgba(228, 231, 234, 0.5);
12
+ border-radius: 2px;
13
+ }
14
+
15
+ ::-webkit-scrollbar-thumb:hover {
16
+ background-color: rgba(156, 163, 175, 0.75);
17
+ }
package/dist/styles.css CHANGED
@@ -1,54 +1,7 @@
1
+ @import "./styles/colors.css";
2
+ @import "./styles/scrollbar.css";
3
+ @import "./styles/ag-grid.css";
4
+
1
5
  /* Makes the consumer's Tailwind scan the component classes. The path is
2
6
  relative to this file, so it works from core/ and from the copy in dist/. */
3
7
  @source "./";
4
-
5
- /* Global Scrollbar */
6
- ::-webkit-scrollbar {
7
- width: 4px;
8
- }
9
-
10
- ::-webkit-scrollbar-track {
11
- background: transparent;
12
- }
13
-
14
- ::-webkit-scrollbar-thumb {
15
- background-color: rgba(228, 231, 234, 0.5);
16
- border-radius: 2px;
17
- }
18
-
19
- ::-webkit-scrollbar-thumb:hover {
20
- background-color: rgba(156, 163, 175, 0.75);
21
- }
22
-
23
- /* AG Grid Custom Styles */
24
- .ag-theme-alpine {
25
- --ag-header-background-color: #f8fafc;
26
- --ag-header-foreground-color: #334155;
27
- --ag-header-cell-hover-background-color: #e2e8f0;
28
- --ag-odd-row-background-color: #f8fafc;
29
- --ag-row-hover-color: #e0f2fe;
30
- --ag-selected-row-background-color: #dbeafe;
31
- --ag-border-color: #e2e8f0;
32
- --ag-font-family: inherit;
33
- --ag-font-size: 14px;
34
- }
35
-
36
- .ag-theme-alpine .ag-header-cell {
37
- font-weight: 600;
38
- text-transform: uppercase;
39
- font-size: 12px;
40
- letter-spacing: 0.05em;
41
- border-right: 1px solid #475569;
42
- }
43
-
44
- .ag-theme-alpine .ag-header-cell:last-child {
45
- border-right: none;
46
- }
47
-
48
- .ag-theme-alpine .ag-row {
49
- border-bottom: 1px solid #f1f5f9;
50
- }
51
-
52
- .ag-theme-alpine .ag-row:hover {
53
- background-color: var(--ag-row-hover-color);
54
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexandregme/zljs",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "description": "Opinionated, accessible React component library for enterprise apps (Next.js, Tailwind CSS v4).",
5
5
  "keywords": [
6
6
  "react",