@ourtrip/ui 1.0.5 → 1.0.7

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.
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "@ourtrip/ui",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "webpack"
9
9
  },
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
10
15
  "keywords": [],
11
16
  "author": "",
12
17
  "license": "ISC",
@@ -16,16 +21,12 @@
16
21
  "@babel/preset-env": "^7.26.9",
17
22
  "@babel/preset-react": "^7.26.3",
18
23
  "@babel/preset-typescript": "^7.26.0",
19
- "@rollup/plugin-commonjs": "^28.0.3",
20
- "@rollup/plugin-node-resolve": "^16.0.1",
21
24
  "@types/react": "^19.0.10",
22
25
  "@types/react-dom": "^19.0.4",
23
26
  "@types/react-slider": "^1.3.6",
24
27
  "microbundle": "^0.15.1",
25
28
  "react": "^19.0.0",
26
29
  "react-dom": "^19.0.0",
27
- "rollup": "^2.79.2",
28
- "rollup-plugin-typescript2": "^0.36.0",
29
30
  "ts-loader": "^9.5.2",
30
31
  "typescript": "^5.8.2",
31
32
  "webpack": "^5.98.0",
@@ -1,52 +0,0 @@
1
- 'use client';
2
-
3
- import React, { useState } from 'react';
4
-
5
- interface IAccordionProps {
6
- title: string;
7
- text: string;
8
- }
9
-
10
- const Accordion = ({ title, text }: IAccordionProps) => {
11
- const [open, setOpen] = useState<boolean>(false);
12
-
13
- return (
14
- <div
15
- className='w-full flex flex-col p-6 border border-gray-200 rounded-default cursor-pointer'
16
- onClick={() => setOpen(prev => !prev)}
17
- >
18
- <div className='flex items-center gap-6'>
19
- <div
20
- className={`relative w-10 h-10 rounded-full flex justify-center items-center transition-colors duration-300 ${
21
- open ? 'bg-primary-900' : 'bg-gray-100'
22
- }`}
23
- >
24
- <div
25
- className={`absolute w-4 h-0.5 rounded transition-transform duration-300 ${
26
- open
27
- ? 'bg-primary-900 transform rotate-[-90deg]'
28
- : 'bg-primary-900 transform rotate-[-180deg]'
29
- }`}
30
- />
31
- <div
32
- className={`absolute w-4 h-0.5 rounded transition-transform duration-300 ${
33
- open
34
- ? 'bg-white transform rotate-0'
35
- : 'bg-primary-900 transform rotate-[-90deg]'
36
- }`}
37
- />
38
- </div>
39
- <h2 className='font-medium text-lg text-primary-900'>{title}</h2>
40
- </div>
41
- <div
42
- className={`pl-16 overflow-hidden transition-max-height duration-500 ease-in-out ${
43
- open ? 'max-h-56' : 'max-h-0'
44
- }`}
45
- >
46
- <p className='pt-2.5 text-base text-gray-500 leading-7'>{text}</p>
47
- </div>
48
- </div>
49
- );
50
- };
51
-
52
- export default Accordion;
@@ -1,56 +0,0 @@
1
- 'use client';
2
-
3
- import React, { FC, ReactNode } from 'react';
4
- import { Check, Info, Warning, WarningCircle } from '@phosphor-icons/react';
5
-
6
- type TAlertType = 'info' | 'success' | 'danger' | 'warning';
7
- type TAlertVariant = 'fill' | 'outline';
8
-
9
- interface IAlertProps {
10
- type: TAlertType;
11
- variant: TAlertVariant;
12
- children: ReactNode;
13
- }
14
-
15
- const iconByAlertType: Record<TAlertType, ReactNode> = {
16
- danger: <WarningCircle size={24} />,
17
- success: <Check size={24} />,
18
- info: <Info size={24} />,
19
- warning: <Warning size={24} />
20
- };
21
-
22
- const Alert: FC<IAlertProps> = ({ type, variant, children }) => {
23
- const baseClasses = 'rounded-default p-4 flex items-start gap-4';
24
- const typeVariantClasses: Record<
25
- TAlertType,
26
- Record<TAlertVariant, string>
27
- > = {
28
- info: {
29
- fill: 'bg-info-500 text-white',
30
- outline: 'border border-info-500 text-info-500'
31
- },
32
- success: {
33
- fill: 'bg-success-500 text-white',
34
- outline: 'border border-success-500 text-success-500'
35
- },
36
- danger: {
37
- fill: 'bg-danger-500 text-white',
38
- outline: 'border border-danger-500 text-danger-500'
39
- },
40
- warning: {
41
- fill: 'bg-warning-500 text-white',
42
- outline: 'border border-warning-500 text-warning-500'
43
- }
44
- };
45
-
46
- const className = `${baseClasses} ${typeVariantClasses[type][variant]}`;
47
-
48
- return (
49
- <div className={className}>
50
- {iconByAlertType[type]}
51
- <div>{children}</div>
52
- </div>
53
- );
54
- };
55
-
56
- export default Alert;
@@ -1,84 +0,0 @@
1
- 'use client';
2
-
3
- import React, { FC, ReactNode } from 'react';
4
-
5
- type BadgeSize = 'small' | 'normal' | 'large';
6
-
7
- interface IBadgeProps {
8
- icon?: ReactNode;
9
- children: ReactNode;
10
- type:
11
- | 'success'
12
- | 'warning'
13
- | 'danger'
14
- | 'info'
15
- | 'white'
16
- | 'primary'
17
- | 'secondary';
18
- size?: BadgeSize;
19
- mobile?: boolean;
20
- className?: string;
21
- }
22
-
23
- const Badge: FC<IBadgeProps> = ({
24
- children,
25
- icon,
26
- type,
27
- size = 'normal',
28
- mobile,
29
- className
30
- }) => {
31
- const baseClasses = `flex items-center rounded-button ${
32
- mobile ? 'lg:hidden md:flex' : ''
33
- } ${className || ''}`;
34
- let typeClasses = '';
35
-
36
- const sizeClasses = {
37
- small: 'px-2 py-1 gap-0',
38
- normal: 'py-2 px-3 gap-2',
39
- large: 'py-3 px-4 gap-3'
40
- }[size];
41
-
42
- const textSizesClasses = {
43
- small: 'text-xs font-normal',
44
- normal: 'text-sm font-semibold',
45
- large: 'text-base font-semibold'
46
- }[size];
47
-
48
- switch (type) {
49
- case 'success':
50
- typeClasses = 'bg-success-100 text-success-600';
51
- break;
52
- case 'warning':
53
- typeClasses = 'bg-warning-100 text-warning-600';
54
- break;
55
- case 'danger':
56
- typeClasses = 'bg-danger-100 text-danger-600';
57
- break;
58
- case 'info':
59
- typeClasses = 'bg-info-100 text-info-900';
60
- break;
61
- case 'white':
62
- typeClasses = 'bg-white text-gray-900';
63
- break;
64
- case 'primary':
65
- typeClasses = 'bg-primary-500 text-white';
66
- break;
67
- case 'secondary':
68
- typeClasses = 'bg-gray-100 text-primary-500';
69
- break;
70
- default:
71
- typeClasses = '';
72
- }
73
-
74
- const textClasses = `font-semibold whitespace-nowrap ${textSizesClasses}`;
75
-
76
- return (
77
- <div className={`${baseClasses} ${typeClasses} ${sizeClasses}`}>
78
- {icon && <span className='mr-2'>{icon}</span>}
79
- <p className={textClasses}>{children}</p>
80
- </div>
81
- );
82
- };
83
-
84
- export default Badge;
@@ -1,48 +0,0 @@
1
- 'use client';
2
-
3
- /* eslint-disable jsx-a11y/no-static-element-interactions */
4
- /* eslint-disable jsx-a11y/click-events-have-key-events */
5
- /* eslint-disable jsx-a11y/anchor-is-valid */
6
- import React from 'react';
7
- import { CaretRight } from '@phosphor-icons/react';
8
-
9
- export type BreadcrumbsItemType = {
10
- id: string;
11
- text: string;
12
- href: string;
13
- };
14
-
15
- interface IBreadcrumbsProps {
16
- items: BreadcrumbsItemType[];
17
- }
18
-
19
- const Breadcrumbs = ({ items }: IBreadcrumbsProps) => {
20
- return (
21
- <div className='flex items-center gap-2.5'>
22
- {items?.map((item, index) => {
23
- const isActive = index !== items.length - 1;
24
- return (
25
- <div key={item.id} className='flex items-center gap-2.5'>
26
- <a
27
- onClick={() => {
28
- if (isActive) {
29
- window.open(item.href, '_blank');
30
- }
31
- }}
32
- className={`no-underline text-blue-900 text-sm ${
33
- isActive
34
- ? 'hover:text-blue-500 hover:cursor-pointer'
35
- : 'cursor-text'
36
- }`}
37
- >
38
- {item.text}
39
- </a>
40
- {isActive && <CaretRight />}
41
- </div>
42
- );
43
- })}
44
- </div>
45
- );
46
- };
47
-
48
- export default Breadcrumbs;
@@ -1,187 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import { CircleNotch } from '@phosphor-icons/react';
5
- import { cva, type VariantProps } from 'class-variance-authority';
6
- import { cn } from '../utils/classes';
7
-
8
- const buttonVariants = cva(
9
- 'flex items-center justify-center gap-2 whitespace-nowrap transition-colors focus:outline-hidden',
10
- {
11
- variants: {
12
- variant: {
13
- fill: '',
14
- outline: 'bg-transparent border'
15
- },
16
- color: {
17
- primary: '',
18
- secondary: '',
19
- danger: '',
20
- gray: '',
21
- white: ''
22
- },
23
- size: {
24
- small: 'h-[32px] px-4 text-sm',
25
- normal: 'h-[40px] px-6 text-base',
26
- large: 'h-[48px] px-8 text-lg',
27
- icon: 'h-[40px] w-[40px] p-0'
28
- },
29
- shape: {
30
- default: 'rounded-inner',
31
- rounded: 'rounded-full'
32
- },
33
- fontWeight: {
34
- normal: 'font-normal',
35
- bold: 'font-medium'
36
- },
37
- fullWidth: {
38
- true: 'w-full',
39
- false: ''
40
- },
41
- fullHeight: {
42
- true: 'h-full',
43
- false: ''
44
- },
45
- disabled: {
46
- true: 'bg-gray-200 text-gray-900 border-none cursor-not-allowed hover:bg-gray-200 hover:text-gray-900',
47
- false: ''
48
- }
49
- },
50
- compoundVariants: [
51
- {
52
- variant: 'fill',
53
- color: 'primary',
54
- disabled: false,
55
- className: 'bg-primary-500 text-white hover:bg-primary-400 active:bg-primary-600'
56
- },
57
- {
58
- variant: 'fill',
59
- color: 'secondary',
60
- disabled: false,
61
- className: 'bg-secondary-500 text-white hover:bg-secondary-400 active:bg-secondary-600'
62
- },
63
- {
64
- variant: 'fill',
65
- color: 'danger',
66
- disabled: false,
67
- className: 'bg-red-500 text-white hover:bg-red-400 active:bg-red-600'
68
- },
69
- {
70
- variant: 'fill',
71
- color: 'gray',
72
- disabled: false,
73
- className: 'bg-gray-100 text-gray-700 hover:bg-gray-200 active:bg-gray-300'
74
- },
75
- {
76
- variant: 'fill',
77
- color: 'white',
78
- disabled: false,
79
- className: 'bg-white text-black hover:bg-gray-200'
80
- },
81
- {
82
- variant: 'outline',
83
- color: 'primary',
84
- disabled: false,
85
- className:
86
- 'text-primary-500 border-primary-500 hover:text-primary-400 hover:border-primary-400'
87
- },
88
- {
89
- variant: 'outline',
90
- color: 'secondary',
91
- disabled: false,
92
- className:
93
- 'text-secondary-500 border-secondary-500 hover:text-secondary-400 hover:border-secondary-400'
94
- },
95
- {
96
- variant: 'outline',
97
- color: 'danger',
98
- disabled: false,
99
- className:
100
- 'text-red-500 border-red-500 hover:text-red-400 hover:border-red-400'
101
- },
102
- {
103
- variant: 'outline',
104
- color: 'gray',
105
- disabled: false,
106
- className:
107
- 'text-gray-300 border-gray-300 hover:text-gray-500 hover:border-gray-400'
108
- },
109
- {
110
- variant: 'outline',
111
- color: 'white',
112
- disabled: false,
113
- className:
114
- 'text-white border-white hover:text-gray-200 hover:border-gray-200'
115
- }
116
- ],
117
- defaultVariants: {
118
- variant: 'fill',
119
- color: 'primary',
120
- size: 'normal',
121
- shape: 'default',
122
- fontWeight: 'normal',
123
- fullWidth: false,
124
- fullHeight: false,
125
- disabled: false
126
- }
127
- }
128
- );
129
-
130
- interface ButtonProps
131
- extends React.ButtonHTMLAttributes<HTMLButtonElement>,
132
- VariantProps<typeof buttonVariants> {
133
- loading?: boolean;
134
- color?: 'primary' | 'secondary' | 'danger' | 'gray' | 'white';
135
- disabled?: boolean;
136
- }
137
-
138
- const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
139
- (
140
- {
141
- className,
142
- variant,
143
- color,
144
- size,
145
- shape,
146
- fontWeight,
147
- fullWidth,
148
- fullHeight,
149
- disabled,
150
- loading = false,
151
- children,
152
- ...props
153
- },
154
- ref
155
- ) => {
156
- return (
157
- <button
158
- className={cn(
159
- buttonVariants({
160
- variant,
161
- color,
162
- size,
163
- shape,
164
- fontWeight,
165
- fullWidth,
166
- fullHeight,
167
- disabled: disabled || loading
168
- }),
169
- className
170
- )}
171
- ref={ref}
172
- disabled={disabled || loading}
173
- {...props}
174
- >
175
- {loading ? (
176
- <CircleNotch className='animate-spin' weight='bold' />
177
- ) : (
178
- children
179
- )}
180
- </button>
181
- );
182
- }
183
- );
184
-
185
- Button.displayName = 'Button';
186
-
187
- export default Button;
@@ -1,23 +0,0 @@
1
- 'use client';
2
-
3
- import React, { FC, HTMLAttributes, ReactNode } from 'react';
4
-
5
- interface ICardProps {
6
- children: ReactNode;
7
- }
8
-
9
- const Card: FC<ICardProps & HTMLAttributes<HTMLDivElement>> = ({
10
- children,
11
- ...props
12
- }) => {
13
- return (
14
- <div
15
- className='p-4 rounded-default border bg-white border-gray-200'
16
- {...props}
17
- >
18
- {children}
19
- </div>
20
- );
21
- };
22
-
23
- export default Card;
@@ -1,70 +0,0 @@
1
- 'use client';
2
-
3
- import React, { ReactNode, memo, useEffect, useState } from 'react';
4
- import { Check } from '@phosphor-icons/react';
5
- import Stars from './stars';
6
-
7
- interface ICheckbox {
8
- value?: boolean;
9
- // eslint-disable-next-line no-unused-vars
10
- onChange?: (checked: boolean) => void;
11
- label?: ReactNode;
12
- trailing?: string | number;
13
- textColor?: 'primary';
14
- type?: string;
15
- }
16
-
17
- const Checkbox = ({
18
- value,
19
- onChange,
20
- label,
21
- trailing,
22
- textColor,
23
- type
24
- }: ICheckbox) => {
25
- const [checked, setChecked] = useState<boolean>(value || false);
26
- useEffect(() => {
27
- if (value !== undefined) setChecked(value);
28
- }, [value]);
29
-
30
- return (
31
- <div
32
- className='w-full flex items-center justify-between cursor-pointer gap-2 select-none'
33
- onClick={() => {
34
- setChecked(prev => !prev);
35
- onChange?.(!checked);
36
- }}
37
- >
38
- <div className='flex items-center gap-2'>
39
- <div
40
- className={`w-5 h-5 flex items-center justify-center border border-primary-500 rounded-md flex-none mt-[3px] hover:bg-primary-500 ${
41
- checked ? 'bg-primary-500' : ''
42
- }`}
43
- >
44
- {checked && <Check size={12} color='white' weight='bold' />}
45
- </div>
46
- {label && (
47
- <p
48
- className={`flex items-center gap-1 text-sm mt-1 ${
49
- textColor === 'primary' ? 'text-primary-900' : 'text-gray-500'
50
- }`}
51
- >
52
- {type === 'stars' ? (
53
- <Stars rate={parseFloat(label.toString())} />
54
- ) : (
55
- label
56
- )}
57
- </p>
58
- )}
59
- </div>
60
- {trailing !== undefined && (
61
- <p className='text-sm text-gray-500'>{trailing}</p>
62
- )}
63
- </div>
64
- );
65
- };
66
-
67
- const propsAreEqual = (prevProps: ICheckbox, nextProps: ICheckbox) =>
68
- prevProps.value === nextProps.value && prevProps.label === nextProps.label;
69
-
70
- export default memo(Checkbox, propsAreEqual);
@@ -1,56 +0,0 @@
1
- 'use client';
2
-
3
- import React, { FC, ReactNode, useState } from 'react';
4
- import { CaretDown, CaretUp } from '@phosphor-icons/react';
5
-
6
- type TToggleType = 'bottom' | 'right';
7
- type IToggleTextType = {
8
- open: string;
9
- close: string;
10
- };
11
-
12
- interface ICollapseProps {
13
- title: string;
14
- content: ReactNode;
15
- showPreview?: boolean;
16
- toggleText?: IToggleTextType;
17
- togglePosition?: TToggleType;
18
- }
19
-
20
- const Collapse: FC<ICollapseProps> = ({
21
- title,
22
- content,
23
- showPreview = false,
24
- togglePosition = 'right',
25
- toggleText
26
- }) => {
27
- const [open, setOpen] = useState(false);
28
-
29
- return (
30
- <div
31
- className={`relative flex items-start ${
32
- togglePosition === 'right' ? 'flex-row' : 'flex-col'
33
- } gap-3`}
34
- onClick={() => setOpen(prev => !prev)}
35
- >
36
- <div className='mt-1'>
37
- <h3 className='text-sm text-primary-900'>{title}</h3>
38
- <div
39
- className={`overflow-hidden transition-max-height duration-300 ease-in-out ${
40
- open ? 'max-h-[1000px]' : showPreview ? 'max-h-12' : 'max-h-0'
41
- }`}
42
- >
43
- <p className='mt-1 text-gray-500'>{content}</p>
44
- </div>
45
- </div>
46
- <div className='flex items-center gap-2'>
47
- {toggleText && <span>{open ? toggleText.close : toggleText.open}</span>}
48
- <div className='w-7 h-7 rounded-full bg-gray-100 flex items-center justify-center'>
49
- {open ? <CaretUp size={18} /> : <CaretDown size={18} />}
50
- </div>
51
- </div>
52
- </div>
53
- );
54
- };
55
-
56
- export default Collapse;
@@ -1,28 +0,0 @@
1
- 'use client';
2
-
3
- import React, { HTMLAttributes } from 'react';
4
- import classNames from 'classnames';
5
-
6
- interface IDivider extends HTMLAttributes<HTMLDivElement> {
7
- orientation?: 'horizontal' | 'vertical';
8
- fullHeight?: boolean;
9
- className?: string;
10
- }
11
-
12
- const Divider = ({
13
- orientation = 'vertical',
14
- fullHeight,
15
- className,
16
- ...props
17
- }: IDivider) => {
18
- const dividerClass = classNames({
19
- 'w-px h-10 bg-gray-200': orientation === 'vertical' && !fullHeight,
20
- 'w-full h-px bg-gray-200': orientation === 'horizontal',
21
- 'w-px h-full bg-gray-200': orientation === 'vertical' && fullHeight,
22
- [className as string]: className
23
- });
24
-
25
- return <div {...props} className={dividerClass} />;
26
- };
27
-
28
- export default Divider;