@dafaz-ui/react 2.1.0 → 2.2.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.
package/dist/index.js CHANGED
@@ -20,6 +20,18 @@ var __spreadValues = (a, b) => {
20
20
  return a;
21
21
  };
22
22
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __objRest = (source, exclude) => {
24
+ var target = {};
25
+ for (var prop in source)
26
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
27
+ target[prop] = source[prop];
28
+ if (source != null && __getOwnPropSymbols)
29
+ for (var prop of __getOwnPropSymbols(source)) {
30
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
31
+ target[prop] = source[prop];
32
+ }
33
+ return target;
34
+ };
23
35
  var __export = (target, all) => {
24
36
  for (var name in all)
25
37
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -37,8 +49,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
37
49
  // src/index.tsx
38
50
  var src_exports = {};
39
51
  __export(src_exports, {
52
+ Box: () => Box,
40
53
  Button: () => Button,
54
+ Heading: () => Heading,
41
55
  Text: () => Text,
56
+ TextInput: () => TextInput,
42
57
  config: () => config,
43
58
  createTheme: () => createTheme,
44
59
  css: () => css,
@@ -149,8 +164,42 @@ var {
149
164
  }
150
165
  });
151
166
 
152
- // src/components/Button.tsx
153
- var Button = styled("button", {
167
+ // src/components/Box/styles.ts
168
+ var BoxUI = styled("div", {
169
+ padding: "$4",
170
+ variants: {
171
+ stretch: {
172
+ true: {
173
+ width: "100%"
174
+ },
175
+ false: {
176
+ width: "18.4375rem"
177
+ }
178
+ },
179
+ dark: {
180
+ true: {
181
+ background: "$gray800"
182
+ },
183
+ false: {
184
+ background: "transparent"
185
+ }
186
+ }
187
+ },
188
+ defaultVariants: {
189
+ stretch: false,
190
+ dark: false
191
+ }
192
+ });
193
+
194
+ // src/components/Box/index.tsx
195
+ var import_jsx_runtime = require("react/jsx-runtime");
196
+ function Box(_a) {
197
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
198
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BoxUI, __spreadProps(__spreadValues({}, props), { children }));
199
+ }
200
+
201
+ // src/components/Button/styles.ts
202
+ var ButtonUI = styled("button", {
154
203
  all: "unset",
155
204
  borderRadius: "$md",
156
205
  fontSize: "$md",
@@ -168,10 +217,6 @@ var Button = styled("button", {
168
217
  "&:disabled": {
169
218
  cursor: "not-allowed"
170
219
  },
171
- svg: {
172
- width: "$4",
173
- height: "$4"
174
- },
175
220
  variants: {
176
221
  variant: {
177
222
  primary: {
@@ -243,8 +288,24 @@ var Button = styled("button", {
243
288
  }
244
289
  });
245
290
 
246
- // src/components/Text.tsx
247
- var Text = styled("p", {
291
+ // src/components/Button/index.tsx
292
+ var import_jsx_runtime2 = require("react/jsx-runtime");
293
+ function Button(_a) {
294
+ var _b = _a, {
295
+ children,
296
+ variant = "primary",
297
+ size = "md"
298
+ } = _b, props = __objRest(_b, [
299
+ "children",
300
+ "variant",
301
+ "size"
302
+ ]);
303
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ButtonUI, __spreadProps(__spreadValues({ variant, size }, props), { children }));
304
+ }
305
+ ButtonUI.displayName = "Button";
306
+
307
+ // src/components/Text/styles.ts
308
+ var TextUI = styled("p", {
248
309
  fontFamily: "$web",
249
310
  lineHeight: "$base",
250
311
  margin: 0,
@@ -264,10 +325,155 @@ var Text = styled("p", {
264
325
  size: "md"
265
326
  }
266
327
  });
328
+
329
+ // src/components/Text/index.tsx
330
+ var import_jsx_runtime3 = require("react/jsx-runtime");
331
+ function Text(_a) {
332
+ var _b = _a, {
333
+ children,
334
+ size = "md"
335
+ } = _b, props = __objRest(_b, [
336
+ "children",
337
+ "size"
338
+ ]);
339
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TextUI, __spreadProps(__spreadValues({ size }, props), { children }));
340
+ }
341
+ Text.displayName = "Text";
342
+
343
+ // src/components/Heading/styles.ts
344
+ var HeadingUI = styled("h2", {
345
+ fontFamily: "$web",
346
+ lineHeight: "$shorter",
347
+ margin: 0,
348
+ variants: {
349
+ mode: {
350
+ default: {
351
+ color: "$dafaz400"
352
+ },
353
+ white: {
354
+ color: "$white"
355
+ }
356
+ },
357
+ size: {
358
+ sm: { fontSize: "$lg" },
359
+ md: { fontSize: "$xl" },
360
+ lg: { fontSize: "$2xl" },
361
+ xl: { fontSize: "3rem" },
362
+ "2xl": { fontSize: "4rem" }
363
+ }
364
+ },
365
+ defaultVariants: {
366
+ mode: "default",
367
+ size: "lg"
368
+ }
369
+ });
370
+
371
+ // src/components/Heading/index.tsx
372
+ var import_jsx_runtime4 = require("react/jsx-runtime");
373
+ function Heading(_a) {
374
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
375
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(HeadingUI, __spreadProps(__spreadValues({}, props), { children }));
376
+ }
377
+ Heading.displayName = "Heading";
378
+
379
+ // src/components/TextInput/index.tsx
380
+ var import_react2 = require("react");
381
+
382
+ // src/components/TextInput/styles.ts
383
+ var InputContainer = styled("div", {
384
+ margin: 0,
385
+ backgroundColor: "transparent",
386
+ borderBottom: "2px solid $dafaz600",
387
+ borderRadius: "$md",
388
+ boxSizing: "border-box",
389
+ display: "flex",
390
+ alignItems: "baseline",
391
+ padding: "$1 $2",
392
+ transition: "border 0.2s linear",
393
+ "&:has(input:focus)": {
394
+ borderBottom: "2px solid $dafaz400"
395
+ },
396
+ "&:has(input:disabled)": {
397
+ opacity: 0.5,
398
+ cursor: "not-allowed"
399
+ },
400
+ variants: {
401
+ withShadow: {
402
+ true: {
403
+ boxShadow: "inset 0 3rem #444"
404
+ }
405
+ }
406
+ },
407
+ defaultVariants: {
408
+ withShadow: false
409
+ }
410
+ });
411
+ var InputUI = styled("input", {
412
+ margin: 0,
413
+ fontFamily: "$app",
414
+ fontSize: "$xl",
415
+ color: "$white",
416
+ backgroundColor: "transparent",
417
+ border: "none",
418
+ "&::-ms-reveal": {
419
+ filter: "invert(100%)"
420
+ },
421
+ "&::placeholder": {
422
+ fontWeight: "$regular",
423
+ color: "$white",
424
+ opacity: 0.75
425
+ },
426
+ "&:focus": {
427
+ outline: 0
428
+ }
429
+ });
430
+ var Sufix = styled("span", {
431
+ fontFamily: "$app",
432
+ fontSize: "$sm",
433
+ color: "$white",
434
+ fontStyle: "italic",
435
+ "&:has(input:focus)": {
436
+ visibility: "hidden"
437
+ }
438
+ });
439
+
440
+ // src/components/TextInput/index.tsx
441
+ var import_jsx_runtime5 = require("react/jsx-runtime");
442
+ var TextInput = (0, import_react2.forwardRef)(
443
+ (_a, ref) => {
444
+ var _b = _a, {
445
+ withShadow = false,
446
+ required = true,
447
+ requiredText = "Opcional"
448
+ } = _b, props = __objRest(_b, [
449
+ "withShadow",
450
+ "required",
451
+ "requiredText"
452
+ ]);
453
+ const [hiddenOptional, setHiddenOptional] = (0, import_react2.useState)(required);
454
+ function handleOnChange(event) {
455
+ if (!required) {
456
+ if (event.target.value === "") {
457
+ setHiddenOptional(false);
458
+ } else {
459
+ setHiddenOptional(true);
460
+ }
461
+ }
462
+ }
463
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(InputContainer, { withShadow, children: [
464
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(InputUI, __spreadValues({ ref, onChange: handleOnChange }, props)),
465
+ !hiddenOptional && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Sufix, { style: { marginLeft: `-${requiredText.length / 2}rem` }, children: requiredText })
466
+ ] });
467
+ }
468
+ );
469
+ TextInput.displayName = "Input";
267
470
  // Annotate the CommonJS export names for ESM import in node:
268
471
  0 && (module.exports = {
472
+ Box,
269
473
  Button,
474
+ Heading,
270
475
  Text,
476
+ TextInput,
271
477
  config,
272
478
  createTheme,
273
479
  css,
package/dist/index.mjs CHANGED
@@ -17,6 +17,18 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
20
32
 
21
33
  // ../tokens/dist/index.mjs
22
34
  var colors = {
@@ -117,8 +129,42 @@ var {
117
129
  }
118
130
  });
119
131
 
120
- // src/components/Button.tsx
121
- var Button = styled("button", {
132
+ // src/components/Box/styles.ts
133
+ var BoxUI = styled("div", {
134
+ padding: "$4",
135
+ variants: {
136
+ stretch: {
137
+ true: {
138
+ width: "100%"
139
+ },
140
+ false: {
141
+ width: "18.4375rem"
142
+ }
143
+ },
144
+ dark: {
145
+ true: {
146
+ background: "$gray800"
147
+ },
148
+ false: {
149
+ background: "transparent"
150
+ }
151
+ }
152
+ },
153
+ defaultVariants: {
154
+ stretch: false,
155
+ dark: false
156
+ }
157
+ });
158
+
159
+ // src/components/Box/index.tsx
160
+ import { jsx } from "react/jsx-runtime";
161
+ function Box(_a) {
162
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
163
+ return /* @__PURE__ */ jsx(BoxUI, __spreadProps(__spreadValues({}, props), { children }));
164
+ }
165
+
166
+ // src/components/Button/styles.ts
167
+ var ButtonUI = styled("button", {
122
168
  all: "unset",
123
169
  borderRadius: "$md",
124
170
  fontSize: "$md",
@@ -136,10 +182,6 @@ var Button = styled("button", {
136
182
  "&:disabled": {
137
183
  cursor: "not-allowed"
138
184
  },
139
- svg: {
140
- width: "$4",
141
- height: "$4"
142
- },
143
185
  variants: {
144
186
  variant: {
145
187
  primary: {
@@ -211,8 +253,24 @@ var Button = styled("button", {
211
253
  }
212
254
  });
213
255
 
214
- // src/components/Text.tsx
215
- var Text = styled("p", {
256
+ // src/components/Button/index.tsx
257
+ import { jsx as jsx2 } from "react/jsx-runtime";
258
+ function Button(_a) {
259
+ var _b = _a, {
260
+ children,
261
+ variant = "primary",
262
+ size = "md"
263
+ } = _b, props = __objRest(_b, [
264
+ "children",
265
+ "variant",
266
+ "size"
267
+ ]);
268
+ return /* @__PURE__ */ jsx2(ButtonUI, __spreadProps(__spreadValues({ variant, size }, props), { children }));
269
+ }
270
+ ButtonUI.displayName = "Button";
271
+
272
+ // src/components/Text/styles.ts
273
+ var TextUI = styled("p", {
216
274
  fontFamily: "$web",
217
275
  lineHeight: "$base",
218
276
  margin: 0,
@@ -232,9 +290,157 @@ var Text = styled("p", {
232
290
  size: "md"
233
291
  }
234
292
  });
293
+
294
+ // src/components/Text/index.tsx
295
+ import { jsx as jsx3 } from "react/jsx-runtime";
296
+ function Text(_a) {
297
+ var _b = _a, {
298
+ children,
299
+ size = "md"
300
+ } = _b, props = __objRest(_b, [
301
+ "children",
302
+ "size"
303
+ ]);
304
+ return /* @__PURE__ */ jsx3(TextUI, __spreadProps(__spreadValues({ size }, props), { children }));
305
+ }
306
+ Text.displayName = "Text";
307
+
308
+ // src/components/Heading/styles.ts
309
+ var HeadingUI = styled("h2", {
310
+ fontFamily: "$web",
311
+ lineHeight: "$shorter",
312
+ margin: 0,
313
+ variants: {
314
+ mode: {
315
+ default: {
316
+ color: "$dafaz400"
317
+ },
318
+ white: {
319
+ color: "$white"
320
+ }
321
+ },
322
+ size: {
323
+ sm: { fontSize: "$lg" },
324
+ md: { fontSize: "$xl" },
325
+ lg: { fontSize: "$2xl" },
326
+ xl: { fontSize: "3rem" },
327
+ "2xl": { fontSize: "4rem" }
328
+ }
329
+ },
330
+ defaultVariants: {
331
+ mode: "default",
332
+ size: "lg"
333
+ }
334
+ });
335
+
336
+ // src/components/Heading/index.tsx
337
+ import { jsx as jsx4 } from "react/jsx-runtime";
338
+ function Heading(_a) {
339
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
340
+ return /* @__PURE__ */ jsx4(HeadingUI, __spreadProps(__spreadValues({}, props), { children }));
341
+ }
342
+ Heading.displayName = "Heading";
343
+
344
+ // src/components/TextInput/index.tsx
345
+ import {
346
+ forwardRef,
347
+ useState
348
+ } from "react";
349
+
350
+ // src/components/TextInput/styles.ts
351
+ var InputContainer = styled("div", {
352
+ margin: 0,
353
+ backgroundColor: "transparent",
354
+ borderBottom: "2px solid $dafaz600",
355
+ borderRadius: "$md",
356
+ boxSizing: "border-box",
357
+ display: "flex",
358
+ alignItems: "baseline",
359
+ padding: "$1 $2",
360
+ transition: "border 0.2s linear",
361
+ "&:has(input:focus)": {
362
+ borderBottom: "2px solid $dafaz400"
363
+ },
364
+ "&:has(input:disabled)": {
365
+ opacity: 0.5,
366
+ cursor: "not-allowed"
367
+ },
368
+ variants: {
369
+ withShadow: {
370
+ true: {
371
+ boxShadow: "inset 0 3rem #444"
372
+ }
373
+ }
374
+ },
375
+ defaultVariants: {
376
+ withShadow: false
377
+ }
378
+ });
379
+ var InputUI = styled("input", {
380
+ margin: 0,
381
+ fontFamily: "$app",
382
+ fontSize: "$xl",
383
+ color: "$white",
384
+ backgroundColor: "transparent",
385
+ border: "none",
386
+ "&::-ms-reveal": {
387
+ filter: "invert(100%)"
388
+ },
389
+ "&::placeholder": {
390
+ fontWeight: "$regular",
391
+ color: "$white",
392
+ opacity: 0.75
393
+ },
394
+ "&:focus": {
395
+ outline: 0
396
+ }
397
+ });
398
+ var Sufix = styled("span", {
399
+ fontFamily: "$app",
400
+ fontSize: "$sm",
401
+ color: "$white",
402
+ fontStyle: "italic",
403
+ "&:has(input:focus)": {
404
+ visibility: "hidden"
405
+ }
406
+ });
407
+
408
+ // src/components/TextInput/index.tsx
409
+ import { jsx as jsx5, jsxs } from "react/jsx-runtime";
410
+ var TextInput = forwardRef(
411
+ (_a, ref) => {
412
+ var _b = _a, {
413
+ withShadow = false,
414
+ required = true,
415
+ requiredText = "Opcional"
416
+ } = _b, props = __objRest(_b, [
417
+ "withShadow",
418
+ "required",
419
+ "requiredText"
420
+ ]);
421
+ const [hiddenOptional, setHiddenOptional] = useState(required);
422
+ function handleOnChange(event) {
423
+ if (!required) {
424
+ if (event.target.value === "") {
425
+ setHiddenOptional(false);
426
+ } else {
427
+ setHiddenOptional(true);
428
+ }
429
+ }
430
+ }
431
+ return /* @__PURE__ */ jsxs(InputContainer, { withShadow, children: [
432
+ /* @__PURE__ */ jsx5(InputUI, __spreadValues({ ref, onChange: handleOnChange }, props)),
433
+ !hiddenOptional && /* @__PURE__ */ jsx5(Sufix, { style: { marginLeft: `-${requiredText.length / 2}rem` }, children: requiredText })
434
+ ] });
435
+ }
436
+ );
437
+ TextInput.displayName = "Input";
235
438
  export {
439
+ Box,
236
440
  Button,
441
+ Heading,
237
442
  Text,
443
+ TextInput,
238
444
  config,
239
445
  createTheme,
240
446
  css,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dafaz-ui/react",
3
- "version": "2.1.0",
3
+ "version": "2.2.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react'
2
+ import { BoxUI, BoxUIProps } from './styles'
3
+
4
+ interface BoxProps {
5
+ children: ReactNode
6
+ }
7
+
8
+ export function Box({ children, ...props }: BoxUIProps & BoxProps) {
9
+ return <BoxUI {...props}>{children}</BoxUI>
10
+ }
@@ -0,0 +1,35 @@
1
+ import { styled } from '../../styles'
2
+ import type { ComponentProps, ElementType } from 'react'
3
+
4
+ export const BoxUI = styled('div', {
5
+ padding: '$4',
6
+
7
+ variants: {
8
+ stretch: {
9
+ true: {
10
+ width: '100%',
11
+ },
12
+ false: {
13
+ width: '18.4375rem',
14
+ },
15
+ },
16
+ dark: {
17
+ true: {
18
+ background: '$gray800',
19
+ },
20
+ false: {
21
+ background: 'transparent',
22
+ },
23
+ },
24
+ },
25
+ defaultVariants: {
26
+ stretch: false,
27
+ dark: false,
28
+ },
29
+ })
30
+
31
+ export interface BoxUIProps extends ComponentProps<typeof BoxUI> {
32
+ as?: ElementType
33
+ stretch?: boolean
34
+ dark?: boolean
35
+ }
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from 'react'
2
+ import { ButtonUI, ButtonUIProps } from './styles'
3
+
4
+ interface ButtonProps {
5
+ children: ReactNode
6
+ }
7
+
8
+ export function Button({
9
+ children,
10
+ variant = 'primary',
11
+ size = 'md',
12
+ ...props
13
+ }: ButtonUIProps & ButtonProps) {
14
+ return (
15
+ <ButtonUI variant={variant} size={size} {...props}>
16
+ {children}
17
+ </ButtonUI>
18
+ )
19
+ }
20
+
21
+ ButtonUI.displayName = 'Button'
@@ -1,9 +1,8 @@
1
- import type { ComponentProps } from '@stitches/react'
2
- import { styled } from '../styles'
3
- import type { ElementType } from 'react'
1
+ import type { ComponentProps, ElementType } from 'react'
2
+ import { styled } from '../../styles'
4
3
 
5
4
  /** Primary UI component for user interaction */
6
- export const Button = styled('button', {
5
+ export const ButtonUI = styled('button', {
7
6
  all: 'unset',
8
7
  borderRadius: '$md',
9
8
  fontSize: '$md',
@@ -25,11 +24,6 @@ export const Button = styled('button', {
25
24
  cursor: 'not-allowed',
26
25
  },
27
26
 
28
- svg: {
29
- width: '$4',
30
- height: '$4',
31
- },
32
-
33
27
  variants: {
34
28
  variant: {
35
29
  primary: {
@@ -108,14 +102,12 @@ export const Button = styled('button', {
108
102
  },
109
103
  })
110
104
 
111
- export interface ButtonProps extends ComponentProps<typeof Button> {
105
+ export interface ButtonUIProps extends ComponentProps<typeof ButtonUI> {
112
106
  as?: ElementType
113
107
  /** How large should the button be? */
114
108
  size?: 'sm' | 'md' | 'lg'
115
109
  /** Optional click handler */
116
110
  onClick?: () => void
117
- /** Button contents */
118
- label: string
119
111
  /** Button is disable? */
120
112
  disabled?: boolean
121
113
  //** Button UI mode */
@@ -0,0 +1,12 @@
1
+ import type { ReactNode } from 'react'
2
+ import { HeadingUI, HeadingUIProps } from './styles'
3
+
4
+ interface HeadingProps {
5
+ children: ReactNode
6
+ }
7
+
8
+ export function Heading({ children, ...props }: HeadingUIProps & HeadingProps) {
9
+ return <HeadingUI {...props}>{children}</HeadingUI>
10
+ }
11
+
12
+ Heading.displayName = 'Heading'
@@ -0,0 +1,36 @@
1
+ import { ComponentProps, ElementType } from 'react'
2
+ import { styled } from '../../styles'
3
+
4
+ export const HeadingUI = styled('h2', {
5
+ fontFamily: '$web',
6
+ lineHeight: '$shorter',
7
+ margin: 0,
8
+
9
+ variants: {
10
+ mode: {
11
+ default: {
12
+ color: '$dafaz400',
13
+ },
14
+ white: {
15
+ color: '$white',
16
+ },
17
+ },
18
+ size: {
19
+ sm: { fontSize: '$lg' },
20
+ md: { fontSize: '$xl' },
21
+ lg: { fontSize: '$2xl' },
22
+ xl: { fontSize: '3rem' },
23
+ '2xl': { fontSize: '4rem' },
24
+ },
25
+ },
26
+ defaultVariants: {
27
+ mode: 'default',
28
+ size: 'lg',
29
+ },
30
+ })
31
+
32
+ export interface HeadingUIProps extends ComponentProps<typeof HeadingUI> {
33
+ as?: ElementType
34
+ size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl'
35
+ mode?: 'default' | 'white'
36
+ }