@kolking/react-ui 1.3.0 → 1.5.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.
Files changed (36) hide show
  1. package/dist/{Input-DE1QkW7S.js → Input-DbQTM4UI.js} +39 -29
  2. package/dist/components/Dialog/Dialog.d.ts +10 -5
  3. package/dist/components/Dialog/Dialog.js +34 -38
  4. package/dist/components/Dialog/useDialog.d.ts +2 -3
  5. package/dist/components/Dialog/useDialog.js +43 -43
  6. package/dist/components/Fields/Checkbox.js +1 -1
  7. package/dist/components/Fields/Field.d.ts +1 -1
  8. package/dist/components/Fields/Field.js +28 -27
  9. package/dist/components/Fields/Input.d.ts +2 -0
  10. package/dist/components/Fields/Input.js +1 -1
  11. package/dist/components/Fields/Numeric.d.ts +4 -0
  12. package/dist/components/Fields/Numeric.js +62 -0
  13. package/dist/components/Fields/Radio.js +1 -1
  14. package/dist/components/Fields/Switch.d.ts +13 -0
  15. package/dist/components/Fields/Switch.js +36 -0
  16. package/dist/components/Fields/index.d.ts +2 -1
  17. package/dist/components/Fields/index.js +13 -11
  18. package/dist/components/Flex/Flex.d.ts +1 -1
  19. package/dist/components/Flex/Flex.js +24 -23
  20. package/dist/components/Segmented/Segmented.js +22 -19
  21. package/dist/components/ToggleButton/ToggleButton.d.ts +5 -0
  22. package/dist/components/ToggleButton/ToggleButton.js +16 -0
  23. package/dist/components/ToggleButton/ToggleGroup.d.ts +12 -0
  24. package/dist/components/ToggleButton/ToggleGroup.js +43 -0
  25. package/dist/components/ToggleButton/index.d.ts +2 -0
  26. package/dist/components/ToggleButton/index.js +6 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +60 -54
  29. package/dist/styles/_theme-default.scss +23 -21
  30. package/dist/styles/_utils.scss +12 -5
  31. package/dist/styles/style.css +1 -1
  32. package/dist/utils/helpers.d.ts +1 -2
  33. package/dist/utils/helpers.js +21 -23
  34. package/package.json +1 -1
  35. package/dist/components/Fields/Quantity.d.ts +0 -7
  36. package/dist/components/Fields/Quantity.js +0 -61
@@ -1,36 +1,37 @@
1
- import { jsx as a } from "react/jsx-runtime";
1
+ import { jsx as p } from "react/jsx-runtime";
2
2
  import d from "classnames";
3
- import { fixedForwardRef as i, cssProps as p } from "../../utils/helpers.js";
4
- const y = "Flex_flex_GBHBA", F = {
5
- flex: y
3
+ import { fixedForwardRef as i, cssProps as F } from "../../utils/helpers.js";
4
+ const u = "Flex_flex_GBHBA", w = {
5
+ flex: u
6
6
  };
7
- function u({
8
- as: l,
7
+ function y({
8
+ as: o,
9
9
  direction: e = "row",
10
- gap: o,
11
- align: r,
10
+ gap: r,
11
+ align: t,
12
12
  justify: s,
13
- wrap: f,
14
- marginStart: n,
15
- marginEnd: x,
16
- className: m,
17
- ...t
18
- }, c) {
19
- return /* @__PURE__ */ a(
20
- l ?? "div",
13
+ wrap: l,
14
+ marginStart: f,
15
+ marginEnd: n,
16
+ className: x,
17
+ style: m,
18
+ ...c
19
+ }, a) {
20
+ return /* @__PURE__ */ p(
21
+ o ?? "div",
21
22
  {
22
- ...t,
23
- ref: c,
23
+ ...c,
24
+ ref: a,
24
25
  "data-flex": e,
25
- className: d(F.flex, m),
26
+ className: d(w.flex, x),
26
27
  style: {
27
- ...t.style,
28
- ...p({ gap: o, align: r, justify: s, direction: e, wrap: f, marginStart: n, marginEnd: x })
28
+ ...m,
29
+ ...F({ gap: r, align: t, justify: s, direction: e, wrap: l, marginStart: f, marginEnd: n })
29
30
  }
30
31
  }
31
32
  );
32
33
  }
33
- const j = i(u);
34
+ const v = i(y);
34
35
  export {
35
- j as Flex
36
+ v as Flex
36
37
  };
@@ -1,40 +1,43 @@
1
- import { jsx as o } from "react/jsx-runtime";
1
+ import { jsx as r } from "react/jsx-runtime";
2
2
  import p from "classnames";
3
3
  import { cssProps as i } from "../../utils/helpers.js";
4
4
  const h = "Segmented_segmented_UOs8Z", S = {
5
5
  segmented: h
6
- }, u = ({
7
- size: s,
8
- items: n,
6
+ }, b = ({
7
+ size: n,
8
+ items: o,
9
9
  selected: t,
10
- disabled: m,
11
- margin: r,
10
+ disabled: s,
11
+ margin: m,
12
12
  className: g,
13
- style: c,
14
- onSelect: d,
15
- ...a
16
- }) => /* @__PURE__ */ o(
13
+ style: a,
14
+ onSelect: c,
15
+ ...d
16
+ }) => /* @__PURE__ */ r(
17
17
  "div",
18
18
  {
19
- ...a,
19
+ ...d,
20
+ role: "radiogroup",
20
21
  "data-segmented": t,
21
22
  className: p(S.segmented, g),
22
23
  style: {
23
- ...c,
24
+ ...a,
24
25
  ...i({
25
- size: s,
26
- margin: r,
27
- length: n.length.toString(),
26
+ size: n,
27
+ margin: m,
28
+ length: o.length.toString(),
28
29
  selected: t.toString()
29
30
  })
30
31
  },
31
- children: n.map((l, e) => /* @__PURE__ */ o(
32
+ children: o.map((l, e) => /* @__PURE__ */ r(
32
33
  "button",
33
34
  {
35
+ role: "radio",
34
36
  type: "button",
35
- disabled: m,
37
+ disabled: s,
38
+ "aria-checked": e === t,
36
39
  "data-selected": e === t,
37
- onClick: () => e !== t && d(e),
40
+ onClick: () => e !== t && c(e),
38
41
  children: l
39
42
  },
40
43
  e
@@ -42,5 +45,5 @@ const h = "Segmented_segmented_UOs8Z", S = {
42
45
  }
43
46
  );
44
47
  export {
45
- u as Segmented
48
+ b as Segmented
46
49
  };
@@ -0,0 +1,5 @@
1
+ import { ButtonProps } from '../Button';
2
+ export type ToggleButtonProps = Omit<ButtonProps, 'variant'> & {
3
+ selected?: boolean;
4
+ };
5
+ export declare const ToggleButton: ({ selected, role, ...props }: ToggleButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { Button as t } from "../Button/Button.js";
3
+ const n = ({ selected: a = !1, role: o, ...r }) => /* @__PURE__ */ i(
4
+ t,
5
+ {
6
+ ...r,
7
+ role: o,
8
+ "aria-checked": o === "radio" ? a : void 0,
9
+ "aria-pressed": o !== "radio" ? a : void 0,
10
+ "data-selected": a,
11
+ variant: a ? "primary" : "secondary"
12
+ }
13
+ );
14
+ export {
15
+ n as ToggleButton
16
+ };
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ export type ToggleGroupProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
3
+ variant?: 'inline' | 'block';
4
+ selected: number;
5
+ disabled?: boolean;
6
+ equalWidth?: boolean;
7
+ children: React.ReactElement[];
8
+ minWidth?: React.CSSProperties['minWidth'];
9
+ maxWidth?: React.CSSProperties['maxWidth'];
10
+ onSelect: (index: number) => void;
11
+ };
12
+ export declare const ToggleGroup: ({ variant, selected, disabled, equalWidth, minWidth, maxWidth, className, style, children, onSelect, ...props }: ToggleGroupProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { jsx as _ } from "react/jsx-runtime";
2
+ import e from "react";
3
+ import x from "classnames";
4
+ import { cssProps as h } from "../../utils/helpers.js";
5
+ const k = "ToggleButton_group_yo9Nc", t = {
6
+ group: k
7
+ }, T = ({
8
+ variant: o = "inline",
9
+ selected: l,
10
+ disabled: s,
11
+ equalWidth: c,
12
+ minWidth: p,
13
+ maxWidth: i,
14
+ className: n,
15
+ style: g,
16
+ children: m,
17
+ onSelect: u,
18
+ ...d
19
+ }) => {
20
+ const a = o === "block" ? "flex" : void 0, f = c ? "0" : void 0;
21
+ return /* @__PURE__ */ _(
22
+ "div",
23
+ {
24
+ ...d,
25
+ role: "radiogroup",
26
+ "data-toggle-group": !0,
27
+ className: x(t.group, t[o], n),
28
+ style: { ...g, ...h({ display: a, flexBasis: f, minWidth: p, maxWidth: i }) },
29
+ children: e.Children.map(
30
+ m,
31
+ (y, r) => e.cloneElement(y, {
32
+ role: "radio",
33
+ disabled: s,
34
+ selected: r === l,
35
+ onClick: () => u(r)
36
+ })
37
+ )
38
+ }
39
+ );
40
+ };
41
+ export {
42
+ T as ToggleGroup
43
+ };
@@ -0,0 +1,2 @@
1
+ export * from './ToggleButton';
2
+ export * from './ToggleGroup';
@@ -0,0 +1,6 @@
1
+ import { ToggleButton as e } from "./ToggleButton.js";
2
+ import { ToggleGroup as t } from "./ToggleGroup.js";
3
+ export {
4
+ e as ToggleButton,
5
+ t as ToggleGroup
6
+ };
package/dist/index.d.ts CHANGED
@@ -12,5 +12,6 @@ export * from './components/Progress';
12
12
  export * from './components/Segmented';
13
13
  export * from './components/Spinner';
14
14
  export * from './components/Tag';
15
+ export * from './components/ToggleButton';
15
16
  export * from './components/Tooltip';
16
17
  export * from './utils/colors';
package/dist/index.js CHANGED
@@ -1,62 +1,68 @@
1
1
  import { Avatar as e } from "./components/Avatar/Avatar.js";
2
2
  import { Badge as p } from "./components/Badge/Badge.js";
3
- import { Button as m } from "./components/Button/Button.js";
4
- import { Dialog as a, DialogClose as i, DialogContent as l, DialogFooter as n, DialogTitle as g } from "./components/Dialog/Dialog.js";
5
- import { useDialog as d } from "./components/Dialog/useDialog.js";
6
- import { withDialog as u } from "./components/Dialog/withDialog.js";
7
- import { Flex as F } from "./components/Flex/Flex.js";
8
- import { Checkbox as C } from "./components/Fields/Checkbox.js";
9
- import { Field as B, FieldDescription as S, FieldLabel as b } from "./components/Fields/Field.js";
10
- import { I as M } from "./Input-DE1QkW7S.js";
11
- import { Quantity as V } from "./components/Fields/Quantity.js";
12
- import { Radio as v } from "./components/Fields/Radio.js";
13
- import { Select as y } from "./components/Fields/Select.js";
14
- import { Textarea as H } from "./components/Fields/Textarea.js";
15
- import { V as N } from "./ValidationTooltip-BgSwl0hJ.js";
16
- import { Heading as R } from "./components/Heading/Heading.js";
17
- import { Icon as q } from "./components/Icon/Icon.js";
18
- import { Menu as E } from "./components/Menu/Menu.js";
19
- import { MenuItem as J } from "./components/Menu/MenuItem.js";
20
- import { Notice as O } from "./components/Notice/Notice.js";
21
- import { ProgressBar as W } from "./components/Progress/ProgressBar.js";
22
- import { ProgressCircular as Y } from "./components/Progress/ProgressCircular.js";
23
- import { Segmented as _ } from "./components/Segmented/Segmented.js";
24
- import { Spinner as oo } from "./components/Spinner/Spinner.js";
25
- import { Tag as eo } from "./components/Tag/Tag.js";
26
- import { Tooltip as po } from "./components/Tooltip/Tooltip.js";
27
- import { palette as mo } from "./utils/colors.js";
3
+ import { Button as x } from "./components/Button/Button.js";
4
+ import { Dialog as i, DialogClose as a, DialogContent as l, DialogFooter as g, DialogTitle as n } from "./components/Dialog/Dialog.js";
5
+ import { useDialog as u } from "./components/Dialog/useDialog.js";
6
+ import { withDialog as d } from "./components/Dialog/withDialog.js";
7
+ import { Flex as T } from "./components/Flex/Flex.js";
8
+ import { Checkbox as B } from "./components/Fields/Checkbox.js";
9
+ import { Field as I, FieldDescription as S, FieldLabel as h } from "./components/Fields/Field.js";
10
+ import { I as w } from "./Input-DbQTM4UI.js";
11
+ import { Numeric as N } from "./components/Fields/Numeric.js";
12
+ import { Radio as V } from "./components/Fields/Radio.js";
13
+ import { Select as v } from "./components/Fields/Select.js";
14
+ import { Switch as G } from "./components/Fields/Switch.js";
15
+ import { Textarea as L } from "./components/Fields/Textarea.js";
16
+ import { V as j } from "./ValidationTooltip-BgSwl0hJ.js";
17
+ import { Heading as y } from "./components/Heading/Heading.js";
18
+ import { Icon as E } from "./components/Icon/Icon.js";
19
+ import { Menu as K } from "./components/Menu/Menu.js";
20
+ import { MenuItem as Q } from "./components/Menu/MenuItem.js";
21
+ import { Notice as W } from "./components/Notice/Notice.js";
22
+ import { ProgressBar as Y } from "./components/Progress/ProgressBar.js";
23
+ import { ProgressCircular as _ } from "./components/Progress/ProgressCircular.js";
24
+ import { Segmented as oo } from "./components/Segmented/Segmented.js";
25
+ import { Spinner as eo } from "./components/Spinner/Spinner.js";
26
+ import { Tag as po } from "./components/Tag/Tag.js";
27
+ import { ToggleButton as xo } from "./components/ToggleButton/ToggleButton.js";
28
+ import { ToggleGroup as io } from "./components/ToggleButton/ToggleGroup.js";
29
+ import { Tooltip as lo } from "./components/Tooltip/Tooltip.js";
30
+ import { palette as no } from "./utils/colors.js";
28
31
  export {
29
32
  e as Avatar,
30
33
  p as Badge,
31
- m as Button,
32
- C as Checkbox,
33
- a as Dialog,
34
- i as DialogClose,
34
+ x as Button,
35
+ B as Checkbox,
36
+ i as Dialog,
37
+ a as DialogClose,
35
38
  l as DialogContent,
36
- n as DialogFooter,
37
- g as DialogTitle,
38
- B as Field,
39
+ g as DialogFooter,
40
+ n as DialogTitle,
41
+ I as Field,
39
42
  S as FieldDescription,
40
- b as FieldLabel,
41
- F as Flex,
42
- R as Heading,
43
- q as Icon,
44
- M as Input,
45
- E as Menu,
46
- J as MenuItem,
47
- O as Notice,
48
- W as ProgressBar,
49
- Y as ProgressCircular,
50
- V as Quantity,
51
- v as Radio,
52
- _ as Segmented,
53
- y as Select,
54
- oo as Spinner,
55
- eo as Tag,
56
- H as Textarea,
57
- po as Tooltip,
58
- N as ValidationTooltip,
59
- mo as palette,
60
- d as useDialog,
61
- u as withDialog
43
+ h as FieldLabel,
44
+ T as Flex,
45
+ y as Heading,
46
+ E as Icon,
47
+ w as Input,
48
+ K as Menu,
49
+ Q as MenuItem,
50
+ W as Notice,
51
+ N as Numeric,
52
+ Y as ProgressBar,
53
+ _ as ProgressCircular,
54
+ V as Radio,
55
+ oo as Segmented,
56
+ v as Select,
57
+ eo as Spinner,
58
+ G as Switch,
59
+ po as Tag,
60
+ L as Textarea,
61
+ xo as ToggleButton,
62
+ io as ToggleGroup,
63
+ lo as Tooltip,
64
+ j as ValidationTooltip,
65
+ no as palette,
66
+ u as useDialog,
67
+ d as withDialog
62
68
  };
@@ -13,17 +13,17 @@ $font-weight: (
13
13
 
14
14
  $font-size: (
15
15
  em: 16px,
16
- xs: 0.750rem,
17
- sm: 0.875rem,
18
- md: 1.000rem,
19
- lg: 1.125rem,
20
- xl: 1.250rem,
21
- h6: clamp(1.000rem, 2.25vw, 1.125rem),
22
- h5: clamp(1.125rem, 2.50vw, 1.250rem),
23
- h4: clamp(1.250rem, 3.00vw, 1.500rem),
24
- h3: clamp(1.500rem, 3.50vw, 1.750rem),
25
- h2: clamp(1.750rem, 4.00vw, 2.000rem),
26
- h1: clamp(2.000rem, 5.00vw, 2.500rem),
16
+ xs: 0.750rem, // 12
17
+ sm: 0.875rem, // 14
18
+ md: 1.000rem, // 16
19
+ lg: 1.125rem, // 18
20
+ xl: 1.250rem, // 20
21
+ h6: clamp(1.000rem, 2.25vw, 1.125rem), // 16 → 18
22
+ h5: clamp(1.125rem, 2.50vw, 1.250rem), // 18 → 20
23
+ h4: clamp(1.250rem, 3.00vw, 1.500rem), // 20 → 24
24
+ h3: clamp(1.500rem, 3.50vw, 1.750rem), // 24 → 28
25
+ h2: clamp(1.750rem, 4.00vw, 2.000rem), // 28 → 32
26
+ h1: clamp(2.000rem, 5.00vw, 2.500rem), // 32 → 40
27
27
  );
28
28
 
29
29
  $line-height: (
@@ -35,19 +35,21 @@ $line-height: (
35
35
  );
36
36
 
37
37
  $border-radius: (
38
- xs: 0.1875rem, // 3px
39
- sm: 0.3125rem, // 5px
40
- md: 0.5000rem, // 8px
41
- lg: 0.7500rem, // 12px
42
- xl: 1.1250rem, // 18px
38
+ xs: 0.1875rem, // 03
39
+ sm: 0.3125rem, // 05
40
+ md: 0.5000rem, // 08
41
+ lg: 0.7500rem, // 12
42
+ xl: 1.1250rem, // 18
43
43
  );
44
44
 
45
45
  $spacing: (
46
- xs: clamp(0.5rem, 0.9765625vw, 0.625rem), // 8 → 10
47
- sm: clamp(1.0rem, 1.7578125vw, 1.125rem), // 1618
48
- md: clamp(1.5rem, 2.7343750vw, 1.750rem), // 2428
49
- lg: clamp(2.0rem, 3.5156250vw, 2.250rem), // 3236
50
- xl: clamp(2.5rem, 4.4921875vw, 2.875rem), // 4046
46
+ 2xs: clamp(0.500rem, 1.25vw, 0.625rem), // 08 → 10
47
+ xs: clamp(0.750rem, 1.75vw, 0.875rem), // 1214
48
+ sm: clamp(1.000rem, 2.50vw, 1.250rem), // 1620
49
+ md: clamp(1.375rem, 3.50vw, 1.750rem), // 2228
50
+ lg: clamp(1.875rem, 4.75vw, 2.375rem), // 3038
51
+ xl: clamp(2.500rem, 6.25vw, 3.125rem), // 40 → 50
52
+ 2xl: clamp(3.250rem, 8.00vw, 4.000rem), // 52 → 64
51
53
  );
52
54
 
53
55
  $drop-shadow: (
@@ -1,6 +1,7 @@
1
1
  @use 'sass:map';
2
2
  @use 'sass:math';
3
3
  @use 'sass:meta';
4
+ @use 'sass:list';
4
5
  @use 'sass:color';
5
6
  @use 'sass:string';
6
7
 
@@ -44,6 +45,17 @@
44
45
  @return map.merge($colors, color-palette($palette, $bg, $fg));
45
46
  }
46
47
 
48
+ // Returns a list of keys converted into strings,
49
+ // mainly used to get a palette color names as strings
50
+ // to avoid sass interpolation warnings
51
+ @function string-keys($map) {
52
+ $output: ();
53
+ @each $key in map.keys($map) {
54
+ $output: list.append($output, $key + '');
55
+ }
56
+ @return $output;
57
+ }
58
+
47
59
  // Shortcut to set an opacity for a CSS variable
48
60
  @function color-opacity($hex, $opacity) {
49
61
  @return color-mix(in srgb, $hex $opacity, transparent);
@@ -84,11 +96,6 @@
84
96
  @return string.unquote('#' + string.slice($ie-hex, 4));
85
97
  }
86
98
 
87
- // Convert color to string
88
- @function to-string($color) {
89
- @return $color + '';
90
- }
91
-
92
99
  @mixin focus-visible($color: var(--color-focus)) {
93
100
  outline-width: 3px;
94
101
  outline-offset: 2px;