@rovula/ui 0.0.28 → 0.0.30

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 (58) hide show
  1. package/dist/cjs/bundle.css +40 -0
  2. package/dist/cjs/bundle.js +3 -3
  3. package/dist/cjs/bundle.js.map +1 -1
  4. package/dist/cjs/types/components/DatePicker/DatePicker.d.ts +2 -1
  5. package/dist/cjs/types/components/DatePicker/DatePicker.stories.d.ts +720 -1
  6. package/dist/cjs/types/components/Dropdown/Dropdown.d.ts +2 -0
  7. package/dist/cjs/types/components/Dropdown/Dropdown.stories.d.ts +8 -0
  8. package/dist/cjs/types/components/InputFilter/InputFilter.d.ts +5 -0
  9. package/dist/cjs/types/components/InputFilter/InputFilter.stories.d.ts +334 -0
  10. package/dist/cjs/types/components/InputFilter/InputFilter.styles.d.ts +7 -0
  11. package/dist/cjs/types/components/Search/Search.d.ts +2 -20
  12. package/dist/cjs/types/components/Search/Search.stories.d.ts +20 -38
  13. package/dist/cjs/types/components/TextInput/TextInput.d.ts +10 -0
  14. package/dist/cjs/types/components/TextInput/TextInput.stories.d.ts +10 -0
  15. package/dist/cjs/types/components/TextInput/TextInput.styles.d.ts +1 -0
  16. package/dist/cjs/types/index.d.ts +1 -0
  17. package/dist/components/DatePicker/DatePicker.js +16 -3
  18. package/dist/components/Dropdown/Dropdown.js +26 -15
  19. package/dist/components/Dropdown/Dropdown.stories.js +1 -0
  20. package/dist/components/InputFilter/InputFilter.js +18 -0
  21. package/dist/components/InputFilter/InputFilter.stories.js +33 -0
  22. package/dist/components/InputFilter/InputFilter.styles.js +60 -0
  23. package/dist/components/Search/Search.js +1 -1
  24. package/dist/components/TextInput/TextInput.js +22 -6
  25. package/dist/components/TextInput/TextInput.styles.js +84 -11
  26. package/dist/esm/bundle.css +40 -0
  27. package/dist/esm/bundle.js +3 -3
  28. package/dist/esm/bundle.js.map +1 -1
  29. package/dist/esm/types/components/DatePicker/DatePicker.d.ts +2 -1
  30. package/dist/esm/types/components/DatePicker/DatePicker.stories.d.ts +720 -1
  31. package/dist/esm/types/components/Dropdown/Dropdown.d.ts +2 -0
  32. package/dist/esm/types/components/Dropdown/Dropdown.stories.d.ts +8 -0
  33. package/dist/esm/types/components/InputFilter/InputFilter.d.ts +5 -0
  34. package/dist/esm/types/components/InputFilter/InputFilter.stories.d.ts +334 -0
  35. package/dist/esm/types/components/InputFilter/InputFilter.styles.d.ts +7 -0
  36. package/dist/esm/types/components/Search/Search.d.ts +2 -20
  37. package/dist/esm/types/components/Search/Search.stories.d.ts +20 -38
  38. package/dist/esm/types/components/TextInput/TextInput.d.ts +10 -0
  39. package/dist/esm/types/components/TextInput/TextInput.stories.d.ts +10 -0
  40. package/dist/esm/types/components/TextInput/TextInput.styles.d.ts +1 -0
  41. package/dist/esm/types/index.d.ts +1 -0
  42. package/dist/index.d.ts +19 -22
  43. package/dist/index.js +1 -0
  44. package/dist/src/theme/global.css +65 -0
  45. package/dist/theme/tokens/components/action-button.css +13 -0
  46. package/package.json +1 -1
  47. package/src/components/DatePicker/DatePicker.tsx +8 -3
  48. package/src/components/Dropdown/Dropdown.stories.tsx +1 -0
  49. package/src/components/Dropdown/Dropdown.tsx +51 -34
  50. package/src/components/InputFilter/InputFilter.stories.tsx +71 -0
  51. package/src/components/InputFilter/InputFilter.styles.ts +69 -0
  52. package/src/components/InputFilter/InputFilter.tsx +55 -0
  53. package/src/components/Search/Search.stories.tsx +1 -1
  54. package/src/components/Search/Search.tsx +13 -2
  55. package/src/components/TextInput/TextInput.styles.ts +84 -11
  56. package/src/components/TextInput/TextInput.tsx +51 -10
  57. package/src/index.ts +1 -0
  58. package/src/theme/tokens/components/action-button.css +13 -0
@@ -142,34 +142,78 @@ export const labelVariant = cva(
142
142
  {
143
143
  variants: {
144
144
  size: {
145
- sm: [
145
+ sm: [],
146
+ md: [],
147
+ lg: [],
148
+ },
149
+ disabled: {
150
+ true: "text-input-default-text placeholder:text-input-default-text",
151
+ },
152
+ error: {
153
+ true: "ring-error",
154
+ },
155
+ hasSearchIcon: {
156
+ false: "",
157
+ },
158
+ isFloatingLabel: {
159
+ false: "hidden peer-placeholder-shown:block peer-focus:bg-transparent",
160
+ },
161
+ },
162
+ compoundVariants: [
163
+ // floating = true
164
+ {
165
+ isFloatingLabel: true,
166
+ size: "sm",
167
+ className: [
146
168
  "left-3 -top-1.5 typography-label2 bg-input-label-bg",
147
169
  "peer-placeholder-shown:top-2 peer-placeholder-shown:typography-small1 peer-placeholder-shown:bg-transparent",
148
170
  "peer-focus:-top-1.5 peer-focus:typography-label2",
149
171
  ],
150
- md: [
172
+ },
173
+ {
174
+ isFloatingLabel: true,
175
+ size: "md",
176
+ className: [
151
177
  "left-3 -top-1.5 typography-label1 bg-input-label-bg",
152
178
  "peer-placeholder-shown:top-2 peer-placeholder-shown:typography-subtitile4 peer-placeholder-shown:bg-transparent",
153
179
  "peer-focus:-top-1.5 peer-focus:typography-label1",
154
180
  ],
155
- lg: [
181
+ },
182
+ {
183
+ isFloatingLabel: true,
184
+ size: "lg",
185
+ className: [
156
186
  "left-4 -top-1.5 typography-label1 bg-input-label-bg",
157
187
  "peer-placeholder-shown:top-4 peer-placeholder-shown:typography-subtitile1 peer-placeholder-shown:bg-transparent",
158
188
  "peer-focus:-top-1.5 peer-focus:typography-label1",
159
189
  ],
160
190
  },
161
- disabled: {
162
- true: "text-input-default-text placeholder:text-input-default-text",
191
+ // --------------
192
+ // flating = false
193
+ {
194
+ isFloatingLabel: false,
195
+ size: "sm",
196
+ className: [
197
+ "left-3 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-small1",
198
+ ],
163
199
  },
164
- error: {
165
- true: "ring-error",
200
+ {
201
+ isFloatingLabel: false,
202
+ size: "md",
203
+ className: [
204
+ "left-3 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-subtitile4",
205
+ ],
166
206
  },
167
- hasSearchIcon: {
168
- false: "",
207
+ {
208
+ isFloatingLabel: false,
209
+ size: "lg",
210
+ className: [
211
+ "left-4 peer-placeholder-shown:top-4 peer-placeholder-shown:typography-subtitile1",
212
+ ],
169
213
  },
170
- },
171
- compoundVariants: [
214
+ // --------------
172
215
  {
216
+ isFloatingLabel: true,
173
217
  hasSearchIcon: true,
174
218
  size: "sm",
175
219
  className: [
@@ -179,6 +223,7 @@ export const labelVariant = cva(
179
223
  ],
180
224
  },
181
225
  {
226
+ isFloatingLabel: true,
182
227
  hasSearchIcon: true,
183
228
  size: "md",
184
229
  className: [
@@ -188,6 +233,7 @@ export const labelVariant = cva(
188
233
  ],
189
234
  },
190
235
  {
236
+ isFloatingLabel: true,
191
237
  hasSearchIcon: true,
192
238
  size: "lg",
193
239
  className: [
@@ -196,12 +242,38 @@ export const labelVariant = cva(
196
242
  "peer-focus:-top-1.5 peer-focus:typography-label1",
197
243
  ],
198
244
  },
245
+ // floating = false and has search icon
246
+ {
247
+ isFloatingLabel: false,
248
+ hasSearchIcon: true,
249
+ size: "sm",
250
+ className: [
251
+ "left-6 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-small1",
252
+ ],
253
+ },
254
+ {
255
+ isFloatingLabel: false,
256
+ hasSearchIcon: true,
257
+ size: "md",
258
+ className: [
259
+ "left-9 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-subtitile4",
260
+ ],
261
+ },
262
+ {
263
+ isFloatingLabel: false,
264
+ hasSearchIcon: true,
265
+ size: "lg",
266
+ className: [
267
+ "left-11 peer-placeholder-shown:top-4 peer-placeholder-shown:typography-subtitile1",
268
+ ],
269
+ },
199
270
  ],
200
271
  defaultVariants: {
201
272
  size: "md",
202
273
  disabled: false,
203
274
  error: false,
204
275
  hasSearchIcon: false,
276
+ isFloatingLabel: true,
205
277
  },
206
278
  }
207
279
  );
@@ -285,6 +357,7 @@ export const iconVariant = cva(
285
357
 
286
358
  export const sectionIconWrapperVariant = cva(
287
359
  [
360
+ "cursor-pointer",
288
361
  "absolute items-center justify-center flex",
289
362
  "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",
290
363
  "fill-input-default-text peer-hover:fill-input-filled-text peer-focus:fill-input-filled-text peer-disabled:fill-input-disable-stroke",
@@ -2,6 +2,7 @@ import React, {
2
2
  FC,
3
3
  ReactNode,
4
4
  forwardRef,
5
+ useCallback,
5
6
  useImperativeHandle,
6
7
  useRef,
7
8
  } from "react";
@@ -34,12 +35,17 @@ export type InputProps = {
34
35
  disabled?: boolean;
35
36
  error?: boolean;
36
37
  required?: boolean;
38
+ isFloatingLabel?: boolean;
39
+ keepCloseIconOnValue?: boolean;
37
40
  hasClearIcon?: boolean;
38
41
  hasSearchIcon?: boolean;
39
42
  startIcon?: ReactNode;
40
43
  endIcon?: ReactNode;
41
44
  className?: string;
42
45
  labelClassName?: string;
46
+ onClickStartIcon?: () => void;
47
+ onClickEndIcon?: () => void;
48
+ renderEndIcon?: () => ReactNode;
43
49
  } & Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">;
44
50
 
45
51
  export const TextInput = forwardRef<HTMLInputElement, InputProps>(
@@ -57,11 +63,15 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
57
63
  disabled = false,
58
64
  error = false,
59
65
  required = true,
66
+ isFloatingLabel = true,
67
+ keepCloseIconOnValue = false,
60
68
  hasClearIcon = true,
61
69
  hasSearchIcon = false,
62
70
  startIcon,
63
71
  endIcon,
64
72
  labelClassName,
73
+ onClickEndIcon,
74
+ renderEndIcon,
65
75
  ...props
66
76
  },
67
77
  ref
@@ -87,6 +97,7 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
87
97
  disabled,
88
98
  error,
89
99
  hasSearchIcon,
100
+ isFloatingLabel,
90
101
  });
91
102
  const helperTextClassname = helperTextVariant({ size, error, disabled });
92
103
  const iconWrapperClassname = iconWrapperVariant({ size });
@@ -101,11 +112,26 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
101
112
 
102
113
  useImperativeHandle(ref, () => inputRef?.current as HTMLInputElement);
103
114
 
104
- const handleClearInput = () => {
115
+ const handleClearInput = useCallback(() => {
105
116
  if (inputRef.current) {
106
117
  inputRef.current.value = "";
118
+
119
+ if (props.onChange) {
120
+ const event = new Event("input", { bubbles: true });
121
+ props.onChange({ target: { value: "" } } as any);
122
+ }
123
+ }
124
+ }, [props.onChange]);
125
+
126
+ // TODO startIcon
127
+ const handleOnClickRightSectionIcon = useCallback(() => {
128
+ if (disabled) return;
129
+
130
+ onClickEndIcon?.();
131
+ if (inputRef.current) {
132
+ inputRef.current.focus();
107
133
  }
108
- };
134
+ }, [disabled, onClickEndIcon]);
109
135
 
110
136
  return (
111
137
  <div className={`inline-flex flex-col ${fullwidth ? "w-full" : ""}`}>
@@ -125,7 +151,13 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
125
151
  className={cn(inputClassname, props.className)}
126
152
  />
127
153
  {hasClearIcon && !hasRightSectionIcon && (
128
- <div className={iconWrapperClassname}>
154
+ <div
155
+ className={iconWrapperClassname}
156
+ style={{
157
+ display:
158
+ keepCloseIconOnValue && props.value ? "flex" : undefined,
159
+ }}
160
+ >
129
161
  <XCircleIcon
130
162
  type="button"
131
163
  className={iconClassname}
@@ -133,8 +165,15 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
133
165
  />
134
166
  </div>
135
167
  )}
136
- {hasRightSectionIcon && (
137
- <div className={endIconWrapperClassname}>{endIcon}</div>
168
+ {hasRightSectionIcon && renderEndIcon ? (
169
+ renderEndIcon()
170
+ ) : (
171
+ <div
172
+ className={endIconWrapperClassname}
173
+ onClick={handleOnClickRightSectionIcon}
174
+ >
175
+ {endIcon}
176
+ </div>
138
177
  )}
139
178
 
140
179
  <label htmlFor={_id} className={cn(labelClassname, labelClassName)}>
@@ -152,11 +191,13 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
152
191
  </div>
153
192
  {(errorMessage || helperText) && (
154
193
  <span className={helperTextClassname}>
155
- <ExclamationCircleIcon
156
- width={16}
157
- height={16}
158
- className={error ? "fill-error" : ""}
159
- />{" "}
194
+ <span className="h-full">
195
+ <ExclamationCircleIcon
196
+ width={16}
197
+ height={16}
198
+ className={error ? "fill-error" : ""}
199
+ />
200
+ </span>
160
201
  {errorMessage || helperText}
161
202
  </span>
162
203
  )}
package/src/index.ts CHANGED
@@ -30,6 +30,7 @@ export * from "./components/DataTable/DataTable";
30
30
  export * from "./components/Dialog/Dialog";
31
31
  export * from "./components/AlertDialog/AlertDialog";
32
32
  export * from "./components/Search/Search";
33
+ export * from "./components/InputFilter/InputFilter";
33
34
  export * from "./components/Slider/Slider";
34
35
  export * from "./components/Switch/Switch";
35
36
  export * from "./components/DropdownMenu/DropdownMenu";
@@ -11,6 +11,19 @@
11
11
  /* Solid Mode Tokens */
12
12
  /* ------------------------------------------------------------------ */
13
13
 
14
+ /* TODO */
15
+ --function-default-solid: #ececec;
16
+ --function-default-hover: #fafafa;
17
+ --function-default-hover-bg: rgba(250 250 250 / 0.08);
18
+ --function-default-stroke: rgba(158 158 158 / 0.24);
19
+ --function-default-icon: #212b36;
20
+ --function-default-outline-icon: #9e9e9e;
21
+ --function-active-solid: #b1a400;
22
+ --function-active-hover: #ddcd00;
23
+ --function-active-hover-bg: rgba(221 205 0 / 0.08);
24
+ --function-active-stroke: rgba(177 164 0 / 0.48);
25
+ --function-active-icon: #212b36;
26
+
14
27
  /* Default State */
15
28
  --action-button-solid-default-bg: var(--state-color-primary-default);
16
29
  --action-button-solid-default-border: var(--state-color-primary-default);