@rovula/ui 0.0.29 → 0.0.31

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 (77) hide show
  1. package/dist/cjs/bundle.css +139 -69
  2. package/dist/cjs/bundle.js +3 -3
  3. package/dist/cjs/bundle.js.map +1 -1
  4. package/dist/cjs/types/components/Dropdown/Dropdown.d.ts +12 -0
  5. package/dist/cjs/types/components/Dropdown/Dropdown.stories.d.ts +18 -0
  6. package/dist/cjs/types/components/InputFilter/InputFilter.d.ts +64 -0
  7. package/dist/cjs/types/components/InputFilter/InputFilter.stories.d.ts +370 -0
  8. package/dist/cjs/types/components/InputFilter/InputFilter.styles.d.ts +8 -0
  9. package/dist/cjs/types/components/Search/Search.d.ts +2 -20
  10. package/dist/cjs/types/components/Search/Search.stories.d.ts +26 -38
  11. package/dist/cjs/types/components/TextInput/TextInput.d.ts +10 -0
  12. package/dist/cjs/types/components/TextInput/TextInput.stories.d.ts +10 -0
  13. package/dist/cjs/types/components/TextInput/TextInput.styles.d.ts +1 -0
  14. package/dist/cjs/types/index.d.ts +1 -0
  15. package/dist/components/ActionButton/ActionButton.stories.js +1 -1
  16. package/dist/components/Checkbox/Checkbox.js +3 -3
  17. package/dist/components/Checkbox/Checkbox.stories.js +1 -1
  18. package/dist/components/DatePicker/DatePicker.js +2 -1
  19. package/dist/components/Dropdown/Dropdown.js +34 -19
  20. package/dist/components/Dropdown/Dropdown.stories.js +1 -0
  21. package/dist/components/Dropdown/Dropdown.styles.js +1 -1
  22. package/dist/components/InputFilter/InputFilter.js +124 -0
  23. package/dist/components/InputFilter/InputFilter.stories.js +34 -0
  24. package/dist/components/InputFilter/InputFilter.styles.js +65 -0
  25. package/dist/components/RadioGroup/RadioGroup.js +5 -2
  26. package/dist/components/RadioGroup/RadioGroup.stories.js +1 -1
  27. package/dist/components/Search/Search.js +1 -1
  28. package/dist/components/Search/Search.stories.js +2 -1
  29. package/dist/components/TextInput/TextInput.js +23 -6
  30. package/dist/components/TextInput/TextInput.styles.js +94 -20
  31. package/dist/esm/bundle.css +139 -69
  32. package/dist/esm/bundle.js +3 -3
  33. package/dist/esm/bundle.js.map +1 -1
  34. package/dist/esm/types/components/Dropdown/Dropdown.d.ts +12 -0
  35. package/dist/esm/types/components/Dropdown/Dropdown.stories.d.ts +18 -0
  36. package/dist/esm/types/components/InputFilter/InputFilter.d.ts +64 -0
  37. package/dist/esm/types/components/InputFilter/InputFilter.stories.d.ts +370 -0
  38. package/dist/esm/types/components/InputFilter/InputFilter.styles.d.ts +8 -0
  39. package/dist/esm/types/components/Search/Search.d.ts +2 -20
  40. package/dist/esm/types/components/Search/Search.stories.d.ts +26 -38
  41. package/dist/esm/types/components/TextInput/TextInput.d.ts +10 -0
  42. package/dist/esm/types/components/TextInput/TextInput.stories.d.ts +10 -0
  43. package/dist/esm/types/components/TextInput/TextInput.styles.d.ts +1 -0
  44. package/dist/esm/types/index.d.ts +1 -0
  45. package/dist/index.d.ts +82 -16
  46. package/dist/index.js +1 -0
  47. package/dist/src/theme/global.css +278 -161
  48. package/dist/theme/presets/colors.js +21 -0
  49. package/dist/theme/themes/xspector/color.css +13 -0
  50. package/dist/theme/themes/xspector/components/action-button.css +44 -42
  51. package/dist/theme/themes/xspector/state.css +1 -1
  52. package/dist/theme/tokens/color.css +13 -0
  53. package/dist/theme/tokens/components/action-button.css +42 -42
  54. package/package.json +1 -1
  55. package/src/components/ActionButton/ActionButton.stories.tsx +1 -1
  56. package/src/components/Checkbox/Checkbox.stories.tsx +1 -1
  57. package/src/components/Checkbox/Checkbox.tsx +4 -4
  58. package/src/components/DatePicker/DatePicker.tsx +4 -2
  59. package/src/components/Dropdown/Dropdown.stories.tsx +1 -0
  60. package/src/components/Dropdown/Dropdown.styles.ts +1 -1
  61. package/src/components/Dropdown/Dropdown.tsx +69 -38
  62. package/src/components/InputFilter/InputFilter.stories.tsx +72 -0
  63. package/src/components/InputFilter/InputFilter.styles.ts +74 -0
  64. package/src/components/InputFilter/InputFilter.tsx +314 -0
  65. package/src/components/RadioGroup/RadioGroup.stories.tsx +1 -1
  66. package/src/components/RadioGroup/RadioGroup.tsx +7 -9
  67. package/src/components/Search/Search.stories.tsx +3 -2
  68. package/src/components/Search/Search.tsx +13 -2
  69. package/src/components/TextInput/TextInput.styles.ts +94 -20
  70. package/src/components/TextInput/TextInput.tsx +53 -11
  71. package/src/index.ts +1 -0
  72. package/src/theme/presets/colors.js +21 -0
  73. package/src/theme/themes/xspector/color.css +13 -0
  74. package/src/theme/themes/xspector/components/action-button.css +44 -42
  75. package/src/theme/themes/xspector/state.css +1 -1
  76. package/src/theme/tokens/color.css +13 -0
  77. package/src/theme/tokens/components/action-button.css +42 -42
@@ -8,7 +8,7 @@ const meta = {
8
8
  layout: "fullscreen",
9
9
  },
10
10
  decorators: [
11
- (Story) => (_jsx("div", { className: "p-5 flex w-full", children: _jsx(Story, {}) })),
11
+ (Story) => (_jsx("div", { className: "p-5 flex w-full bg-base-bg2", children: _jsx(Story, {}) })),
12
12
  ],
13
13
  };
14
14
  export default meta;
@@ -20,6 +20,7 @@ export const Default = {
20
20
  args: {
21
21
  label: "Choose an option:",
22
22
  fullwidth: true,
23
+ size: "md",
23
24
  options,
24
25
  },
25
26
  render: (args) => {
@@ -10,12 +10,12 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { forwardRef, useImperativeHandle, useRef, } from "react";
13
+ import { forwardRef, useCallback, useImperativeHandle, useRef, } from "react";
14
14
  import { helperTextVariant, iconSearchWrapperVariant, iconVariant, iconWrapperVariant, inputVariant, labelVariant, sectionIconWrapperVariant, } from "./TextInput.styles";
15
15
  import { XCircleIcon, ExclamationCircleIcon, MagnifyingGlassIcon, } from "@heroicons/react/16/solid";
16
16
  import { cn } from "@/utils/cn";
17
17
  export const TextInput = forwardRef((_a, ref) => {
18
- var { id, label, size = "md", rounded = "normal", variant = "outline", type = "text", helperText, errorMessage, fullwidth = true, disabled = false, error = false, required = true, hasClearIcon = true, hasSearchIcon = false, startIcon, endIcon, labelClassName } = _a, props = __rest(_a, ["id", "label", "size", "rounded", "variant", "type", "helperText", "errorMessage", "fullwidth", "disabled", "error", "required", "hasClearIcon", "hasSearchIcon", "startIcon", "endIcon", "labelClassName"]);
18
+ var { id, label, size = "md", rounded = "normal", variant = "outline", type = "text", helperText, errorMessage, fullwidth = true, disabled = false, error = false, required = true, isFloatingLabel = true, keepCloseIconOnValue = false, hasClearIcon = true, hasSearchIcon = false, startIcon, endIcon, labelClassName, onClickEndIcon, renderEndIcon } = _a, props = __rest(_a, ["id", "label", "size", "rounded", "variant", "type", "helperText", "errorMessage", "fullwidth", "disabled", "error", "required", "isFloatingLabel", "keepCloseIconOnValue", "hasClearIcon", "hasSearchIcon", "startIcon", "endIcon", "labelClassName", "onClickEndIcon", "renderEndIcon"]);
19
19
  const inputRef = useRef(null);
20
20
  const _id = id || `${type}-${label}-input`;
21
21
  const hasLeftSectionIcon = !!startIcon;
@@ -37,6 +37,7 @@ export const TextInput = forwardRef((_a, ref) => {
37
37
  disabled,
38
38
  error,
39
39
  hasSearchIcon,
40
+ isFloatingLabel,
40
41
  });
41
42
  const helperTextClassname = helperTextVariant({ size, error, disabled });
42
43
  const iconWrapperClassname = iconWrapperVariant({ size });
@@ -49,13 +50,29 @@ export const TextInput = forwardRef((_a, ref) => {
49
50
  error,
50
51
  });
51
52
  useImperativeHandle(ref, () => inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
52
- const handleClearInput = () => {
53
+ const handleClearInput = useCallback(() => {
53
54
  if (inputRef.current) {
54
55
  inputRef.current.value = "";
56
+ if (props.onChange) {
57
+ const event = new Event("input", { bubbles: true });
58
+ props.onChange({ target: { value: "" } });
59
+ }
55
60
  }
56
- };
57
- return (_jsxs("div", { className: `inline-flex flex-col ${fullwidth ? "w-full" : ""}`, children: [_jsxs("div", { className: "relative", children: [hasSearchIcon && (_jsx("div", { className: iconSearchWrapperClassname, children: _jsx(MagnifyingGlassIcon, { className: iconClassname }) })), _jsx("input", Object.assign({}, props, { placeholder: " ", ref: inputRef, type: type, id: _id, disabled: disabled, className: cn(inputClassname, props.className) })), hasClearIcon && !hasRightSectionIcon && (_jsx("div", { className: iconWrapperClassname, children: _jsx(XCircleIcon, { type: "button", className: iconClassname, onMouseDown: handleClearInput }) })), hasRightSectionIcon && (_jsx("div", { className: endIconWrapperClassname, children: endIcon })), _jsxs("label", { htmlFor: _id, className: cn(labelClassname, labelClassName), children: [label, " ", required && (_jsx("span", { className: cn("text-error", {
61
+ }, [props.onChange]);
62
+ // TODO startIcon
63
+ const handleOnClickRightSectionIcon = useCallback(() => {
64
+ if (disabled)
65
+ return;
66
+ onClickEndIcon === null || onClickEndIcon === void 0 ? void 0 : onClickEndIcon();
67
+ if (inputRef.current) {
68
+ inputRef.current.focus();
69
+ }
70
+ }, [disabled, onClickEndIcon]);
71
+ return (_jsxs("div", { className: `inline-flex flex-col ${fullwidth ? "w-full" : ""}`, children: [_jsxs("div", { className: "relative", children: [hasSearchIcon && (_jsx("div", { className: iconSearchWrapperClassname, children: _jsx(MagnifyingGlassIcon, { className: iconClassname }) })), _jsx("input", Object.assign({}, props, { placeholder: " ", ref: inputRef, type: type, id: _id, disabled: disabled, className: cn(inputClassname, props.className) })), hasClearIcon && !hasRightSectionIcon && (_jsx("div", { className: iconWrapperClassname, style: {
72
+ display: keepCloseIconOnValue && props.value ? "flex" : undefined,
73
+ }, children: _jsx(XCircleIcon, { type: "button", className: iconClassname, onMouseDown: handleClearInput }) })), hasRightSectionIcon &&
74
+ (renderEndIcon ? (renderEndIcon()) : (_jsx("div", { className: endIconWrapperClassname, onClick: handleOnClickRightSectionIcon, children: endIcon }))), _jsxs("label", { htmlFor: _id, className: cn(labelClassname, labelClassName), children: [label, " ", required && (_jsx("span", { className: cn("text-error", {
58
75
  "text-input-disable-text": disabled,
59
- }), children: "*" }))] })] }), (errorMessage || helperText) && (_jsxs("span", { className: helperTextClassname, children: [_jsx(ExclamationCircleIcon, { width: 16, height: 16, className: error ? "fill-error" : "" }), " ", errorMessage || helperText] }))] }));
76
+ }), children: "*" }))] })] }), (errorMessage || helperText) && (_jsxs("span", { className: helperTextClassname, children: [_jsx("span", { className: "h-full", children: _jsx(ExclamationCircleIcon, { width: 16, height: 16, className: error ? "fill-error" : "" }) }), errorMessage || helperText] }))] }));
60
77
  });
61
78
  export default TextInput;
@@ -1,5 +1,6 @@
1
1
  import { cva } from "class-variance-authority";
2
2
  export const inputVariant = cva([
3
+ "truncate",
3
4
  "border-0 outline-none",
4
5
  "p-1 flex w-auto box-border",
5
6
  "peer text-input-filled-text placeholder:text-transparent bg-transparent caret-primary",
@@ -72,47 +73,47 @@ export const inputVariant = cva([
72
73
  {
73
74
  hasSearchIcon: true,
74
75
  size: "sm",
75
- class: "ps-6",
76
+ class: "!ps-6",
76
77
  },
77
78
  {
78
79
  hasSearchIcon: true,
79
80
  size: "md",
80
- class: "ps-9",
81
+ class: "!ps-9",
81
82
  },
82
83
  {
83
84
  hasSearchIcon: true,
84
85
  size: "lg",
85
- class: "ps-11",
86
+ class: "!ps-11",
86
87
  },
87
88
  {
88
89
  leftSectionIcon: true,
89
90
  size: "sm",
90
- class: "ps-[38px]",
91
+ class: "!ps-[38px]",
91
92
  },
92
93
  {
93
94
  leftSectionIcon: true,
94
95
  size: "md",
95
- class: "ps-[46px]",
96
+ class: "!ps-[46px]",
96
97
  },
97
98
  {
98
99
  leftSectionIcon: true,
99
100
  size: "lg",
100
- class: "ps-[72px]",
101
+ class: "!ps-[72px]",
101
102
  },
102
103
  {
103
104
  rightSectionIcon: true,
104
105
  size: "sm",
105
- class: "pe-[38px]",
106
+ class: "!pe-[38px]",
106
107
  },
107
108
  {
108
109
  rightSectionIcon: true,
109
110
  size: "md",
110
- class: "pe-[46px]",
111
+ class: "!pe-[46px]",
111
112
  },
112
113
  {
113
114
  rightSectionIcon: true,
114
115
  size: "lg",
115
- class: "pe-[72px]",
116
+ class: "!pe-[72px]",
116
117
  },
117
118
  ],
118
119
  defaultVariants: {
@@ -134,34 +135,78 @@ export const labelVariant = cva([
134
135
  ], {
135
136
  variants: {
136
137
  size: {
137
- sm: [
138
+ sm: [],
139
+ md: [],
140
+ lg: [],
141
+ },
142
+ disabled: {
143
+ true: "text-input-default-text placeholder:text-input-default-text",
144
+ },
145
+ error: {
146
+ true: "ring-error",
147
+ },
148
+ hasSearchIcon: {
149
+ false: "",
150
+ },
151
+ isFloatingLabel: {
152
+ false: "hidden peer-placeholder-shown:block peer-focus:bg-transparent",
153
+ },
154
+ },
155
+ compoundVariants: [
156
+ // floating = true
157
+ {
158
+ isFloatingLabel: true,
159
+ size: "sm",
160
+ className: [
138
161
  "left-3 -top-1.5 typography-label2 bg-input-label-bg",
139
162
  "peer-placeholder-shown:top-2 peer-placeholder-shown:typography-small1 peer-placeholder-shown:bg-transparent",
140
163
  "peer-focus:-top-1.5 peer-focus:typography-label2",
141
164
  ],
142
- md: [
165
+ },
166
+ {
167
+ isFloatingLabel: true,
168
+ size: "md",
169
+ className: [
143
170
  "left-3 -top-1.5 typography-label1 bg-input-label-bg",
144
171
  "peer-placeholder-shown:top-2 peer-placeholder-shown:typography-subtitile4 peer-placeholder-shown:bg-transparent",
145
172
  "peer-focus:-top-1.5 peer-focus:typography-label1",
146
173
  ],
147
- lg: [
174
+ },
175
+ {
176
+ isFloatingLabel: true,
177
+ size: "lg",
178
+ className: [
148
179
  "left-4 -top-1.5 typography-label1 bg-input-label-bg",
149
180
  "peer-placeholder-shown:top-4 peer-placeholder-shown:typography-subtitile1 peer-placeholder-shown:bg-transparent",
150
181
  "peer-focus:-top-1.5 peer-focus:typography-label1",
151
182
  ],
152
183
  },
153
- disabled: {
154
- true: "text-input-default-text placeholder:text-input-default-text",
184
+ // --------------
185
+ // flating = false
186
+ {
187
+ isFloatingLabel: false,
188
+ size: "sm",
189
+ className: [
190
+ "left-3 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-small1",
191
+ ],
155
192
  },
156
- error: {
157
- true: "ring-error",
193
+ {
194
+ isFloatingLabel: false,
195
+ size: "md",
196
+ className: [
197
+ "left-3 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-subtitile4",
198
+ ],
158
199
  },
159
- hasSearchIcon: {
160
- false: "",
200
+ {
201
+ isFloatingLabel: false,
202
+ size: "lg",
203
+ className: [
204
+ "left-4 peer-placeholder-shown:top-4 peer-placeholder-shown:typography-subtitile1",
205
+ ],
161
206
  },
162
- },
163
- compoundVariants: [
207
+ // --------------
164
208
  {
209
+ isFloatingLabel: true,
165
210
  hasSearchIcon: true,
166
211
  size: "sm",
167
212
  className: [
@@ -171,6 +216,7 @@ export const labelVariant = cva([
171
216
  ],
172
217
  },
173
218
  {
219
+ isFloatingLabel: true,
174
220
  hasSearchIcon: true,
175
221
  size: "md",
176
222
  className: [
@@ -180,6 +226,7 @@ export const labelVariant = cva([
180
226
  ],
181
227
  },
182
228
  {
229
+ isFloatingLabel: true,
183
230
  hasSearchIcon: true,
184
231
  size: "lg",
185
232
  className: [
@@ -188,12 +235,38 @@ export const labelVariant = cva([
188
235
  "peer-focus:-top-1.5 peer-focus:typography-label1",
189
236
  ],
190
237
  },
238
+ // floating = false and has search icon
239
+ {
240
+ isFloatingLabel: false,
241
+ hasSearchIcon: true,
242
+ size: "sm",
243
+ className: [
244
+ "left-6 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-small1",
245
+ ],
246
+ },
247
+ {
248
+ isFloatingLabel: false,
249
+ hasSearchIcon: true,
250
+ size: "md",
251
+ className: [
252
+ "left-9 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-subtitile4",
253
+ ],
254
+ },
255
+ {
256
+ isFloatingLabel: false,
257
+ hasSearchIcon: true,
258
+ size: "lg",
259
+ className: [
260
+ "left-11 peer-placeholder-shown:top-4 peer-placeholder-shown:typography-subtitile1",
261
+ ],
262
+ },
191
263
  ],
192
264
  defaultVariants: {
193
265
  size: "md",
194
266
  disabled: false,
195
267
  error: false,
196
268
  hasSearchIcon: false,
269
+ isFloatingLabel: true,
197
270
  },
198
271
  });
199
272
  export const helperTextVariant = cva(["text-small1 flex flex-row items-center gap-1"], {
@@ -258,6 +331,7 @@ export const iconVariant = cva([
258
331
  },
259
332
  });
260
333
  export const sectionIconWrapperVariant = cva([
334
+ "cursor-pointer",
261
335
  "absolute items-center justify-center flex",
262
336
  "border-l border-l-input-default-stroke peer-hover:border-l-input-active-stroke peer-focus:border-l-input-active-stroke peer-disabled:border-l-input-disable-stroke",
263
337
  "fill-input-default-text peer-hover:fill-input-filled-text peer-focus:fill-input-filled-text peer-disabled:fill-input-disable-stroke",