@rovula/ui 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.
Files changed (57) hide show
  1. package/dist/cjs/bundle.css +424 -9
  2. package/dist/cjs/bundle.js +3 -3
  3. package/dist/cjs/bundle.js.map +1 -1
  4. package/dist/cjs/types/components/AlertDialog/Alert.stories.d.ts +1 -1
  5. package/dist/cjs/types/components/Calendar/Calendar.d.ts +9 -0
  6. package/dist/cjs/types/components/Calendar/Calendar.stories.d.ts +724 -0
  7. package/dist/cjs/types/components/Calendar/index.d.ts +1 -0
  8. package/dist/cjs/types/components/DatePicker/DatePicker.d.ts +8 -0
  9. package/dist/cjs/types/components/DatePicker/DatePicker.stories.d.ts +21 -0
  10. package/dist/cjs/types/components/Popover/Popover.d.ts +6 -0
  11. package/dist/cjs/types/components/Popover/Popover.stories.d.ts +21 -0
  12. package/dist/cjs/types/components/TextInput/TextInput.stories.d.ts +7 -0
  13. package/dist/cjs/types/components/TextInput/TextInput.styles.d.ts +5 -0
  14. package/dist/cjs/types/index.d.ts +3 -0
  15. package/dist/components/Calendar/Calendar.js +34 -0
  16. package/dist/components/Calendar/Calendar.stories.js +38 -0
  17. package/dist/components/Calendar/index.js +1 -0
  18. package/dist/components/DatePicker/DatePicker.js +21 -0
  19. package/dist/components/DatePicker/DatePicker.stories.js +36 -0
  20. package/dist/components/Popover/Popover.js +35 -0
  21. package/dist/components/Popover/Popover.stories.js +33 -0
  22. package/dist/components/TextInput/TextInput.js +9 -3
  23. package/dist/components/TextInput/TextInput.stories.js +13 -1
  24. package/dist/components/TextInput/TextInput.styles.js +42 -1
  25. package/dist/esm/bundle.css +424 -9
  26. package/dist/esm/bundle.js +3 -3
  27. package/dist/esm/bundle.js.map +1 -1
  28. package/dist/esm/types/components/AlertDialog/Alert.stories.d.ts +1 -1
  29. package/dist/esm/types/components/Calendar/Calendar.d.ts +9 -0
  30. package/dist/esm/types/components/Calendar/Calendar.stories.d.ts +724 -0
  31. package/dist/esm/types/components/Calendar/index.d.ts +1 -0
  32. package/dist/esm/types/components/DatePicker/DatePicker.d.ts +8 -0
  33. package/dist/esm/types/components/DatePicker/DatePicker.stories.d.ts +21 -0
  34. package/dist/esm/types/components/Popover/Popover.d.ts +6 -0
  35. package/dist/esm/types/components/Popover/Popover.stories.d.ts +21 -0
  36. package/dist/esm/types/components/TextInput/TextInput.stories.d.ts +7 -0
  37. package/dist/esm/types/components/TextInput/TextInput.styles.d.ts +5 -0
  38. package/dist/esm/types/index.d.ts +3 -0
  39. package/dist/index.d.ts +19 -1
  40. package/dist/index.js +3 -0
  41. package/dist/src/theme/global.css +146 -8
  42. package/dist/theme/global.css +8 -4
  43. package/dist/theme/presets/colors.js +2 -2
  44. package/package.json +5 -2
  45. package/src/components/Calendar/Calendar.stories.tsx +49 -0
  46. package/src/components/Calendar/Calendar.tsx +49 -0
  47. package/src/components/Calendar/index.ts +1 -0
  48. package/src/components/DatePicker/DatePicker.stories.tsx +40 -0
  49. package/src/components/DatePicker/DatePicker.tsx +57 -0
  50. package/src/components/Popover/Popover.stories.tsx +40 -0
  51. package/src/components/Popover/Popover.tsx +31 -0
  52. package/src/components/TextInput/TextInput.stories.tsx +37 -1
  53. package/src/components/TextInput/TextInput.styles.ts +46 -1
  54. package/src/components/TextInput/TextInput.tsx +13 -3
  55. package/src/index.ts +7 -0
  56. package/src/theme/global.css +8 -4
  57. package/src/theme/presets/colors.js +2 -2
@@ -0,0 +1,40 @@
1
+ import React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import DatePicker from "./DatePicker";
4
+
5
+ // import { Popover, PopoverTrigger, PopoverContent } from "./Popover";
6
+
7
+ const meta = {
8
+ title: "Components/DatePicker",
9
+ component: DatePicker,
10
+ tags: ["autodocs"],
11
+ parameters: {
12
+ layout: "fullscreen",
13
+ },
14
+ decorators: [
15
+ (Story) => (
16
+ <div className="p-5 flex w-full">
17
+ <Story />
18
+ </div>
19
+ ),
20
+ ],
21
+ } satisfies Meta<typeof DatePicker>;
22
+
23
+ export default meta;
24
+
25
+ export const Default = {
26
+ args: {},
27
+ render: (args) => {
28
+ console.log("args ", args);
29
+ const props: typeof args = {
30
+ ...args,
31
+ };
32
+ const [date, setDate] = React.useState<Date | undefined>(undefined);
33
+
34
+ return (
35
+ <div className="flex flex-row gap-4 w-full">
36
+ <DatePicker date={date} onSelect={setDate} />
37
+ </div>
38
+ );
39
+ },
40
+ } satisfies StoryObj;
@@ -0,0 +1,57 @@
1
+ "use client";
2
+
3
+ import React, { FC, useState } from "react";
4
+ import { CalendarIcon } from "@heroicons/react/16/solid";
5
+
6
+ import { Calendar } from "../Calendar";
7
+ import { Popover, PopoverContent, PopoverTrigger } from "../Popover/Popover";
8
+ import { Modifiers } from "react-day-picker";
9
+ import { TextInput } from "../TextInput/TextInput";
10
+ import { format } from "date-fns/format";
11
+
12
+ type DatePickerProps = {
13
+ date: Date | undefined;
14
+ onSelect: (
15
+ selected: Date | undefined,
16
+ triggerDate: Date,
17
+ modifiers: Modifiers,
18
+ e: React.MouseEvent | React.KeyboardEvent
19
+ ) => void | undefined;
20
+ };
21
+
22
+ const DatePicker: FC<DatePickerProps> = ({ date, onSelect }) => {
23
+ const [isOpen, setIsOpen] = useState(false);
24
+
25
+ return (
26
+ <div>
27
+ <Popover open={isOpen} onOpenChange={setIsOpen}>
28
+ <PopoverTrigger asChild>
29
+ <div className="flex">
30
+ <TextInput
31
+ fullwidth
32
+ id="2"
33
+ readOnly
34
+ label="Date"
35
+ size="md"
36
+ value={date ? format(date, "dd MMM yyyy") : isOpen ? " " : ""}
37
+ hasClearIcon={false}
38
+ endIcon={<CalendarIcon fill="inherit" />}
39
+ />
40
+ </div>
41
+ </PopoverTrigger>
42
+ <PopoverContent className="w-auto p-0">
43
+ <Calendar
44
+ mode="single"
45
+ selected={date}
46
+ onSelect={(...value) => {
47
+ onSelect?.(...value);
48
+ setIsOpen(false);
49
+ }}
50
+ />
51
+ </PopoverContent>
52
+ </Popover>
53
+ </div>
54
+ );
55
+ };
56
+
57
+ export default DatePicker;
@@ -0,0 +1,40 @@
1
+ import React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+
4
+ import { Popover, PopoverTrigger, PopoverContent } from "./Popover";
5
+
6
+ const meta = {
7
+ title: "Components/Popver",
8
+ component: Popover,
9
+ tags: ["autodocs"],
10
+ parameters: {
11
+ layout: "fullscreen",
12
+ },
13
+ decorators: [
14
+ (Story) => (
15
+ <div className="p-5 flex w-full">
16
+ <Story />
17
+ </div>
18
+ ),
19
+ ],
20
+ } satisfies Meta<typeof Popover>;
21
+
22
+ export default meta;
23
+
24
+ export const Default = {
25
+ args: {},
26
+ render: (args) => {
27
+ console.log("args ", args);
28
+ const props: typeof args = {
29
+ ...args,
30
+ };
31
+ return (
32
+ <div className="flex flex-row gap-4 w-full">
33
+ <Popover>
34
+ <PopoverTrigger>Open</PopoverTrigger>
35
+ <PopoverContent>Place content for the popover here.</PopoverContent>
36
+ </Popover>
37
+ </div>
38
+ );
39
+ },
40
+ } satisfies StoryObj;
@@ -0,0 +1,31 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
5
+
6
+ import { cn } from "@/utils/cn";
7
+
8
+ const Popover = PopoverPrimitive.Root;
9
+
10
+ const PopoverTrigger = PopoverPrimitive.Trigger;
11
+
12
+ const PopoverContent = React.forwardRef<
13
+ React.ElementRef<typeof PopoverPrimitive.Content>,
14
+ React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
15
+ >(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
16
+ <PopoverPrimitive.Portal>
17
+ <PopoverPrimitive.Content
18
+ ref={ref}
19
+ align={align}
20
+ sideOffset={sideOffset}
21
+ className={cn(
22
+ "z-50 min-w-72 rounded-md border bg-popup-background border-none overflow-hidden p-0 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
23
+ className
24
+ )}
25
+ {...props}
26
+ />
27
+ </PopoverPrimitive.Portal>
28
+ ));
29
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
30
+
31
+ export { Popover, PopoverTrigger, PopoverContent };
@@ -1,6 +1,7 @@
1
1
  import React, { useRef } from "react";
2
2
  import type { Meta, StoryObj } from "@storybook/react";
3
3
  import TextInput from "./TextInput";
4
+ import { CalendarIcon } from "@heroicons/react/16/solid";
4
5
 
5
6
  // More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
6
7
  const meta = {
@@ -13,7 +14,7 @@ const meta = {
13
14
  },
14
15
  decorators: [
15
16
  (Story) => (
16
- <div className="p-5 flex w-full">
17
+ <div className="p-5 flex w-full bg-[rgb(var(--other-bg-2))]">
17
18
  <Story />
18
19
  </div>
19
20
  ),
@@ -87,3 +88,38 @@ export const CustomLabel = {
87
88
  );
88
89
  },
89
90
  } satisfies StoryObj;
91
+
92
+ export const FuctionInput = {
93
+ args: {
94
+ label: "Placeholder Text",
95
+ disabled: false,
96
+ },
97
+ render: (args) => {
98
+ console.log("args ", args);
99
+ const props: typeof args = {
100
+ ...args,
101
+ };
102
+ return (
103
+ <div className="flex flex-row gap-4 w-full">
104
+ <TextInput
105
+ id="1"
106
+ size="lg"
107
+ {...args}
108
+ endIcon={<CalendarIcon className="size-full" fill="inherit" />}
109
+ />
110
+ <TextInput
111
+ id="2"
112
+ size="md"
113
+ {...args}
114
+ endIcon={<CalendarIcon className="size-full" fill="inherit" />}
115
+ />
116
+ <TextInput
117
+ id="3"
118
+ size="sm"
119
+ {...args}
120
+ endIcon={<CalendarIcon className="size-full" fill="inherit" />}
121
+ />
122
+ </div>
123
+ );
124
+ },
125
+ } satisfies StoryObj;
@@ -4,7 +4,7 @@ export const inputVariant = cva(
4
4
  [
5
5
  "border-0 outline-none",
6
6
  "p-1 flex w-auto box-border",
7
- "peer text-black placeholder:text-transparent",
7
+ "peer text-black placeholder:text-transparent bg-transparent caret-primary",
8
8
  ],
9
9
  {
10
10
  variants: {
@@ -37,6 +37,9 @@ export const inputVariant = cva(
37
37
  hasClearIcon: {
38
38
  true: "",
39
39
  },
40
+ rightSectionIcon: {
41
+ false: "",
42
+ },
40
43
  },
41
44
  compoundVariants: [
42
45
  {
@@ -58,6 +61,21 @@ export const inputVariant = cva(
58
61
  size: "lg",
59
62
  class: "focus:pe-10",
60
63
  },
64
+ {
65
+ rightSectionIcon: true,
66
+ size: "sm",
67
+ class: "pe-[38px]",
68
+ },
69
+ {
70
+ rightSectionIcon: true,
71
+ size: "md",
72
+ class: "pe-[46px]",
73
+ },
74
+ {
75
+ rightSectionIcon: true,
76
+ size: "lg",
77
+ class: "pe-[72px]",
78
+ },
61
79
  ],
62
80
  defaultVariants: {
63
81
  size: "md",
@@ -67,6 +85,7 @@ export const inputVariant = cva(
67
85
  disabled: false,
68
86
  error: false,
69
87
  hasClearIcon: false,
88
+ rightSectionIcon: false,
70
89
  },
71
90
  }
72
91
  );
@@ -167,3 +186,29 @@ export const iconVariant = cva(
167
186
  },
168
187
  }
169
188
  );
189
+
190
+ export const sectionIconWrapperVariant = cva(
191
+ [
192
+ "absolute inset-y-0 right-0 items-center justify-center flex",
193
+ "border-l border-l-input-stroke peer-hover:border-l-input-active peer-focus:border-l-input-stroke-active peer-disabled:border-l-input-stroke-disabled",
194
+ "fill-input-text peer-hover:fill-input-text-active peer-focus:fill-input-text-active",
195
+ ],
196
+ {
197
+ variants: {
198
+ size: {
199
+ sm: "p-1 size-[30px]",
200
+ md: "p-2 size-[38px]",
201
+ lg: "p-3 size-14",
202
+ },
203
+ rounded: {
204
+ none: "rounded-r-none",
205
+ normal: "rounded-r-xl",
206
+ full: "rounded-r-full",
207
+ },
208
+ },
209
+ defaultVariants: {
210
+ size: "md",
211
+ rounded: "normal",
212
+ },
213
+ }
214
+ );
@@ -11,6 +11,7 @@ import {
11
11
  iconWrapperVariant,
12
12
  inputVariant,
13
13
  labelVariant,
14
+ sectionIconWrapperVariant,
14
15
  } from "./TextInput.styles";
15
16
  import { XCircleIcon, ExclamationCircleIcon } from "@heroicons/react/16/solid";
16
17
  import { cn } from "@/utils/cn";
@@ -58,6 +59,7 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
58
59
  ) => {
59
60
  const inputRef = useRef<HTMLInputElement>(null);
60
61
  const _id = id || `${type}-${label}-input`;
62
+ const hasRightSectionIcon = !!endIcon;
61
63
  const inputClassname = inputVariant({
62
64
  size,
63
65
  rounded,
@@ -65,7 +67,8 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
65
67
  fullwidth,
66
68
  disabled,
67
69
  error,
68
- hasClearIcon,
70
+ hasClearIcon: hasRightSectionIcon ? false : hasClearIcon,
71
+ rightSectionIcon: hasRightSectionIcon,
69
72
  });
70
73
  const labelClassname = labelVariant({
71
74
  size,
@@ -75,6 +78,10 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
75
78
  const helperTextClassname = helperTextVariant({ size, error, disabled });
76
79
  const iconWrapperClassname = iconWrapperVariant({ size });
77
80
  const iconClassname = iconVariant({ size });
81
+ const sectionIconWrapperClassname = sectionIconWrapperVariant({
82
+ size,
83
+ rounded,
84
+ });
78
85
 
79
86
  useImperativeHandle(ref, () => inputRef?.current as HTMLInputElement);
80
87
 
@@ -96,7 +103,7 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
96
103
  disabled={disabled}
97
104
  className={cn(inputClassname, props.className)}
98
105
  />
99
- {hasClearIcon && (
106
+ {hasClearIcon && !hasRightSectionIcon && (
100
107
  <div className={iconWrapperClassname}>
101
108
  <XCircleIcon
102
109
  type="button"
@@ -105,7 +112,10 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
105
112
  />
106
113
  </div>
107
114
  )}
108
- {endIcon}
115
+ {hasRightSectionIcon && (
116
+ <div className={sectionIconWrapperClassname}>{endIcon}</div>
117
+ )}
118
+
109
119
  <label htmlFor={_id} className={cn(labelClassname, labelClassName)}>
110
120
  {label} {required && <span className="text-error">*</span>}
111
121
  </label>
package/src/index.ts CHANGED
@@ -13,6 +13,13 @@ export { Navbar } from "./components/Navbar";
13
13
  export { default as ActionButton } from "./components/ActionButton/ActionButton";
14
14
  export { Avatar, AvatarGroup } from "./components/Avatar";
15
15
  export { Collapsible } from "./components/Collapsible";
16
+ export { Calendar } from "./components/Calendar";
17
+ export { default as DatePicker } from "./components/DatePicker/DatePicker";
18
+ export {
19
+ Popover,
20
+ PopoverTrigger,
21
+ PopoverContent,
22
+ } from "./components/Popover/Popover";
16
23
  export * from "./components/Table/Table";
17
24
  export * from "./components/DataTable/DataTable";
18
25
  export * from "./components/Dialog/Dialog";
@@ -176,6 +176,10 @@
176
176
  --text-grey-light: 164 169 178;
177
177
  --text-white: 255 255 255;
178
178
 
179
+ /* Other */
180
+ --other-bg: var(--white);
181
+ --other-bg-2: var(--white);
182
+
179
183
  /* Other/Popup */
180
184
  --popup-background: 249 251 255;
181
185
  /* Other/Popup Curtain */
@@ -192,8 +196,8 @@
192
196
 
193
197
  /* TODO for shadcn, wait for refactor */
194
198
  /* --background: 0 0% 100%; */
195
- --background: 220 100% 99%;
196
- --foreground: 222.2 47.4% 11.2%;
199
+ --background: var(--brand-background);
200
+ --foreground: var(--text-white:);
197
201
 
198
202
  --muted: 210 40% 96.1%;
199
203
  --muted-foreground: 215.4 16.3% 46.9%;
@@ -204,8 +208,8 @@
204
208
  --border: 214.3 31.8% 91.4%;
205
209
  --input: 214.3 31.8% 91.4%;
206
210
 
207
- --card: 0 0% 100%;
208
- --card-foreground: 222.2 47.4% 11.2%;
211
+ --card: var(--white);
212
+ --card-foreground: var(--primary);
209
213
 
210
214
  --primary: var(--primary-default);
211
215
 
@@ -7,8 +7,8 @@ module.exports = {
7
7
  colors: {
8
8
  border: "hsl(var(--border))",
9
9
  ring: "hsl(var(--ring))",
10
- background: "hsl(var(--background))",
11
- foreground: "hsl(var(--foreground))",
10
+ background: "rgb(var(--background) / <alpha-value>)",
11
+ foreground: "rgb(var(--foreground) / <alpha-value>)",
12
12
  // Palette colors
13
13
  themes: {
14
14
  50: "rgb(var(--themes-50) / <alpha-value>)",