@ourtrip/ui 1.0.4 → 1.0.6

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/README.md ADDED
@@ -0,0 +1,434 @@
1
+ # @ourtrip/ui
2
+
3
+ A modern React component library built with Tailwind CSS, providing a comprehensive set of UI components for building beautiful and responsive user interfaces.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Using npm
9
+ npm install @ourtrip/ui
10
+
11
+ # Using yarn
12
+ yarn add @ourtrip/ui
13
+
14
+ # Using pnpm
15
+ pnpm add @ourtrip/ui
16
+ ```
17
+
18
+ ## Setup
19
+
20
+ ### Tailwind CSS Configuration
21
+
22
+ This component library requires Tailwind CSS. If you don't have it installed in your project, please follow the [official Tailwind CSS installation guide](https://tailwindcss.com/docs/installation).
23
+
24
+ Once Tailwind CSS is installed, update your `tailwind.config.js` or `tailwind.config.ts` file to include the following configuration:
25
+
26
+ ```js
27
+ /** @type {import('tailwindcss').Config} */
28
+ const config = {
29
+ content: [
30
+ "./src/**/*.{js,ts,jsx,tsx}",
31
+ "./node_modules/@ourtrip/ui/**/*.{js,ts,jsx,tsx}"
32
+ ],
33
+ theme: {
34
+ extend: {},
35
+ },
36
+ plugins: [],
37
+ };
38
+
39
+ export default config;
40
+ ```
41
+
42
+ This ensures Tailwind CSS processes the styles used in the @ourtrip/ui components.
43
+
44
+ ## Usage
45
+
46
+ Import components from the library as follows:
47
+
48
+ ```jsx
49
+ import { Button, Card, Input } from "@ourtrip/ui";
50
+
51
+ function App() {
52
+ return (
53
+ <Card>
54
+ <h2>Hello World</h2>
55
+ <Input label="Name" placeholder="Enter your name" />
56
+ <Button>Submit</Button>
57
+ </Card>
58
+ );
59
+ }
60
+ ```
61
+
62
+ ## Components
63
+
64
+ ### Accordion
65
+
66
+ Expandable content sections for organizing information.
67
+
68
+ ```jsx
69
+ <Accordion title="Frequently Asked Questions" text="This is the content of the accordion" />
70
+ ```
71
+
72
+ ### Alert
73
+
74
+ Provides contextual feedback messages for user actions.
75
+
76
+ ```jsx
77
+ <Alert type="success" variant="fill">
78
+ Your data has been successfully saved!
79
+ </Alert>
80
+ ```
81
+
82
+ **Props**:
83
+ - `type`: 'info' | 'success' | 'danger' | 'warning'
84
+ - `variant`: 'fill' | 'outline'
85
+
86
+ ### Badge
87
+
88
+ Compact element to represent status, count, or categorization.
89
+
90
+ ```jsx
91
+ <Badge type="success" size="normal">New</Badge>
92
+ ```
93
+
94
+ **Props**:
95
+ - `type`: 'success' | 'warning' | 'danger' | 'info' | 'white' | 'primary' | 'secondary'
96
+ - `size`: 'small' | 'normal' | 'large'
97
+ - `icon`: ReactNode (optional)
98
+
99
+ ### Breadcrumbs
100
+
101
+ Navigation element to show the user's location in the site hierarchy.
102
+
103
+ ```jsx
104
+ const items = [
105
+ { id: "1", text: "Home", href: "/" },
106
+ { id: "2", text: "Products", href: "/products" },
107
+ { id: "3", text: "Product Details", href: "/products/1" }
108
+ ];
109
+
110
+ <Breadcrumbs items={items} />
111
+ ```
112
+
113
+ ### Button
114
+
115
+ Interactive element for user actions.
116
+
117
+ ```jsx
118
+ <Button
119
+ variant="fill"
120
+ color="primary"
121
+ size="normal"
122
+ onClick={() => console.log('Button clicked!')}
123
+ >
124
+ Click Me
125
+ </Button>
126
+ ```
127
+
128
+ **Props**:
129
+ - `variant`: 'fill' | 'outline'
130
+ - `color`: 'primary' | 'secondary' | 'danger' | 'gray' | 'white'
131
+ - `size`: 'small' | 'normal' | 'large' | 'icon'
132
+ - `loading`: boolean
133
+ - `disabled`: boolean
134
+ - `fullWidth`: boolean
135
+
136
+ ### Card
137
+
138
+ Container for content with predefined styling.
139
+
140
+ ```jsx
141
+ <Card>
142
+ <h3>Card Title</h3>
143
+ <p>Card content goes here</p>
144
+ </Card>
145
+ ```
146
+
147
+ ### Checkbox
148
+
149
+ Selection component for multiple choices.
150
+
151
+ ```jsx
152
+ <Checkbox
153
+ label="I agree to terms and conditions"
154
+ onChange={(checked) => console.log(checked)}
155
+ />
156
+ ```
157
+
158
+ **Props**:
159
+ - `value`: boolean
160
+ - `onChange`: (checked: boolean) => void
161
+ - `label`: ReactNode
162
+ - `trailing`: string | number (optional)
163
+
164
+ ### Collapse
165
+
166
+ Toggleable content area.
167
+
168
+ ```jsx
169
+ <Collapse
170
+ title="More Information"
171
+ content="This content can be hidden or shown"
172
+ togglePosition="bottom"
173
+ showPreview={true}
174
+ />
175
+ ```
176
+
177
+ ### Divider
178
+
179
+ Horizontal or vertical line to separate content.
180
+
181
+ ```jsx
182
+ <Divider orientation="horizontal" />
183
+ ```
184
+
185
+ **Props**:
186
+ - `orientation`: 'horizontal' | 'vertical'
187
+ - `fullHeight`: boolean
188
+
189
+ ### Input
190
+
191
+ Text input field for user data entry.
192
+
193
+ ```jsx
194
+ <Input
195
+ label="Email Address"
196
+ placeholder="Enter your email"
197
+ type="email"
198
+ color="gray"
199
+ />
200
+ ```
201
+
202
+ **Props**:
203
+ - `label`: string
204
+ - `color`: 'white' | 'gray'
205
+ - `error`: string
206
+ - `disabled`: boolean
207
+
208
+ ### Modal
209
+
210
+ Dialogs for important information or actions.
211
+
212
+ ```jsx
213
+ const [isOpen, setIsOpen] = useState(false);
214
+
215
+ <>
216
+ <Button onClick={() => setIsOpen(true)}>Open Modal</Button>
217
+ <Modal
218
+ isOpen={isOpen}
219
+ onClose={() => setIsOpen(false)}
220
+ showCloseButton={true}
221
+ >
222
+ <h3>Modal Title</h3>
223
+ <p>Modal content</p>
224
+ </Modal>
225
+ </>
226
+ ```
227
+
228
+ ### PhoneInput
229
+
230
+ Specialized input for phone numbers with country codes.
231
+
232
+ ```jsx
233
+ <PhoneInput
234
+ t={translation}
235
+ DDI="+55"
236
+ phoneDDIKey="phone.ddi"
237
+ phoneAreaCodeKey="phone.areaCode"
238
+ phoneNumberKey="phone.number"
239
+ registerWithMask={registerWithMask}
240
+ setFocus={setFocus}
241
+ errors={errors}
242
+ />
243
+ ```
244
+
245
+ ### Popover
246
+
247
+ Floating content that appears on interaction.
248
+
249
+ ```jsx
250
+ <Popover>
251
+ <PopoverTrigger asChild>
252
+ <Button>Open Popover</Button>
253
+ </PopoverTrigger>
254
+ <PopoverContent>
255
+ <p>Popover content</p>
256
+ </PopoverContent>
257
+ </Popover>
258
+ ```
259
+
260
+ ### Radio
261
+
262
+ Selection component for single choices.
263
+
264
+ ```jsx
265
+ <Radio label="Option 1" name="options" value="1" />
266
+ <Radio label="Option 2" name="options" value="2" />
267
+ ```
268
+
269
+ **Props**:
270
+ - `label`: string
271
+ - `size`: 'small' | 'normal' | 'large'
272
+
273
+ ### Range
274
+
275
+ Slider for selecting a value or range.
276
+
277
+ ```jsx
278
+ <Range
279
+ min={0}
280
+ max={100}
281
+ initialValues={[20, 80]}
282
+ onChange={(values) => console.log(values)}
283
+ />
284
+ ```
285
+
286
+ ### Select
287
+
288
+ Dropdown selection component.
289
+
290
+ ```jsx
291
+ <Select>
292
+ <SelectTrigger>
293
+ <SelectValue placeholder="Select an option" />
294
+ </SelectTrigger>
295
+ <SelectContent>
296
+ <SelectItem value="option1">Option 1</SelectItem>
297
+ <SelectItem value="option2">Option 2</SelectItem>
298
+ </SelectContent>
299
+ </Select>
300
+ ```
301
+
302
+ ### Sheet
303
+
304
+ Slide-in panel from the edge of the screen.
305
+
306
+ ```jsx
307
+ <Sheet>
308
+ <SheetTrigger asChild>
309
+ <Button>Open Sheet</Button>
310
+ </SheetTrigger>
311
+ <SheetContent side="right">
312
+ <h3>Sheet Title</h3>
313
+ <p>Sheet content</p>
314
+ </SheetContent>
315
+ </Sheet>
316
+ ```
317
+
318
+ ### Stars
319
+
320
+ Rating component for displaying ratings.
321
+
322
+ ```jsx
323
+ <Stars rate={4.5} />
324
+ ```
325
+
326
+ ### StepMarker
327
+
328
+ Visual indicator for multi-step processes.
329
+
330
+ ```jsx
331
+ <StepMarker
332
+ step={1}
333
+ title="Personal Information"
334
+ subtitle="Enter your details"
335
+ checked={false}
336
+ active={true}
337
+ onClick={() => goToStep(1)}
338
+ />
339
+ ```
340
+
341
+ ### Switch
342
+
343
+ Toggle between two states.
344
+
345
+ ```jsx
346
+ <Switch
347
+ on={isEnabled}
348
+ onChange={(on) => setIsEnabled(on)}
349
+ label="Enable notifications"
350
+ />
351
+ ```
352
+
353
+ ### Tag
354
+
355
+ Label element for categorization.
356
+
357
+ ```jsx
358
+ <Tag color="primary" onClick={() => console.log('Tag clicked')}>
359
+ Featured
360
+ </Tag>
361
+ ```
362
+
363
+ **Props**:
364
+ - `color`: 'primary' | 'secondary' | 'white'
365
+ - `iconLeft`: ReactNode
366
+ - `iconRight`: ReactNode
367
+
368
+ ### Tooltip
369
+
370
+ Information that appears on hover.
371
+
372
+ ```jsx
373
+ <Tooltip text="Additional information" active={true}>
374
+ <Button>Hover me</Button>
375
+ </Tooltip>
376
+ ```
377
+
378
+ ## Utility Functions
379
+
380
+ The library provides some utility functions:
381
+
382
+ ### Validation
383
+
384
+ ```jsx
385
+ import { isValidEmail, isValidCpf, isFullName } from '@ourtrip/ui';
386
+
387
+ const isEmail = isValidEmail('user@example.com'); // Returns true
388
+ ```
389
+
390
+ Available validation functions:
391
+ - `isValidCpf`: Validates a Brazilian CPF
392
+ - `isValidCNPJ`: Validates a Brazilian CNPJ
393
+ - `isCPF`: Checks if a string is a valid CPF
394
+ - `isCNPJ`: Checks if a string is a valid CNPJ
395
+ - `isFullName`: Validates if a string is a full name
396
+ - `isValidName`: Validates if a string is a valid name
397
+ - `isValidEmail`: Validates email format
398
+ - `isValidPhoneNumber`: Validates phone number format
399
+ - `isValidNumberCode`: Validates a numeric code
400
+ - `isValidDDD`: Validates Brazilian area codes
401
+ - `isValidChildDate`: Validates if a date is for a minor
402
+ - `isValidAdult`: Validates if a date is for an adult
403
+
404
+ ### Classes
405
+
406
+ ```jsx
407
+ import { cn } from '@ourtrip/ui';
408
+
409
+ const className = cn('base-class', condition && 'conditional-class');
410
+ ```
411
+
412
+ ## Browser Support
413
+
414
+ This library supports modern browsers including:
415
+ - Chrome (latest)
416
+ - Firefox (latest)
417
+ - Safari (latest)
418
+ - Edge (latest)
419
+
420
+ ## License
421
+
422
+ ISC
423
+
424
+ ## Dependencies
425
+
426
+ This library builds on several excellent packages including:
427
+ - React and React DOM
428
+ - @phosphor-icons/react
429
+ - Radix UI components
430
+ - Tailwind CSS
431
+ - Framer Motion
432
+ - date-fns
433
+
434
+ You don't need to install these dependencies separately as they are included in the package.
@@ -0,0 +1,30 @@
1
+ image: node:18
2
+
3
+ definitions:
4
+ caches:
5
+ npm: ~/.npm
6
+
7
+ pipelines:
8
+ branches:
9
+ master:
10
+ - step:
11
+ name: Build and publish to npm
12
+ caches:
13
+ - npm
14
+ script:
15
+ - npm install --legacy-peer-deps
16
+ - npm run build
17
+ - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
18
+ - npm publish --access public
19
+ artifacts:
20
+ - dist/**
21
+
22
+ pull-requests:
23
+ '**':
24
+ - step:
25
+ name: Build and test
26
+ caches:
27
+ - npm
28
+ script:
29
+ - npm install
30
+ - npm run build
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ourtrip/ui",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -16,16 +16,12 @@
16
16
  "@babel/preset-env": "^7.26.9",
17
17
  "@babel/preset-react": "^7.26.3",
18
18
  "@babel/preset-typescript": "^7.26.0",
19
- "@rollup/plugin-commonjs": "^28.0.3",
20
- "@rollup/plugin-node-resolve": "^16.0.1",
21
19
  "@types/react": "^19.0.10",
22
20
  "@types/react-dom": "^19.0.4",
23
21
  "@types/react-slider": "^1.3.6",
24
22
  "microbundle": "^0.15.1",
25
23
  "react": "^19.0.0",
26
24
  "react-dom": "^19.0.0",
27
- "rollup": "^2.79.2",
28
- "rollup-plugin-typescript2": "^0.36.0",
29
25
  "ts-loader": "^9.5.2",
30
26
  "typescript": "^5.8.2",
31
27
  "webpack": "^5.98.0",
package/rollup.config.js DELETED
@@ -1,29 +0,0 @@
1
- const resolve = require('@rollup/plugin-node-resolve');
2
- const commonjs = require('@rollup/plugin-commonjs');
3
- const typescript = require('rollup-plugin-typescript2');
4
-
5
- module.exports = {
6
- input: 'src/index.tsx',
7
- output: [
8
- {
9
- file: 'dist/index.cjs.js',
10
- format: 'cjs',
11
- sourcemap: true,
12
- exports: 'named'
13
- },
14
- {
15
- file: 'dist/index.esm.js',
16
- format: 'esm',
17
- sourcemap: true
18
- }
19
- ],
20
- external: ['react', 'react-dom'],
21
- plugins: [
22
- resolve(),
23
- commonjs(),
24
- typescript({
25
- useTsconfigDeclarationDir: true,
26
- clean: true
27
- })
28
- ]
29
- };