@companix/uikit 0.0.17 → 0.0.19

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.
@@ -1,7 +1,7 @@
1
1
  import { InputContainerProps } from './InputContainer';
2
2
  export interface InputProps extends Omit<InputContainerProps, 'inputRef' | 'children'> {
3
3
  placeholder?: string;
4
- value?: string | number;
4
+ value?: string;
5
5
  readOnly?: boolean;
6
6
  onValueChange?: (value: string, targetElement: HTMLInputElement) => void;
7
7
  onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
@@ -1,4 +1,6 @@
1
- interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'children'> {
1
+ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'children' | 'value' | 'defaultValue'> {
2
+ defaultValue?: string;
3
+ value?: string;
2
4
  mask?: string;
3
5
  maskChar?: string;
4
6
  onValueChange?: (value: string, targetElement: HTMLInputElement) => void;
@@ -1,6 +1,23 @@
1
- import { InputProps } from '../Input/Input';
2
- export interface NumberInputProps extends Omit<InputProps, 'value' | 'onChange'> {
3
- value: number | null;
4
- onChange: (value: number | null) => void;
1
+ import { InputContainerProps } from '../Input/InputContainer';
2
+ export interface ReactNumberFormatParams {
3
+ thousandSeparator?: boolean | string;
4
+ decimalSeparator?: string;
5
+ allowedDecimalSeparators?: Array<string>;
6
+ thousandsGroupStyle?: 'thousand' | 'lakh' | 'wan' | 'none';
7
+ decimalScale?: number;
8
+ fixedDecimalScale?: boolean;
9
+ allowNegative?: boolean;
10
+ allowLeadingZeros?: boolean;
11
+ suffix?: string;
12
+ prefix?: string;
5
13
  }
6
- export declare const NumberInput: ({ value, onChange, ...props }: NumberInputProps) => import("react/jsx-runtime").JSX.Element;
14
+ export interface NumberInputProps extends Omit<InputContainerProps, 'inputRef' | 'children'>, ReactNumberFormatParams {
15
+ placeholder?: string;
16
+ value?: number | null;
17
+ readOnly?: boolean;
18
+ onValueChange?: (value: number | null) => void;
19
+ onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
20
+ inputRef?: React.Ref<HTMLInputElement>;
21
+ inputClassName?: string;
22
+ }
23
+ export declare const NumberInput: import('react').ForwardRefExoticComponent<NumberInputProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,4 +1,4 @@
1
- interface RadioOption<T> {
1
+ export interface RadioOption<T> {
2
2
  value: T;
3
3
  label: React.ReactNode;
4
4
  }
@@ -20,5 +20,5 @@ type SelectProps<T> = Omit<SelectFormProps, 'value' | 'onChange' | 'closeButton'
20
20
  scrollTo: (index: number) => void;
21
21
  }>;
22
22
  };
23
- export declare const Select: <T extends string | number>(props: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
23
+ export declare const Select: <T>(props: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
24
24
  export {};
package/dist/bundle.es.js CHANGED
@@ -2,63 +2,64 @@ import { Button as e } from "./bundle.es2.js";
2
2
  import { Spinner as p } from "./bundle.es3.js";
3
3
  import { Scrollable as x } from "./bundle.es4.js";
4
4
  import { ImitateScroll as a } from "./bundle.es5.js";
5
- import { Popover as i } from "./bundle.es6.js";
6
- import { Tooltip as c } from "./bundle.es7.js";
5
+ import { Popover as l } from "./bundle.es6.js";
6
+ import { Tooltip as u } from "./bundle.es7.js";
7
7
  import { Select as S } from "./bundle.es8.js";
8
8
  import { Input as T } from "./bundle.es9.js";
9
9
  import { OptionItem as D } from "./bundle.es10.js";
10
10
  import { NumberInput as b } from "./bundle.es11.js";
11
- import { OptionsList as d } from "./bundle.es12.js";
11
+ import { OptionsList as A } from "./bundle.es12.js";
12
12
  import { ButtonGroup as w } from "./bundle.es13.js";
13
- import { Checkbox as L } from "./bundle.es14.js";
14
- import { Switch as P } from "./bundle.es15.js";
15
- import { Radio as v } from "./bundle.es16.js";
13
+ import { Checkbox as G } from "./bundle.es14.js";
14
+ import { Switch as O } from "./bundle.es15.js";
15
+ import { Radio as h, RadioGroup as v } from "./bundle.es16.js";
16
16
  import { Drawer as F } from "./bundle.es17.js";
17
17
  import { Dialog as y } from "./bundle.es18.js";
18
- import { AlertDialog as R } from "./bundle.es19.js";
19
- import { LoadButton as q } from "./bundle.es20.js";
20
- import { Tabs as E } from "./bundle.es21.js";
21
- import { Countdown as J } from "./bundle.es22.js";
22
- import { TextArea as M } from "./bundle.es23.js";
23
- import { SelectTags as U } from "./bundle.es24.js";
24
- import { DatePicker as W } from "./bundle.es25.js";
25
- import { DateInput as Y } from "./bundle.es26.js";
26
- import { FileOverlay as _ } from "./bundle.es27.js";
27
- import { FormGroup as oo } from "./bundle.es28.js";
28
- import { TimePicker as eo } from "./bundle.es29.js";
29
- import { useLocalStorage as po } from "./bundle.es30.js";
30
- import { createAlertAgent as xo } from "./bundle.es31.js";
31
- import { createToaster as ao } from "./bundle.es32.js";
18
+ import { AlertDialog as j } from "./bundle.es19.js";
19
+ import { LoadButton as z } from "./bundle.es20.js";
20
+ import { Tabs as H } from "./bundle.es21.js";
21
+ import { Countdown as K } from "./bundle.es22.js";
22
+ import { TextArea as Q } from "./bundle.es23.js";
23
+ import { SelectTags as V } from "./bundle.es24.js";
24
+ import { DatePicker as X } from "./bundle.es25.js";
25
+ import { DateInput as Z } from "./bundle.es26.js";
26
+ import { FileOverlay as $ } from "./bundle.es27.js";
27
+ import { FormGroup as ro } from "./bundle.es28.js";
28
+ import { TimePicker as to } from "./bundle.es29.js";
29
+ import { useLocalStorage as mo } from "./bundle.es30.js";
30
+ import { createAlertAgent as fo } from "./bundle.es31.js";
31
+ import { createToaster as io } from "./bundle.es32.js";
32
32
  export {
33
- R as AlertDialog,
33
+ j as AlertDialog,
34
34
  e as Button,
35
35
  w as ButtonGroup,
36
- L as Checkbox,
37
- J as Countdown,
38
- Y as DateInput,
39
- W as DatePicker,
36
+ G as Checkbox,
37
+ K as Countdown,
38
+ Z as DateInput,
39
+ X as DatePicker,
40
40
  y as Dialog,
41
41
  F as Drawer,
42
- _ as FileOverlay,
43
- oo as FormGroup,
42
+ $ as FileOverlay,
43
+ ro as FormGroup,
44
44
  a as ImitateScroll,
45
45
  T as Input,
46
- q as LoadButton,
46
+ z as LoadButton,
47
47
  b as NumberInput,
48
48
  D as OptionItem,
49
- d as OptionsList,
50
- i as Popover,
51
- v as Radio,
49
+ A as OptionsList,
50
+ l as Popover,
51
+ h as Radio,
52
+ v as RadioGroup,
52
53
  x as Scrollable,
53
54
  S as Select,
54
- U as SelectTags,
55
+ V as SelectTags,
55
56
  p as Spinner,
56
- P as Switch,
57
- E as Tabs,
58
- M as TextArea,
59
- eo as TimePicker,
60
- c as Tooltip,
61
- xo as createAlertAgent,
62
- ao as createToaster,
63
- po as useLocalStorage
57
+ O as Switch,
58
+ H as Tabs,
59
+ Q as TextArea,
60
+ to as TimePicker,
61
+ u as Tooltip,
62
+ fo as createAlertAgent,
63
+ io as createToaster,
64
+ mo as useLocalStorage
64
65
  };
@@ -1,33 +1,58 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import { useState as p, useRef as m } from "react";
3
- import { Input as l } from "./bundle.es9.js";
4
- const N = ({ value: r, onChange: u, ...e }) => {
5
- const [, t] = p([]), n = m(i(r));
6
- return +n.current !== r && (n.current = i(r)), /* @__PURE__ */ f(
7
- l,
8
- {
9
- ...e,
10
- value: n.current,
11
- onChange: (o) => {
12
- const s = o.currentTarget.value.trim();
13
- if (s === "")
14
- return n.current = "", u(null);
15
- if (!(s.startsWith(".") || s.replace(".", "").split("").some((c) => isNaN(parseInt(c))))) {
16
- if (n.current = a(s.split("")), +n.current === r)
17
- return t([]);
18
- u(+n.current);
19
- }
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import C from "classnames";
3
+ import { forwardRef as j, useRef as w } from "react";
4
+ import { mergeRefs as y } from "react-merge-refs";
5
+ import { InputContainer as F } from "./bundle.es38.js";
6
+ import { NumericFormat as V } from "react-number-format";
7
+ const D = j(
8
+ ({
9
+ onChange: m,
10
+ onValueChange: o,
11
+ readOnly: i,
12
+ inputClassName: f,
13
+ value: n,
14
+ placeholder: u,
15
+ thousandSeparator: p,
16
+ decimalSeparator: a,
17
+ allowedDecimalSeparators: l,
18
+ thousandsGroupStyle: d,
19
+ decimalScale: s,
20
+ fixedDecimalScale: b,
21
+ allowNegative: R,
22
+ allowLeadingZeros: c,
23
+ suffix: g,
24
+ prefix: x,
25
+ inputRef: I,
26
+ ...e
27
+ }, N) => {
28
+ const r = w(null);
29
+ return /* @__PURE__ */ t(F, { ref: N, inputRef: r, ...e, children: /* @__PURE__ */ t(
30
+ V,
31
+ {
32
+ type: "text",
33
+ getInputRef: y([r, I]),
34
+ className: C("form-input form-input-base", f),
35
+ "aria-disabled": e.disabled,
36
+ onChange: m,
37
+ onValueChange: ({ floatValue: h }) => o?.(h ?? null),
38
+ value: n,
39
+ placeholder: u,
40
+ disabled: e.disabled,
41
+ readOnly: i,
42
+ thousandSeparator: p,
43
+ decimalSeparator: a,
44
+ allowedDecimalSeparators: l,
45
+ thousandsGroupStyle: d,
46
+ decimalScale: s,
47
+ fixedDecimalScale: b,
48
+ allowNegative: R,
49
+ allowLeadingZeros: c,
50
+ suffix: g,
51
+ prefix: x
20
52
  }
21
- }
22
- );
23
- }, i = (r) => r === null ? "" : r.toString(), a = (r) => {
24
- const u = [...r], e = [...r];
25
- if (e.every((t) => t === "0"))
26
- return "0";
27
- for (let t = 0; t < e.length && e[t] === "0"; t++)
28
- e[t] === "0" && e[t + 1] !== "." && u.shift();
29
- return u.join("");
30
- };
53
+ ) });
54
+ }
55
+ );
31
56
  export {
32
- N as NumberInput
57
+ D as NumberInput
33
58
  };
@@ -1,23 +1,47 @@
1
- import { jsxs as l, jsx as r } from "react/jsx-runtime";
2
- import { useId as c } from "react";
3
- import * as d from "@radix-ui/react-radio-group";
4
- import { attr as i } from "@companix/utils-browser";
5
- const h = ({ value: t, label: e, size: m = "md", disabled: a, required: s }) => {
6
- const o = c();
7
- return /* @__PURE__ */ l(
1
+ import { jsxs as u, jsx as o } from "react/jsx-runtime";
2
+ import { useId as p } from "react";
3
+ import * as l from "@radix-ui/react-radio-group";
4
+ import { attr as s } from "@companix/utils-browser";
5
+ const q = (t) => {
6
+ const { options: m, value: a, onChange: r, disabled: d, required: e, size: n } = t;
7
+ return /* @__PURE__ */ o(
8
+ l.Root,
9
+ {
10
+ className: "radio-group",
11
+ disabled: d,
12
+ "data-required": s(e && !a),
13
+ "data-v": a,
14
+ value: a,
15
+ onValueChange: (i) => r(i),
16
+ children: m.map((i, c) => /* @__PURE__ */ o(
17
+ h,
18
+ {
19
+ ...i,
20
+ size: n,
21
+ disabled: d,
22
+ required: e && !a
23
+ },
24
+ `radio-${i.value}-${c}`
25
+ ))
26
+ }
27
+ );
28
+ }, h = ({ value: t, label: m, size: a = "md", disabled: r, required: d }) => {
29
+ const e = p();
30
+ return /* @__PURE__ */ u(
8
31
  "span",
9
32
  {
10
33
  className: "radio",
11
- "data-disabled": i(a),
12
- "data-size": m,
13
- "data-required": i(s),
34
+ "data-disabled": s(r),
35
+ "data-size": a,
36
+ "data-required": s(d),
14
37
  children: [
15
- /* @__PURE__ */ r(d.Item, { className: "radio-box", value: t, disabled: a, id: o, children: /* @__PURE__ */ r(d.Indicator, { className: "radio-mark" }) }),
16
- /* @__PURE__ */ r("label", { className: "radio-label", htmlFor: o, "data-disabled": i(a), children: e })
38
+ /* @__PURE__ */ o(l.Item, { className: "radio-box", value: t, disabled: r, id: e, children: /* @__PURE__ */ o(l.Indicator, { className: "radio-mark" }) }),
39
+ /* @__PURE__ */ o("label", { className: "radio-label", htmlFor: e, "data-disabled": s(r), children: m })
17
40
  ]
18
41
  }
19
42
  );
20
43
  };
21
44
  export {
22
- h as Radio
45
+ h as Radio,
46
+ q as RadioGroup
23
47
  };
@@ -2,7 +2,7 @@ import { jsx as u } from "react/jsx-runtime";
2
2
  import { forwardRef as m, useCallback as i } from "react";
3
3
  import c from "react-input-mask";
4
4
  const I = m(
5
- ({ mask: r, maskChar: f, onChange: n, onValueChange: o, ...a }, e) => {
5
+ ({ mask: r, maskChar: f = "_", onChange: n, onValueChange: o, ...a }, e) => {
6
6
  const p = i(
7
7
  (t) => {
8
8
  n?.(t), o?.(t.target.value, t.target);
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export { OptionsList } from './OptionItem/OptionsList';
12
12
  export { ButtonGroup } from './ButtonGroup';
13
13
  export { Checkbox } from './Checkbox';
14
14
  export { Switch } from './Switch';
15
- export { Radio } from './Radio';
15
+ export { Radio, RadioGroup } from './Radio';
16
16
  export { Drawer } from './Drawer';
17
17
  export { Dialog } from './Dialog';
18
18
  export { AlertDialog } from './DialogAlert/Alert';
@@ -26,8 +26,10 @@ export { DateInput } from './DateInput';
26
26
  export { FileOverlay } from './File';
27
27
  export { FormGroup } from './FormGroup';
28
28
  export { TimePicker } from './TimePicker';
29
- export * from './__hooks/use-local-storage';
29
+ export { useLocalStorage } from './__hooks/use-local-storage';
30
30
  export { createAlertAgent } from './DialogAlert';
31
31
  export { createToaster } from './Toaster';
32
32
  export * from './types';
33
33
  export type { Appearance } from './Button';
34
+ export type { RadioOption } from './Radio';
35
+ export type { NumberInputProps, ReactNumberFormatParams } from './NumberInput';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "module": "./dist/bundle.es.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -37,7 +37,8 @@
37
37
  "@radix-ui/react-visually-hidden": "^1.2.4",
38
38
  "classnames": "^2.5.1",
39
39
  "react-input-mask": "^2.0.4",
40
- "react-merge-refs": "^3.0.2"
40
+ "react-merge-refs": "^3.0.2",
41
+ "react-number-format": "^5.4.4"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@blueprintjs/core": "^6.2.1",
@@ -1,35 +0,0 @@
1
- .number-input-container {
2
- display: flex;
3
- gap: 4px;
4
- }
5
-
6
- .number-stepper {
7
- display: flex;
8
- flex-direction: column;
9
- height: 30px;
10
- min-height: 30px;
11
- line-height: 30px;
12
- border: 1px solid var(--border-color);
13
- box-shadow: 0 1px 2px rgb(0 0 0 / 47%);
14
- border-radius: 4px;
15
-
16
- &-splitter {
17
- height: 1px;
18
- background-color: var(--border-color);
19
- }
20
-
21
- &-slot {
22
- border-radius: 0px;
23
- height: 13.5px;
24
-
25
- &[data-slot='decrement'] {
26
- border-bottom-left-radius: 3px;
27
- border-bottom-right-radius: 3px;
28
- }
29
-
30
- &[data-slot='increment'] {
31
- border-top-left-radius: 3px;
32
- border-top-right-radius: 3px;
33
- }
34
- }
35
- }
@@ -1,8 +0,0 @@
1
- import { StepperInputOptions } from '../__hooks/use-stepper-input';
2
- interface StepperInputProps extends StepperInputOptions {
3
- buttons?: boolean;
4
- placeholder?: string;
5
- inputStyle?: React.CSSProperties;
6
- }
7
- export declare const StepperInput: ({ inputStyle, placeholder, buttons, ...options }: StepperInputProps) => import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -1,13 +0,0 @@
1
- export interface StepperInputOptions {
2
- value: number;
3
- onChange: (value: number) => void;
4
- step: number;
5
- minValue?: number;
6
- }
7
- export declare const useStepperInput: ({ minValue, value, onChange, step }: StepperInputOptions) => {
8
- inputRef: import('react').RefObject<HTMLInputElement>;
9
- value: string;
10
- increment: () => void;
11
- decrement: () => void;
12
- handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
13
- };