@xjur-ui/react 1.0.0 → 1.0.1

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 (115) hide show
  1. package/.turbo/turbo-build.log +61 -57
  2. package/CHANGELOG.md +11 -0
  3. package/dist/components/avatar.d.ts +11 -0
  4. package/dist/components/avatar.js +58 -0
  5. package/dist/components/{ui/button.d.ts → button.d.ts} +2 -2
  6. package/dist/components/{ui/button.js → button.js} +9 -6
  7. package/dist/components/calendar.d.ts +11 -0
  8. package/dist/components/calendar.js +751 -0
  9. package/dist/components/checkbox.d.ts +8 -0
  10. package/dist/components/{ui/input/root.js → checkbox.js} +69 -79
  11. package/dist/components/chip.d.ts +24 -0
  12. package/dist/components/chip.js +255 -0
  13. package/dist/components/collapsible.d.ts +8 -0
  14. package/dist/components/collapsible.js +41 -0
  15. package/dist/components/date-picker.d.ts +20 -0
  16. package/dist/components/date-picker.js +230 -0
  17. package/dist/components/divider.d.ts +7 -0
  18. package/dist/components/divider.js +28 -0
  19. package/dist/components/dropdown-menu.d.ts +22 -0
  20. package/dist/components/dropdown-menu.js +294 -0
  21. package/dist/components/{resources/icons.d.ts → icon.d.ts} +11 -2
  22. package/dist/components/{ui/icon.js → icon.js} +18 -5
  23. package/dist/components/input.d.ts +32 -0
  24. package/dist/components/input.js +299 -0
  25. package/dist/components/list.d.ts +25 -0
  26. package/dist/components/{ui/input/content.js → list.js} +83 -87
  27. package/dist/components/{ui/logo.d.ts → logo.d.ts} +2 -2
  28. package/dist/components/{ui/logo.js → logo.js} +5 -5
  29. package/dist/components/{ui/otp-input.js → otp-input.js} +1 -1
  30. package/dist/components/radio.d.ts +10 -0
  31. package/dist/components/{ui/input/label.js → radio.js} +68 -77
  32. package/dist/components/search-input.d.ts +17 -0
  33. package/dist/components/search-input.js +274 -0
  34. package/dist/components/select.d.ts +33 -0
  35. package/dist/components/select.js +548 -0
  36. package/dist/components/sheet.d.ts +19 -0
  37. package/dist/components/sheet.js +251 -0
  38. package/dist/components/switch.d.ts +7 -0
  39. package/dist/components/switch.js +36 -0
  40. package/dist/components/tabs.d.ts +11 -0
  41. package/dist/components/tabs.js +54 -0
  42. package/dist/components/tag.d.ts +18 -0
  43. package/dist/components/tag.js +189 -0
  44. package/dist/components/{ui/typography.d.ts → typography.d.ts} +3 -3
  45. package/dist/components/{ui/typography.js → typography.js} +1 -1
  46. package/dist/index.css +1156 -62
  47. package/dist/index.d.ts +2 -17
  48. package/dist/index.js +0 -788
  49. package/eslint.config.js +8 -1
  50. package/package.json +40 -10
  51. package/src/components/avatar.tsx +53 -0
  52. package/src/components/{ui/button.tsx → button.tsx} +7 -5
  53. package/src/components/calendar.tsx +123 -0
  54. package/src/components/checkbox.tsx +57 -0
  55. package/src/components/chip.tsx +109 -0
  56. package/src/components/collapsible.tsx +35 -0
  57. package/src/components/date-picker.tsx +154 -0
  58. package/src/components/divider.tsx +23 -0
  59. package/src/components/dropdown-menu.tsx +101 -0
  60. package/src/components/{ui/icon.tsx → icon.tsx} +1 -1
  61. package/src/components/input.tsx +241 -0
  62. package/src/components/list.tsx +111 -0
  63. package/src/components/radio.tsx +74 -0
  64. package/src/components/search-input.tsx +112 -0
  65. package/src/components/select.tsx +234 -0
  66. package/src/components/sheet.tsx +141 -0
  67. package/src/components/switch.tsx +31 -0
  68. package/src/components/tabs.tsx +53 -0
  69. package/src/components/tag.tsx +91 -0
  70. package/src/index.css +4 -1
  71. package/src/index.ts +0 -1
  72. package/src/{components/resources → resources}/icons.ts +14 -1
  73. package/src/resources/input-mask.ts +91 -0
  74. package/dist/components/resources/icons.js +0 -133
  75. package/dist/components/resources/logo/horizontal.d.ts +0 -12
  76. package/dist/components/resources/logo/horizontal.js +0 -107
  77. package/dist/components/resources/logo/icon.d.ts +0 -12
  78. package/dist/components/resources/logo/icon.js +0 -79
  79. package/dist/components/resources/logo/index.d.ts +0 -4
  80. package/dist/components/resources/logo/index.js +0 -291
  81. package/dist/components/resources/logo/vertical.d.ts +0 -12
  82. package/dist/components/resources/logo/vertical.js +0 -107
  83. package/dist/components/ui/accordion.d.ts +0 -5
  84. package/dist/components/ui/accordion.js +0 -8
  85. package/dist/components/ui/icon.d.ts +0 -12
  86. package/dist/components/ui/index.d.ts +0 -17
  87. package/dist/components/ui/index.js +0 -788
  88. package/dist/components/ui/input/content.d.ts +0 -9
  89. package/dist/components/ui/input/index.d.ts +0 -12
  90. package/dist/components/ui/input/index.js +0 -335
  91. package/dist/components/ui/input/label.d.ts +0 -12
  92. package/dist/components/ui/input/message.d.ts +0 -10
  93. package/dist/components/ui/input/message.js +0 -128
  94. package/dist/components/ui/input/root.d.ts +0 -18
  95. package/dist/components/ui/input/slot.d.ts +0 -10
  96. package/dist/components/ui/input/slot.js +0 -20
  97. package/dist/components/ui/input/text.d.ts +0 -10
  98. package/dist/components/ui/input/text.js +0 -195
  99. package/src/components/ui/accordion.tsx +0 -3
  100. package/src/components/ui/index.ts +0 -13
  101. package/src/components/ui/input/content.tsx +0 -59
  102. package/src/components/ui/input/index.ts +0 -6
  103. package/src/components/ui/input/label.tsx +0 -41
  104. package/src/components/ui/input/message.tsx +0 -37
  105. package/src/components/ui/input/root.tsx +0 -57
  106. package/src/components/ui/input/slot.tsx +0 -21
  107. package/src/components/ui/input/text.tsx +0 -69
  108. /package/dist/components/{ui/otp-input.d.ts → otp-input.d.ts} +0 -0
  109. /package/src/components/{ui/logo.tsx → logo.tsx} +0 -0
  110. /package/src/components/{ui/otp-input.tsx → otp-input.tsx} +0 -0
  111. /package/src/components/{ui/typography.tsx → typography.tsx} +0 -0
  112. /package/src/{components/resources → resources}/logo/horizontal.tsx +0 -0
  113. /package/src/{components/resources → resources}/logo/icon.tsx +0 -0
  114. /package/src/{components/resources → resources}/logo/index.ts +0 -0
  115. /package/src/{components/resources → resources}/logo/vertical.tsx +0 -0
@@ -1,195 +0,0 @@
1
- // src/components/ui/input/text.tsx
2
- import { InputMask } from "@react-input/mask";
3
- import { useCallback, useEffect, useRef } from "react";
4
- import { cx as cx3 } from "@xjur-ui/util";
5
-
6
- // src/components/ui/input/root.tsx
7
- import { createContext, use } from "react";
8
- import { cx as cx2 } from "@xjur-ui/util";
9
-
10
- // src/components/ui/input/message.tsx
11
- import { memo as memo2 } from "react";
12
- import { cx } from "@xjur-ui/util";
13
-
14
- // src/components/ui/typography.tsx
15
- import { Slot } from "@radix-ui/react-slot";
16
- import { cva } from "@xjur-ui/util";
17
- import { memo } from "react";
18
- import { jsx } from "react/jsx-runtime";
19
- var typographyVariants = cva("", {
20
- variants: {
21
- variant: {
22
- body: "",
23
- label: "",
24
- title: "",
25
- headline: ""
26
- },
27
- size: {
28
- "sm-2x": "",
29
- "sm-1x": "",
30
- sm: "",
31
- md: "",
32
- lg: ""
33
- },
34
- weight: {
35
- thin: "font-thin",
36
- extraLight: "font-extralight",
37
- light: "font-light",
38
- normal: "font-normal",
39
- medium: "font-medium",
40
- semibold: "font-semibold",
41
- bold: "font-bold",
42
- extraBold: "font-extrabold",
43
- black: "font-black"
44
- }
45
- },
46
- compoundVariants: [
47
- { variant: "body", size: "sm-1x", class: "text-size-body-sm-1x" },
48
- { variant: "body", size: "sm", class: "text-size-body-sm" },
49
- { variant: "body", size: "md", class: "text-size-body-md" },
50
- { variant: "body", size: "lg", class: "text-size-body-lg" },
51
- { variant: "label", size: "sm-2x", class: "text-size-label-sm-2x" },
52
- { variant: "label", size: "sm-1x", class: "text-size-label-sm-1x" },
53
- { variant: "label", size: "sm", class: "text-size-label-sm" },
54
- { variant: "label", size: "md", class: "text-size-label-md" },
55
- { variant: "label", size: "lg", class: "text-size-label-lg" },
56
- { variant: "title", size: "sm", class: "text-size-title-sm" },
57
- { variant: "title", size: "md", class: "text-size-title-md" },
58
- { variant: "title", size: "lg", class: "text-size-title-lg" },
59
- { variant: "headline", size: "sm", class: "text-size-headline-sm" },
60
- { variant: "headline", size: "md", class: "text-size-headline-md" },
61
- { variant: "headline", size: "lg", class: "text-size-headline-lg" }
62
- ],
63
- defaultVariants: {
64
- variant: "body",
65
- size: "md",
66
- weight: "normal"
67
- }
68
- });
69
- var Typography = memo(
70
- ({
71
- variant,
72
- size,
73
- weight,
74
- asChild,
75
- className,
76
- ...props
77
- }) => {
78
- const Component = asChild ? Slot : "span";
79
- return /* @__PURE__ */ jsx(
80
- Component,
81
- {
82
- className: typographyVariants({ variant, size, weight, className }),
83
- ...props
84
- }
85
- );
86
- }
87
- );
88
- Typography.displayName = "Typography";
89
-
90
- // src/components/ui/input/message.tsx
91
- import { jsx as jsx2 } from "react/jsx-runtime";
92
- var InputMessage = memo2(
93
- ({
94
- children,
95
- className,
96
- weight = "normal",
97
- variant = "body",
98
- size = "sm-1x",
99
- ...props
100
- }) => {
101
- const { errorMessage } = useInput();
102
- return /* @__PURE__ */ jsx2(
103
- Typography,
104
- {
105
- className: cx(
106
- "text-neutral-dark data-[error=true]:text-danger-idle",
107
- className
108
- ),
109
- "data-error": !!errorMessage,
110
- size,
111
- variant,
112
- weight,
113
- ...props,
114
- children
115
- }
116
- );
117
- }
118
- );
119
- InputMessage.displayName = "InputMessage";
120
-
121
- // src/components/ui/input/root.tsx
122
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
123
- var InputRootContext = createContext({});
124
- function useInput() {
125
- const context = use(InputRootContext);
126
- if (!context) {
127
- throw new Error(
128
- "useInput must be called within <Input.Root> or <Select.Root>"
129
- );
130
- }
131
- return context;
132
- }
133
-
134
- // src/components/ui/input/text.tsx
135
- import { jsx as jsx4 } from "react/jsx-runtime";
136
- function InputText({
137
- className,
138
- value,
139
- mask,
140
- ...props
141
- }) {
142
- const { errorMessage } = useInput();
143
- const inputRef = useRef(null);
144
- const InputComponent = mask ? InputMask : "input";
145
- const onCheckInputFilled = useCallback(
146
- ({ shouldUnfill = false }) => {
147
- if (inputRef.current) {
148
- if (shouldUnfill) inputRef.current.dataset.filled = "false";
149
- else {
150
- const hasNotErrorAndHasValue = !errorMessage && !!inputRef.current.value;
151
- inputRef.current.dataset.filled = String(hasNotErrorAndHasValue);
152
- }
153
- }
154
- },
155
- [errorMessage]
156
- );
157
- function setRef(ref) {
158
- inputRef.current = ref;
159
- if (typeof props.ref === "function") {
160
- props.ref(ref);
161
- }
162
- }
163
- useEffect(() => {
164
- onCheckInputFilled({ shouldUnfill: false });
165
- }, [onCheckInputFilled]);
166
- return /* @__PURE__ */ jsx4(
167
- InputComponent,
168
- {
169
- ...props,
170
- ...mask && { ...mask },
171
- className: cx3(
172
- "h-full w-full bg-transparent",
173
- "border-hidden outline-hidden",
174
- "placeholder:text-placeholder-neutral font-normal",
175
- "text-neutral-dark text-size-body-md overflow-hidden text-ellipsis",
176
- className
177
- ),
178
- "data-filled": !!value && !errorMessage,
179
- readOnly: props.readOnly !== void 0 && props.readOnly,
180
- ref: setRef,
181
- value,
182
- onBlur: (event) => {
183
- props.onBlur?.(event);
184
- onCheckInputFilled({ shouldUnfill: false });
185
- },
186
- onFocus: (event) => {
187
- props.onFocus?.(event);
188
- onCheckInputFilled({ shouldUnfill: true });
189
- }
190
- }
191
- );
192
- }
193
- export {
194
- InputText
195
- };
@@ -1,3 +0,0 @@
1
- export function Accordion() {
2
- return <div>Accordion Test</div>
3
- }
@@ -1,13 +0,0 @@
1
- export { Button, type ButtonProps } from './button'
2
- export { Icon, type IconProps } from './icon'
3
- export { Typography, type TypographyProps } from './typography'
4
- export { Logo, type LogoProps } from './logo'
5
-
6
- export { InputRoot, type InputRootProps } from './input/root'
7
- export { InputText, type InputTextProps } from './input/text'
8
- export { InputContent, type InputContentProps } from './input/content'
9
- export { InputSlot, type InputSlotProps } from './input/slot'
10
-
11
- export { OTPInput } from './otp-input'
12
-
13
- export { Accordion } from './accordion'
@@ -1,59 +0,0 @@
1
- import type { ComponentProps } from 'react'
2
- import { cx, cva } from '@xjur-ui/util'
3
- import { useInput } from './root'
4
-
5
- const variants = cva(
6
- [
7
- 'flex items-center gap-small py-small_1x-alt px-small',
8
- 'border-1 border-border-layer-2',
9
- 'bg-layer-2-idle',
10
- 'group-hover:border-border-layer-3',
11
- 'transition-[border-color] duration-100 ease',
12
- 'data-[disabled=true]:pointer-events-none',
13
- 'has-[input[data-filled=true]]:bg-layer-2-hover'
14
- ],
15
- {
16
- variants: {
17
- isError: {
18
- true: 'border-1 border-danger-idle focus-within:border-danger-idle focus-within:shadow-focus-danger group-hover:border-danger-idle',
19
- false:
20
- 'focus-within:border-primary-idle focus-within:shadow-focus-primary'
21
- },
22
- rounded: {
23
- true: 'rounded-circle',
24
- false: 'rounded-small-1x'
25
- }
26
- },
27
- defaultVariants: {
28
- rounded: false
29
- }
30
- }
31
- )
32
-
33
- export type InputContentProps = ComponentProps<'div'> & {
34
- children: ComponentProps<'div'>['children']
35
- }
36
-
37
- export function InputContent({
38
- className,
39
- children,
40
- ...props
41
- }: InputContentProps) {
42
- const { errorMessage, rounded, disabled } = useInput()
43
-
44
- const classNames = variants({
45
- className,
46
- isError: !!errorMessage,
47
- rounded
48
- })
49
-
50
- return (
51
- <div
52
- {...props}
53
- className={cx('group', classNames)}
54
- data-disabled={disabled}
55
- >
56
- {children}
57
- </div>
58
- )
59
- }
@@ -1,6 +0,0 @@
1
- export * from './root'
2
- export * from './text'
3
- export * from './content'
4
- export * from './slot'
5
- export * from './message'
6
- export * from './label'
@@ -1,41 +0,0 @@
1
- import { memo } from 'react'
2
- import { cx } from '@xjur-ui/util'
3
- import { Typography, type TypographyProps } from '../typography'
4
- import { useInput } from './root'
5
-
6
- export type InputLabelProps = TypographyProps & {
7
- htmlFor?: string
8
- }
9
-
10
- export const InputLabel = memo(
11
- ({
12
- children,
13
- htmlFor,
14
- variant = 'label',
15
- weight = 'medium',
16
- size = 'sm',
17
- className,
18
- ...props
19
- }: InputLabelProps) => {
20
- const { errorMessage } = useInput()
21
-
22
- return (
23
- <Typography
24
- asChild={true}
25
- className={cx(
26
- 'text-title-neutral data-[error=true]:text-danger-label-active w-fit',
27
- className
28
- )}
29
- data-error={!!errorMessage}
30
- size={size}
31
- variant={variant}
32
- weight={weight}
33
- {...props}
34
- >
35
- <label htmlFor={htmlFor}>{children}</label>
36
- </Typography>
37
- )
38
- }
39
- )
40
-
41
- InputLabel.displayName = 'InputLabel'
@@ -1,37 +0,0 @@
1
- import { memo } from 'react'
2
- import { cx } from '@xjur-ui/util'
3
- import { Typography, type TypographyProps } from '../typography'
4
- import { useInput } from './root'
5
-
6
- export type InputMessageProps = TypographyProps
7
-
8
- export const InputMessage = memo(
9
- ({
10
- children,
11
- className,
12
- weight = 'normal',
13
- variant = 'body',
14
- size = 'sm-1x',
15
- ...props
16
- }: InputMessageProps) => {
17
- const { errorMessage } = useInput()
18
-
19
- return (
20
- <Typography
21
- className={cx(
22
- 'text-neutral-dark data-[error=true]:text-danger-idle',
23
- className
24
- )}
25
- data-error={!!errorMessage}
26
- size={size}
27
- variant={variant}
28
- weight={weight}
29
- {...props}
30
- >
31
- {children}
32
- </Typography>
33
- )
34
- }
35
- )
36
-
37
- InputMessage.displayName = 'InputMessage'
@@ -1,57 +0,0 @@
1
- import { type ComponentProps, createContext, use } from 'react'
2
- import { cx } from '@xjur-ui/util'
3
- import { InputMessage } from './message'
4
-
5
- export type InputRoot = {
6
- size?: 'md' | 'lg'
7
- rounded?: boolean
8
- errorMessage?: string
9
- disabled?: boolean
10
- }
11
-
12
- export const InputRootContext = createContext({} as InputRoot)
13
-
14
- export function useInput() {
15
- const context = use(InputRootContext)
16
-
17
- if (!context) {
18
- throw new Error(
19
- 'useInput must be called within <Input.Root> or <Select.Root>'
20
- )
21
- }
22
-
23
- return context
24
- }
25
-
26
- export type InputRootProps = ComponentProps<'div'> & {
27
- children: ComponentProps<'div'>['children']
28
- } & InputRoot
29
-
30
- export function InputRoot({
31
- children,
32
- className,
33
- errorMessage,
34
- size = 'lg',
35
- rounded = false,
36
- disabled,
37
- ...props
38
- }: InputRootProps) {
39
- return (
40
- <InputRootContext.Provider
41
- value={{ errorMessage, disabled, size, rounded }}
42
- >
43
- <div
44
- {...props}
45
- className={cx(
46
- 'group gap-small relative flex flex-col data-[disabled=true]:opacity-60',
47
- className
48
- )}
49
- data-disabled={disabled}
50
- >
51
- {children}
52
-
53
- {errorMessage && <InputMessage>{errorMessage}</InputMessage>}
54
- </div>
55
- </InputRootContext.Provider>
56
- )
57
- }
@@ -1,21 +0,0 @@
1
- import { type ComponentProps, memo } from 'react'
2
- import { cx } from '@xjur-ui/util'
3
-
4
- export type InputSlotProps = ComponentProps<'label'> & {
5
- children: ComponentProps<'label'>['children']
6
- }
7
-
8
- export const InputSlot = memo(
9
- ({ children, className, ...props }: InputSlotProps) => {
10
- return (
11
- <label
12
- {...props}
13
- className={cx('flex items-center justify-center', className)}
14
- >
15
- {children}
16
- </label>
17
- )
18
- }
19
- )
20
-
21
- InputSlot.displayName = 'InputSlot'
@@ -1,69 +0,0 @@
1
- import { InputMask, type MaskOptions } from '@react-input/mask'
2
- import { type ComponentProps, useCallback, useEffect, useRef } from 'react'
3
- import { cx } from '@xjur-ui/util'
4
- import { useInput } from './root'
5
-
6
- export type InputTextProps = ComponentProps<'input'> & { mask?: MaskOptions }
7
-
8
- export function InputText({
9
- className,
10
- value,
11
- mask,
12
- ...props
13
- }: InputTextProps) {
14
- const { errorMessage } = useInput()
15
- const inputRef = useRef<HTMLInputElement>(null)
16
- const InputComponent = mask ? InputMask : 'input'
17
-
18
- const onCheckInputFilled = useCallback(
19
- ({ shouldUnfill = false }: { shouldUnfill: boolean }) => {
20
- if (inputRef.current) {
21
- if (shouldUnfill) inputRef.current.dataset.filled = 'false'
22
- else {
23
- const hasNotErrorAndHasValue =
24
- !errorMessage && !!inputRef.current.value
25
- inputRef.current.dataset.filled = String(hasNotErrorAndHasValue)
26
- }
27
- }
28
- },
29
- [errorMessage]
30
- )
31
-
32
- function setRef(ref: HTMLInputElement) {
33
- inputRef.current = ref
34
-
35
- if (typeof props.ref === 'function') {
36
- props.ref(ref)
37
- }
38
- }
39
-
40
- useEffect(() => {
41
- onCheckInputFilled({ shouldUnfill: false })
42
- }, [onCheckInputFilled])
43
-
44
- return (
45
- <InputComponent
46
- {...props}
47
- {...(mask && { ...mask })}
48
- className={cx(
49
- 'h-full w-full bg-transparent',
50
- 'border-hidden outline-hidden',
51
- 'placeholder:text-placeholder-neutral font-normal',
52
- 'text-neutral-dark text-size-body-md overflow-hidden text-ellipsis',
53
- className
54
- )}
55
- data-filled={!!value && !errorMessage}
56
- readOnly={props.readOnly !== undefined && props.readOnly}
57
- ref={setRef}
58
- value={value}
59
- onBlur={event => {
60
- props.onBlur?.(event)
61
- onCheckInputFilled({ shouldUnfill: false })
62
- }}
63
- onFocus={event => {
64
- props.onFocus?.(event)
65
- onCheckInputFilled({ shouldUnfill: true })
66
- }}
67
- />
68
- )
69
- }
File without changes