@consumidor-positivo/aurora 1.2.0 → 1.3.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.
Files changed (96) hide show
  1. package/README.md +59 -3
  2. package/astro/AdBox/index.astro +28 -0
  3. package/astro/Alert/index.astro +257 -0
  4. package/astro/BadgeInfo/index.astro +55 -0
  5. package/astro/BadgeState/index.astro +79 -0
  6. package/astro/Button/index.astro +11 -3
  7. package/astro/Card/Container/index.astro +44 -0
  8. package/astro/Card/Emphasis/index.astro +39 -0
  9. package/astro/Card/Image/index.astro +26 -0
  10. package/astro/Card/Root/index.astro +53 -0
  11. package/astro/Card/Tag/index.astro +26 -0
  12. package/astro/Chip/index.astro +48 -0
  13. package/astro/ChipBanner/index.astro +160 -0
  14. package/astro/Container/index.astro +16 -0
  15. package/astro/Divider/index.astro +27 -0
  16. package/astro/Image/index.astro +26 -0
  17. package/astro/LazyImage/index.astro +55 -0
  18. package/astro/LinkButton/index.astro +54 -0
  19. package/astro/Logo/ac/BadgeFullWhite.astro +20 -0
  20. package/astro/Logo/ac/BadgeWhite.astro +23 -0
  21. package/astro/Logo/ac/BadgeWhiteStroke.astro +27 -0
  22. package/astro/Logo/ac/BadgeWhiteStrokeDefault.astro +28 -0
  23. package/astro/Logo/ac/Badget.astro +24 -0
  24. package/astro/Logo/ac/Primary.astro +28 -0
  25. package/astro/Logo/ac/PrimaryFillWhite.astro +28 -0
  26. package/astro/Logo/ac/PrimaryFullWhite.astro +20 -0
  27. package/astro/Logo/ac/PrimaryNegative.astro +20 -0
  28. package/astro/Logo/ac/PrimaryWhite.astro +20 -0
  29. package/astro/Logo/ac/TertiaryWhite.astro +72 -0
  30. package/astro/Logo/cp/BadgeWhiteStroke.astro +10 -0
  31. package/astro/Logo/cp/Badget.astro +14 -0
  32. package/astro/Logo/cp/PrimaryFillWhite.astro +63 -0
  33. package/astro/Logo/cp/PrimaryFullWhite.astro +27 -0
  34. package/astro/Logo/cp/PrimaryLogoWhite.astro +67 -0
  35. package/astro/Logo/cp/PrimaryNegative.astro +27 -0
  36. package/astro/Logo/cp/PrimaryWhite.astro +27 -0
  37. package/astro/Modal/index.astro +213 -0
  38. package/astro/NotificationsBar/Link/index.astro +70 -0
  39. package/astro/NotificationsBar/List/index.astro +38 -0
  40. package/astro/NotificationsBar/index.astro +24 -0
  41. package/astro/PartnerBanner/index.astro +52 -0
  42. package/astro/ProfileNav/index.astro +34 -0
  43. package/astro/ProgressBar/index.astro +70 -0
  44. package/astro/Skeleton/index.astro +50 -0
  45. package/astro/SpecialButton/index.astro +331 -0
  46. package/astro/Spinner/index.astro +75 -0
  47. package/astro/SubHeader/index.astro +57 -0
  48. package/astro/Switch/Card/index.astro +69 -0
  49. package/astro/Switch/Pure/index.astro +47 -0
  50. package/astro/Tooltip/index.astro +38 -0
  51. package/astro/form/Checkbox/Field/index.astro +68 -0
  52. package/astro/form/Checkbox/Group/index.astro +79 -0
  53. package/astro/form/Datepicker/Calendar/index.astro +53 -0
  54. package/astro/form/Datepicker/CalendarHeader/index.astro +57 -0
  55. package/astro/form/Datepicker/Segment/index.astro +53 -0
  56. package/astro/form/Datepicker/index.astro +756 -0
  57. package/astro/form/EmailField/index.astro +237 -0
  58. package/astro/form/Field/ErrorMessage/index.astro +20 -0
  59. package/astro/form/Field/Input/index.astro +15 -0
  60. package/astro/form/Field/InputHolder/index.astro +28 -0
  61. package/astro/form/Field/Label/index.astro +80 -0
  62. package/astro/form/Field/Message/index.astro +29 -0
  63. package/astro/form/Field/Root/index.astro +37 -0
  64. package/astro/form/Field/TextArea/index.astro +69 -0
  65. package/astro/form/InputField/index.astro +96 -0
  66. package/astro/form/PasswordField/index.astro +123 -0
  67. package/astro/form/Radio/Field/index.astro +52 -0
  68. package/astro/form/Radio/Group/index.astro +78 -0
  69. package/astro/form/SelectField/index.astro +561 -0
  70. package/astro/form/TextareaField/index.astro +81 -0
  71. package/astro/form/TokenField/index.astro +211 -0
  72. package/astro/tokens/package.json +6 -0
  73. package/dist/{tokens-C4ypB4bY.js → astro/tokens/index.es.js} +101 -101
  74. package/dist/astro/tokens/index.es.js.map +1 -0
  75. package/dist/components/Alert/index.es.js +1 -1
  76. package/dist/components/BadgeInfo/index.es.js +1 -1
  77. package/dist/components/BadgeState/index.es.js +1 -1
  78. package/dist/components/Image/index.es.js +1 -1
  79. package/dist/components/Spinner/index.es.js +1 -1
  80. package/dist/components/form/Checkbox/Field/index.es.js +1 -1
  81. package/dist/components/form/Datepicker/Calendar/index.es.js +2 -2
  82. package/dist/components/form/Datepicker/CalendarHeader/index.es.js +2 -2
  83. package/dist/components/form/Datepicker/PortalHolder/index.es.js +1 -1
  84. package/dist/components/form/Datepicker/Segment/index.es.js +1 -1
  85. package/dist/components/form/Datepicker/index.es.js +3 -3
  86. package/dist/components/form/Field/Label/index.es.js +1 -1
  87. package/dist/components/form/SelectField/index.es.js +1 -1
  88. package/dist/{index-BcC9liUl.js → index-Bkl5OBIY.js} +3 -3
  89. package/dist/{index-BcC9liUl.js.map → index-Bkl5OBIY.js.map} +1 -1
  90. package/dist/{index-CFYmtkje.js → index-CZfMkAoF.js} +2 -2
  91. package/dist/{index-CFYmtkje.js.map → index-CZfMkAoF.js.map} +1 -1
  92. package/dist/{index-CeClo_WS.js → index-Cw1KtRQr.js} +2 -2
  93. package/dist/{index-CeClo_WS.js.map → index-Cw1KtRQr.js.map} +1 -1
  94. package/dist/main.es.js +101 -101
  95. package/package.json +7 -1
  96. package/dist/tokens-C4ypB4bY.js.map +0 -1
@@ -0,0 +1,123 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types'
3
+ import FieldRoot from '../Field/Root/index.astro'
4
+ import FieldLabel from '../Field/Label/index.astro'
5
+ import FieldInput from '../Field/Input/index.astro'
6
+ import FieldErrorMessage from '../Field/ErrorMessage/index.astro'
7
+ import '../../../dist/components/PasswordField/styles.css'
8
+
9
+ /**
10
+ * Same props as the React `PasswordField`, and the same split: `class` and
11
+ * `style` go on the `au-field` root, every other HTML attribute (`name`,
12
+ * `autocomplete`, `required`, `data-*`...) lands on the `<input>`.
13
+ *
14
+ * The show/hide toggle is the component's own behavior, kept by an inline
15
+ * controller: it flips the input between `password` and `text`, the button
16
+ * text between "mostrar" and "ocultar", `aria-pressed` and `aria-label`, and
17
+ * emits `au:passwordtoggle` (`detail.visible`) from the root. `inputRef` and
18
+ * the `on*` callbacks have no counterpart. Like the React version, the input
19
+ * only gets an `id` when one is passed, and an explicit `type` wins over the
20
+ * toggle (React spreads it after the computed type), so the input then stays
21
+ * `password` while the button still flips.
22
+ */
23
+ export type Props = Omit<HTMLAttributes<'input'>, 'type' | 'disabled'> & {
24
+ type?: 'password'
25
+ showOptionalLabel?: boolean
26
+ /** Marks the label as required. Pass `required` too for native validation. */
27
+ requiredInput?: boolean
28
+ success?: boolean
29
+ error?: boolean
30
+ errorMessage?: string
31
+ label?: string
32
+ disabled?: boolean
33
+ /** Opens the numeric keypad on mobile (`inputmode="numeric"`). */
34
+ numericKeypad?: boolean
35
+ }
36
+
37
+ const uid = crypto.randomUUID().slice(0, 8)
38
+
39
+ const {
40
+ showOptionalLabel,
41
+ requiredInput,
42
+ success = false,
43
+ error = false,
44
+ errorMessage,
45
+ label,
46
+ id: idProp,
47
+ disabled = false,
48
+ style,
49
+ class: className,
50
+ numericKeypad = false,
51
+ ...rest
52
+ } = Astro.props
53
+
54
+ const id = idProp
55
+
56
+ // Stands in for the React `useId()` of the error message.
57
+ const errorId = error && errorMessage ? `au-password-${uid}-error` : undefined
58
+ // React spreads `type` after the computed one, so a passed `type` is fixed.
59
+ const fixedType = rest.type !== undefined
60
+ ---
61
+
62
+ <FieldRoot
63
+ style={style}
64
+ class={className}
65
+ success={success}
66
+ error={error}
67
+ disabled={disabled}
68
+ data-element="au-password-field"
69
+ data-au-password-fixed-type={fixedType ? '' : undefined}>
70
+ <FieldLabel
71
+ text={label}
72
+ id={id}
73
+ required={requiredInput}
74
+ showOptionalLabel={showOptionalLabel}
75
+ success={success}
76
+ error={error}
77
+ disabled={disabled}
78
+ />
79
+ <div class="au-password-field__container">
80
+ <FieldInput
81
+ class="au-password-field__input"
82
+ type="password"
83
+ id={id}
84
+ inputmode={numericKeypad ? 'numeric' : undefined}
85
+ disabled={disabled}
86
+ aria-invalid={error ? 'true' : 'false'}
87
+ aria-describedby={errorId}
88
+ {...rest}
89
+ />
90
+ <button
91
+ class="au-password-field__btn"
92
+ type="button"
93
+ disabled={disabled}
94
+ aria-label="Mostrar senha"
95
+ aria-pressed="false">
96
+ mostrar
97
+ </button>
98
+ </div>
99
+ <FieldErrorMessage hasError={error} message={errorMessage} id={errorId} />
100
+ </FieldRoot>
101
+
102
+ <script>
103
+ import { elementController } from '@consumidor-positivo/aurora/astro/runtime'
104
+
105
+ elementController('au-password-field', ({ root, query, on, emit }) => {
106
+ const input = query<HTMLInputElement>('.au-password-field__input')
107
+ const button = query<HTMLButtonElement>('.au-password-field__btn')
108
+ if (!input || !button) return
109
+
110
+ on('click', (event) => {
111
+ if (!(event.target as Element | null)?.closest('.au-password-field__btn')) return
112
+
113
+ const visible = button.getAttribute('aria-pressed') !== 'true'
114
+ if (!root.hasAttribute('data-au-password-fixed-type')) {
115
+ input.type = visible ? 'text' : 'password'
116
+ }
117
+ button.textContent = visible ? 'ocultar' : 'mostrar'
118
+ button.setAttribute('aria-label', visible ? 'Ocultar senha' : 'Mostrar senha')
119
+ button.setAttribute('aria-pressed', String(visible))
120
+ emit('au:passwordtoggle', { visible })
121
+ })
122
+ })
123
+ </script>
@@ -0,0 +1,52 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types'
3
+ import '../../../../dist/components/Field/styles3.css'
4
+
5
+ /**
6
+ * Same as React: every attribute except `class` goes to the native
7
+ * `<input type="radio">` (`name`, `value`, `checked`, `required`, `data-*`…),
8
+ * so listen to its native `change` event instead of `onChange`. Like React's
9
+ * `className`, `class` lands on the input and replaces `au-radio-field__input`
10
+ * (`style` also goes to the input).
11
+ */
12
+ export type Props = Omit<HTMLAttributes<'input'>, 'type'> & {
13
+ direction?: 'left' | 'right'
14
+ label?: string
15
+ error?: boolean
16
+ type?: 'radio'
17
+ }
18
+
19
+ const {
20
+ type = 'radio',
21
+ direction = 'left',
22
+ label,
23
+ error = false,
24
+ id,
25
+ disabled = false,
26
+ class: className,
27
+ ...rest
28
+ } = Astro.props
29
+
30
+ // The React version falls back to `Math.random()`; here it is fixed at render.
31
+ const safeId = id ?? `au-radio-${crypto.randomUUID().slice(0, 8)}`
32
+ ---
33
+
34
+ <div
35
+ class:list={[
36
+ 'au-radio-field',
37
+ direction === 'left' && 'au-radio-field--left-direction',
38
+ direction === 'right' && 'au-radio-field--right-direction',
39
+ disabled && 'au-radio-field--disabled',
40
+ error && 'au-radio-field--error',
41
+ ]}>
42
+ <input
43
+ class={className ?? 'au-radio-field__input'}
44
+ type={type}
45
+ id={safeId}
46
+ disabled={disabled}
47
+ {...rest}
48
+ />
49
+ <label class="au-radio-field__label" for={safeId}>
50
+ {label}
51
+ </label>
52
+ </div>
@@ -0,0 +1,78 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types'
3
+ import Text from '../../../Text/index.astro'
4
+ import RadioField from '../Field/index.astro'
5
+ import type { Props as RadioFieldProps } from '../Field/index.astro'
6
+ import FieldErrorMessage from '../../Field/ErrorMessage/index.astro'
7
+ import '../../../../dist/components/Group/styles.css'
8
+
9
+ /**
10
+ * React clones its children to inject `name`, `error`, `defaultChecked`,
11
+ * `onChange` and `onFocus`. Astro cannot touch slotted children, so:
12
+ * - pass the fields as `options` and the group renders each `Radio/Field`
13
+ * with the group's `name` and `error`, checked when its `value` matches
14
+ * `defaultValue` (an option's own props win, like React; also like React,
15
+ * an option without `value` is checked when there is no `defaultValue`,
16
+ * since `undefined === undefined`);
17
+ * - or put your own `Radio/Field`s in the default slot, rendered after the
18
+ * `options`; those must carry `name` (and `error`) themselves.
19
+ * No `onChange`/`onFocus`: the native `change`/`focusin` events bubble to the
20
+ * root.
21
+ */
22
+ export type Props = HTMLAttributes<'div'> & {
23
+ options?: RadioFieldProps[]
24
+ name?: string
25
+ defaultValue?: string | number
26
+ orientation?: 'horizontal' | 'vertical'
27
+ label?: string
28
+ error?: boolean
29
+ errorMessage?: string
30
+ required?: boolean
31
+ }
32
+
33
+ const {
34
+ options = [],
35
+ name,
36
+ defaultValue,
37
+ orientation = 'vertical',
38
+ label,
39
+ error = false,
40
+ errorMessage,
41
+ required = false,
42
+ class: className,
43
+ ...rest
44
+ } = Astro.props
45
+
46
+ const safeName = name || `au-radio-group-${crypto.randomUUID().slice(0, 8)}`
47
+ ---
48
+
49
+ <div
50
+ class:list={[
51
+ 'au-radio-group',
52
+ orientation === 'horizontal' && 'au-radio-group--horizontal',
53
+ className,
54
+ ]}
55
+ {...rest}>
56
+ {
57
+ label && (
58
+ <Text variant="body-small" weight="semibold" color="secondary">
59
+ {label}{' '}
60
+ {required && <span class="au-radio-group__label--required">*</span>}
61
+ </Text>
62
+ )
63
+ }
64
+ <div class="au-radio-group__fields">
65
+ {
66
+ options.map((option) => (
67
+ <RadioField
68
+ name={safeName}
69
+ error={error}
70
+ checked={defaultValue === option.value}
71
+ {...option}
72
+ />
73
+ ))
74
+ }
75
+ <slot />
76
+ </div>
77
+ <FieldErrorMessage hasError={error} message={errorMessage} />
78
+ </div>