@xjur-ui/react 1.0.0 → 1.0.2

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 (117) hide show
  1. package/.turbo/turbo-build.log +63 -57
  2. package/CHANGELOG.md +18 -0
  3. package/dist/components/avatar.d.ts +11 -0
  4. package/dist/components/avatar.js +58 -0
  5. package/dist/components/badge.d.ts +13 -0
  6. package/dist/components/{ui/input/message.js → badge.js} +30 -47
  7. package/dist/components/{ui/button.d.ts → button.d.ts} +2 -2
  8. package/dist/components/{ui/button.js → button.js} +9 -6
  9. package/dist/components/calendar.d.ts +11 -0
  10. package/dist/components/calendar.js +751 -0
  11. package/dist/components/checkbox.d.ts +8 -0
  12. package/dist/components/{ui/input/root.js → checkbox.js} +69 -79
  13. package/dist/components/chip.d.ts +24 -0
  14. package/dist/components/chip.js +255 -0
  15. package/dist/components/collapsible.d.ts +8 -0
  16. package/dist/components/collapsible.js +41 -0
  17. package/dist/components/date-picker.d.ts +20 -0
  18. package/dist/components/date-picker.js +232 -0
  19. package/dist/components/divider.d.ts +7 -0
  20. package/dist/components/divider.js +28 -0
  21. package/dist/components/dropdown-menu.d.ts +22 -0
  22. package/dist/components/dropdown-menu.js +294 -0
  23. package/dist/components/{resources/icons.d.ts → icon.d.ts} +11 -2
  24. package/dist/components/{ui/icon.js → icon.js} +20 -5
  25. package/dist/components/input.d.ts +32 -0
  26. package/dist/components/input.js +315 -0
  27. package/dist/components/list.d.ts +25 -0
  28. package/dist/components/{ui/input/content.js → list.js} +83 -87
  29. package/dist/components/{ui/logo.d.ts → logo.d.ts} +2 -2
  30. package/dist/components/{ui/logo.js → logo.js} +5 -5
  31. package/dist/components/{ui/otp-input.js → otp-input.js} +1 -1
  32. package/dist/components/radio.d.ts +10 -0
  33. package/dist/components/{ui/input/label.js → radio.js} +68 -77
  34. package/dist/components/search-input.d.ts +17 -0
  35. package/dist/components/search-input.js +274 -0
  36. package/dist/components/select.d.ts +33 -0
  37. package/dist/components/select.js +550 -0
  38. package/dist/components/sheet.d.ts +19 -0
  39. package/dist/components/sheet.js +251 -0
  40. package/dist/components/switch.d.ts +7 -0
  41. package/dist/components/switch.js +36 -0
  42. package/dist/components/tabs.d.ts +11 -0
  43. package/dist/components/tabs.js +54 -0
  44. package/dist/components/tag.d.ts +18 -0
  45. package/dist/components/tag.js +189 -0
  46. package/dist/components/{ui/typography.d.ts → typography.d.ts} +4 -4
  47. package/dist/components/{ui/typography.js → typography.js} +1 -1
  48. package/dist/index.css +1233 -62
  49. package/dist/index.d.ts +2 -17
  50. package/dist/index.js +0 -788
  51. package/eslint.config.js +8 -1
  52. package/package.json +41 -10
  53. package/src/components/avatar.tsx +53 -0
  54. package/src/components/badge.tsx +40 -0
  55. package/src/components/{ui/button.tsx → button.tsx} +7 -5
  56. package/src/components/calendar.tsx +123 -0
  57. package/src/components/checkbox.tsx +57 -0
  58. package/src/components/chip.tsx +109 -0
  59. package/src/components/collapsible.tsx +35 -0
  60. package/src/components/date-picker.tsx +160 -0
  61. package/src/components/divider.tsx +23 -0
  62. package/src/components/dropdown-menu.tsx +101 -0
  63. package/src/components/{ui/icon.tsx → icon.tsx} +1 -1
  64. package/src/components/input.tsx +256 -0
  65. package/src/components/list.tsx +111 -0
  66. package/src/components/radio.tsx +74 -0
  67. package/src/components/search-input.tsx +112 -0
  68. package/src/components/select.tsx +240 -0
  69. package/src/components/sheet.tsx +141 -0
  70. package/src/components/switch.tsx +31 -0
  71. package/src/components/tabs.tsx +53 -0
  72. package/src/components/tag.tsx +91 -0
  73. package/src/index.css +4 -1
  74. package/src/index.ts +0 -1
  75. package/src/{components/resources → resources}/icons.ts +16 -1
  76. package/src/resources/input-mask.ts +91 -0
  77. package/dist/components/resources/icons.js +0 -133
  78. package/dist/components/resources/logo/horizontal.d.ts +0 -12
  79. package/dist/components/resources/logo/horizontal.js +0 -107
  80. package/dist/components/resources/logo/icon.d.ts +0 -12
  81. package/dist/components/resources/logo/icon.js +0 -79
  82. package/dist/components/resources/logo/index.d.ts +0 -4
  83. package/dist/components/resources/logo/index.js +0 -291
  84. package/dist/components/resources/logo/vertical.d.ts +0 -12
  85. package/dist/components/resources/logo/vertical.js +0 -107
  86. package/dist/components/ui/accordion.d.ts +0 -5
  87. package/dist/components/ui/accordion.js +0 -8
  88. package/dist/components/ui/icon.d.ts +0 -12
  89. package/dist/components/ui/index.d.ts +0 -17
  90. package/dist/components/ui/index.js +0 -788
  91. package/dist/components/ui/input/content.d.ts +0 -9
  92. package/dist/components/ui/input/index.d.ts +0 -12
  93. package/dist/components/ui/input/index.js +0 -335
  94. package/dist/components/ui/input/label.d.ts +0 -12
  95. package/dist/components/ui/input/message.d.ts +0 -10
  96. package/dist/components/ui/input/root.d.ts +0 -18
  97. package/dist/components/ui/input/slot.d.ts +0 -10
  98. package/dist/components/ui/input/slot.js +0 -20
  99. package/dist/components/ui/input/text.d.ts +0 -10
  100. package/dist/components/ui/input/text.js +0 -195
  101. package/src/components/ui/accordion.tsx +0 -3
  102. package/src/components/ui/index.ts +0 -13
  103. package/src/components/ui/input/content.tsx +0 -59
  104. package/src/components/ui/input/index.ts +0 -6
  105. package/src/components/ui/input/label.tsx +0 -41
  106. package/src/components/ui/input/message.tsx +0 -37
  107. package/src/components/ui/input/root.tsx +0 -57
  108. package/src/components/ui/input/slot.tsx +0 -21
  109. package/src/components/ui/input/text.tsx +0 -69
  110. /package/dist/components/{ui/otp-input.d.ts → otp-input.d.ts} +0 -0
  111. /package/src/components/{ui/logo.tsx → logo.tsx} +0 -0
  112. /package/src/components/{ui/otp-input.tsx → otp-input.tsx} +0 -0
  113. /package/src/components/{ui/typography.tsx → typography.tsx} +0 -0
  114. /package/src/{components/resources → resources}/logo/horizontal.tsx +0 -0
  115. /package/src/{components/resources → resources}/logo/icon.tsx +0 -0
  116. /package/src/{components/resources → resources}/logo/index.ts +0 -0
  117. /package/src/{components/resources → resources}/logo/vertical.tsx +0 -0
@@ -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