@dafaz-ui/react 2.0.1 → 2.2.0

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,7 +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,
55
+ Text: () => Text,
56
+ TextInput: () => TextInput,
41
57
  config: () => config,
42
58
  createTheme: () => createTheme,
43
59
  css: () => css,
@@ -61,8 +77,7 @@ var colors = {
61
77
  dafaz200: "#52D058",
62
78
  dafaz400: "#2FC136",
63
79
  dafaz600: "#229E45",
64
- dafaz800: "#2A6A2D",
65
- teste: "#FFF"
80
+ dafaz800: "#2A6A2D"
66
81
  };
67
82
  var opacities = {
68
83
  opacity400: "0.4",
@@ -104,8 +119,8 @@ var fontSizes = {
104
119
  xxs: "0.5rem",
105
120
  xs: "0.625rem",
106
121
  sm: "0.75rem",
107
- md: "0.875",
108
- lg: "1rem",
122
+ md: "0.875rem",
123
+ lg: "1.0rem",
109
124
  xl: "1.25rem",
110
125
  "2xl": "2rem"
111
126
  };
@@ -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: {
@@ -211,21 +256,224 @@ var Button = styled("button", {
211
256
  },
212
257
  size: {
213
258
  sm: {
214
- height: 38
259
+ height: 38,
260
+ fontSize: "$sm"
215
261
  },
216
262
  md: {
217
- height: 46
263
+ height: 46,
264
+ fontSize: "$lg"
265
+ },
266
+ lg: {
267
+ height: 54,
268
+ fontSize: "$xl"
218
269
  }
270
+ },
271
+ flat: {
272
+ true: {
273
+ border: 0,
274
+ background: "transparent",
275
+ "&:disabled": {
276
+ color: "$gray200",
277
+ background: "transparent",
278
+ border: "none"
279
+ }
280
+ },
281
+ false: {}
219
282
  }
220
283
  },
221
284
  defaultVariants: {
222
285
  variant: "primary",
286
+ size: "md",
287
+ flat: false
288
+ }
289
+ });
290
+
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", {
309
+ fontFamily: "$web",
310
+ lineHeight: "$base",
311
+ margin: 0,
312
+ color: "$white",
313
+ variants: {
314
+ size: {
315
+ xxs: { fontSize: "$xxs" },
316
+ xs: { fontSize: "$xs" },
317
+ sm: { fontSize: "$sm" },
318
+ md: { fontSize: "$md" },
319
+ lg: { fontSize: "$lg" },
320
+ xl: { fontSize: "$xl" },
321
+ "2xl": { fontSize: "$2xl" }
322
+ }
323
+ },
324
+ defaultVariants: {
223
325
  size: "md"
224
326
  }
225
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 2.5rem #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";
226
470
  // Annotate the CommonJS export names for ESM import in node:
227
471
  0 && (module.exports = {
472
+ Box,
228
473
  Button,
474
+ Heading,
475
+ Text,
476
+ TextInput,
229
477
  config,
230
478
  createTheme,
231
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 = {
@@ -30,8 +42,7 @@ var colors = {
30
42
  dafaz200: "#52D058",
31
43
  dafaz400: "#2FC136",
32
44
  dafaz600: "#229E45",
33
- dafaz800: "#2A6A2D",
34
- teste: "#FFF"
45
+ dafaz800: "#2A6A2D"
35
46
  };
36
47
  var opacities = {
37
48
  opacity400: "0.4",
@@ -73,8 +84,8 @@ var fontSizes = {
73
84
  xxs: "0.5rem",
74
85
  xs: "0.625rem",
75
86
  sm: "0.75rem",
76
- md: "0.875",
77
- lg: "1rem",
87
+ md: "0.875rem",
88
+ lg: "1.0rem",
78
89
  xl: "1.25rem",
79
90
  "2xl": "2rem"
80
91
  };
@@ -118,8 +129,42 @@ var {
118
129
  }
119
130
  });
120
131
 
121
- // src/components/Button.tsx
122
- 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", {
123
168
  all: "unset",
124
169
  borderRadius: "$md",
125
170
  fontSize: "$md",
@@ -137,10 +182,6 @@ var Button = styled("button", {
137
182
  "&:disabled": {
138
183
  cursor: "not-allowed"
139
184
  },
140
- svg: {
141
- width: "$4",
142
- height: "$4"
143
- },
144
185
  variants: {
145
186
  variant: {
146
187
  primary: {
@@ -180,20 +221,226 @@ var Button = styled("button", {
180
221
  },
181
222
  size: {
182
223
  sm: {
183
- height: 38
224
+ height: 38,
225
+ fontSize: "$sm"
184
226
  },
185
227
  md: {
186
- height: 46
228
+ height: 46,
229
+ fontSize: "$lg"
230
+ },
231
+ lg: {
232
+ height: 54,
233
+ fontSize: "$xl"
187
234
  }
235
+ },
236
+ flat: {
237
+ true: {
238
+ border: 0,
239
+ background: "transparent",
240
+ "&:disabled": {
241
+ color: "$gray200",
242
+ background: "transparent",
243
+ border: "none"
244
+ }
245
+ },
246
+ false: {}
188
247
  }
189
248
  },
190
249
  defaultVariants: {
191
250
  variant: "primary",
251
+ size: "md",
252
+ flat: false
253
+ }
254
+ });
255
+
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", {
274
+ fontFamily: "$web",
275
+ lineHeight: "$base",
276
+ margin: 0,
277
+ color: "$white",
278
+ variants: {
279
+ size: {
280
+ xxs: { fontSize: "$xxs" },
281
+ xs: { fontSize: "$xs" },
282
+ sm: { fontSize: "$sm" },
283
+ md: { fontSize: "$md" },
284
+ lg: { fontSize: "$lg" },
285
+ xl: { fontSize: "$xl" },
286
+ "2xl": { fontSize: "$2xl" }
287
+ }
288
+ },
289
+ defaultVariants: {
192
290
  size: "md"
193
291
  }
194
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 2.5rem #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";
195
438
  export {
439
+ Box,
196
440
  Button,
441
+ Heading,
442
+ Text,
443
+ TextInput,
197
444
  config,
198
445
  createTheme,
199
446
  css,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dafaz-ui/react",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
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
+ }