bonsaif-ui 0.1.19 → 0.1.24

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 (143) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +206 -16
  3. package/dist/bonsaif-ui.js +3827 -2855
  4. package/dist/bonsaif-ui.umd.cjs +1 -1
  5. package/dist/components/BonsaifButton/BonsaifButton.stories.d.ts +22 -0
  6. package/dist/components/BonsaifButton/BonsaifButton.stories.d.ts.map +1 -0
  7. package/dist/components/composition/DynamicDetailTabs.stories.d.ts +11 -0
  8. package/dist/components/composition/DynamicDetailTabs.stories.d.ts.map +1 -0
  9. package/dist/components/layout/AuthShell.stories.d.ts +12 -0
  10. package/dist/components/layout/AuthShell.stories.d.ts.map +1 -0
  11. package/dist/components/layout/GlobalScrollbars.stories.d.ts +9 -0
  12. package/dist/components/layout/GlobalScrollbars.stories.d.ts.map +1 -0
  13. package/dist/components/layout/LayoutShells.stories.d.ts +16 -0
  14. package/dist/components/layout/LayoutShells.stories.d.ts.map +1 -0
  15. package/dist/components/layout/PageHeader.stories.d.ts +12 -0
  16. package/dist/components/layout/PageHeader.stories.d.ts.map +1 -0
  17. package/dist/components/layout/PageSearchInput.stories.d.ts +9 -0
  18. package/dist/components/layout/PageSearchInput.stories.d.ts.map +1 -0
  19. package/dist/components/layout/PrimeAuthRouteShell.stories.d.ts +12 -0
  20. package/dist/components/layout/PrimeAuthRouteShell.stories.d.ts.map +1 -0
  21. package/dist/components/messaging/PrimeSuiteChatFrame.stories.d.ts +14 -0
  22. package/dist/components/messaging/PrimeSuiteChatFrame.stories.d.ts.map +1 -0
  23. package/dist/components/microservices/MicroserviceFrame.stories.d.ts +14 -0
  24. package/dist/components/microservices/MicroserviceFrame.stories.d.ts.map +1 -0
  25. package/dist/components/notifications/PrimeAuthToaster.stories.d.ts +11 -0
  26. package/dist/components/notifications/PrimeAuthToaster.stories.d.ts.map +1 -0
  27. package/dist/components/ui/ActionUtilities.stories.d.ts +13 -0
  28. package/dist/components/ui/ActionUtilities.stories.d.ts.map +1 -0
  29. package/dist/components/ui/Alert.stories.d.ts +23 -0
  30. package/dist/components/ui/Alert.stories.d.ts.map +1 -0
  31. package/dist/components/ui/Button.stories.d.ts +36 -0
  32. package/dist/components/ui/Button.stories.d.ts.map +1 -0
  33. package/dist/components/ui/CalendarPicker.stories.d.ts +9 -0
  34. package/dist/components/ui/CalendarPicker.stories.d.ts.map +1 -0
  35. package/dist/components/ui/Checkbox.stories.d.ts +11 -0
  36. package/dist/components/ui/Checkbox.stories.d.ts.map +1 -0
  37. package/dist/components/ui/CodeBlock.stories.d.ts +11 -0
  38. package/dist/components/ui/CodeBlock.stories.d.ts.map +1 -0
  39. package/dist/components/ui/CompactFilterSelect.stories.d.ts +11 -0
  40. package/dist/components/ui/CompactFilterSelect.stories.d.ts.map +1 -0
  41. package/dist/components/ui/CompactSearchInput.stories.d.ts +11 -0
  42. package/dist/components/ui/CompactSearchInput.stories.d.ts.map +1 -0
  43. package/dist/components/ui/ConfirmDialog.stories.d.ts +9 -0
  44. package/dist/components/ui/ConfirmDialog.stories.d.ts.map +1 -0
  45. package/dist/components/ui/CopyButton.stories.d.ts +11 -0
  46. package/dist/components/ui/CopyButton.stories.d.ts.map +1 -0
  47. package/dist/components/ui/CopyLinkButton.stories.d.ts +11 -0
  48. package/dist/components/ui/CopyLinkButton.stories.d.ts.map +1 -0
  49. package/dist/components/ui/DataDisplay.stories.d.ts +11 -0
  50. package/dist/components/ui/DataDisplay.stories.d.ts.map +1 -0
  51. package/dist/components/ui/DataTable.d.ts.map +1 -1
  52. package/dist/components/ui/DataTable.stories.d.ts +9 -0
  53. package/dist/components/ui/DataTable.stories.d.ts.map +1 -0
  54. package/dist/components/ui/DateRangePicker.stories.d.ts +9 -0
  55. package/dist/components/ui/DateRangePicker.stories.d.ts.map +1 -0
  56. package/dist/components/ui/Drawer.stories.d.ts +9 -0
  57. package/dist/components/ui/Drawer.stories.d.ts.map +1 -0
  58. package/dist/components/ui/DropdownMenu.stories.d.ts +9 -0
  59. package/dist/components/ui/DropdownMenu.stories.d.ts.map +1 -0
  60. package/dist/components/ui/EmailField.d.ts +7 -0
  61. package/dist/components/ui/EmailField.d.ts.map +1 -0
  62. package/dist/components/ui/EmailField.stories.d.ts +11 -0
  63. package/dist/components/ui/EmailField.stories.d.ts.map +1 -0
  64. package/dist/components/ui/EmptyState.stories.d.ts +22 -0
  65. package/dist/components/ui/EmptyState.stories.d.ts.map +1 -0
  66. package/dist/components/ui/Feedback.stories.d.ts +18 -0
  67. package/dist/components/ui/Feedback.stories.d.ts.map +1 -0
  68. package/dist/components/ui/FeedbackComponents.stories.d.ts +11 -0
  69. package/dist/components/ui/FeedbackComponents.stories.d.ts.map +1 -0
  70. package/dist/components/ui/FileUpload.d.ts +29 -0
  71. package/dist/components/ui/FileUpload.d.ts.map +1 -0
  72. package/dist/components/ui/FileUpload.stories.d.ts +57 -0
  73. package/dist/components/ui/FileUpload.stories.d.ts.map +1 -0
  74. package/dist/components/ui/FormField.stories.d.ts +16 -0
  75. package/dist/components/ui/FormField.stories.d.ts.map +1 -0
  76. package/dist/components/ui/FormFields.stories.d.ts +30 -0
  77. package/dist/components/ui/FormFields.stories.d.ts.map +1 -0
  78. package/dist/components/ui/InputField.d.ts +6 -2
  79. package/dist/components/ui/InputField.d.ts.map +1 -1
  80. package/dist/components/ui/InputField.stories.d.ts +26 -0
  81. package/dist/components/ui/InputField.stories.d.ts.map +1 -0
  82. package/dist/components/ui/LoadingState.stories.d.ts +10 -0
  83. package/dist/components/ui/LoadingState.stories.d.ts.map +1 -0
  84. package/dist/components/ui/Modal.stories.d.ts +9 -0
  85. package/dist/components/ui/Modal.stories.d.ts.map +1 -0
  86. package/dist/components/ui/MouseTooltip.d.ts.map +1 -1
  87. package/dist/components/ui/MouseTooltip.stories.d.ts +9 -0
  88. package/dist/components/ui/MouseTooltip.stories.d.ts.map +1 -0
  89. package/dist/components/ui/MultiSelect.stories.d.ts +11 -0
  90. package/dist/components/ui/MultiSelect.stories.d.ts.map +1 -0
  91. package/dist/components/ui/Navigation.stories.d.ts +12 -0
  92. package/dist/components/ui/Navigation.stories.d.ts.map +1 -0
  93. package/dist/components/ui/NumberField.d.ts +4 -0
  94. package/dist/components/ui/NumberField.d.ts.map +1 -0
  95. package/dist/components/ui/NumberField.stories.d.ts +11 -0
  96. package/dist/components/ui/NumberField.stories.d.ts.map +1 -0
  97. package/dist/components/ui/Overlays.stories.d.ts +11 -0
  98. package/dist/components/ui/Overlays.stories.d.ts.map +1 -0
  99. package/dist/components/ui/Pagination.stories.d.ts +9 -0
  100. package/dist/components/ui/Pagination.stories.d.ts.map +1 -0
  101. package/dist/components/ui/PhoneField.d.ts +22 -0
  102. package/dist/components/ui/PhoneField.d.ts.map +1 -0
  103. package/dist/components/ui/PhoneField.stories.d.ts +11 -0
  104. package/dist/components/ui/PhoneField.stories.d.ts.map +1 -0
  105. package/dist/components/ui/RadioGroup.stories.d.ts +11 -0
  106. package/dist/components/ui/RadioGroup.stories.d.ts.map +1 -0
  107. package/dist/components/ui/SearchableSelect.d.ts +6 -1
  108. package/dist/components/ui/SearchableSelect.d.ts.map +1 -1
  109. package/dist/components/ui/SearchableSelect.stories.d.ts +11 -0
  110. package/dist/components/ui/SearchableSelect.stories.d.ts.map +1 -0
  111. package/dist/components/ui/SectionPanel.stories.d.ts +9 -0
  112. package/dist/components/ui/SectionPanel.stories.d.ts.map +1 -0
  113. package/dist/components/ui/StatusBadge.stories.d.ts +27 -0
  114. package/dist/components/ui/StatusBadge.stories.d.ts.map +1 -0
  115. package/dist/components/ui/StatusSelect.d.ts +29 -0
  116. package/dist/components/ui/StatusSelect.d.ts.map +1 -0
  117. package/dist/components/ui/StatusSelect.stories.d.ts +9 -0
  118. package/dist/components/ui/StatusSelect.stories.d.ts.map +1 -0
  119. package/dist/components/ui/StepWizard.stories.d.ts +9 -0
  120. package/dist/components/ui/StepWizard.stories.d.ts.map +1 -0
  121. package/dist/components/ui/Tabs.stories.d.ts +9 -0
  122. package/dist/components/ui/Tabs.stories.d.ts.map +1 -0
  123. package/dist/components/ui/TextInput.stories.d.ts +15 -0
  124. package/dist/components/ui/TextInput.stories.d.ts.map +1 -0
  125. package/dist/components/ui/Textarea.stories.d.ts +17 -0
  126. package/dist/components/ui/Textarea.stories.d.ts.map +1 -0
  127. package/dist/components/ui/TextareaField.stories.d.ts +20 -0
  128. package/dist/components/ui/TextareaField.stories.d.ts.map +1 -0
  129. package/dist/components/ui/Toggle.stories.d.ts +31 -0
  130. package/dist/components/ui/Toggle.stories.d.ts.map +1 -0
  131. package/dist/components/ui/index.d.ts +11 -0
  132. package/dist/components/ui/index.d.ts.map +1 -1
  133. package/dist/components/users/UserAvatar.stories.d.ts +12 -0
  134. package/dist/components/users/UserAvatar.stories.d.ts.map +1 -0
  135. package/dist/index.d.ts +3 -0
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/lib/phoneCountryCodes.d.ts +7 -0
  138. package/dist/lib/phoneCountryCodes.d.ts.map +1 -0
  139. package/dist/lib/validation.d.ts +23 -0
  140. package/dist/lib/validation.d.ts.map +1 -0
  141. package/dist/lib/validationVisibility.d.ts +12 -0
  142. package/dist/lib/validationVisibility.d.ts.map +1 -0
  143. package/package.json +10 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.22 - 2026-05-06
4
+
5
+ - Replace `StatusSelect` native select behavior with a fully custom Bonsaif dropdown menu for consistent inline status changes.
6
+
7
+ ## 0.1.21 - 2026-05-06
8
+
9
+ - Add `StatusSelect`, a compact pill-style select for changing statuses inline while preserving badge-like visual styling.
10
+
3
11
  ## 0.1.18 - 2026-05-06
4
12
 
5
13
  - Render `DataTable` rows with CSS Grid instead of native table layout so column widths, resize handles, sticky columns, and future customization are controlled by the component.
package/README.md CHANGED
@@ -1,25 +1,66 @@
1
1
  # bonsaif-ui
2
2
 
3
- Reusable React components for Bonsaif applications.
3
+ Reusable React components for Bonsaif applications. The package focuses on internal product screens: dense forms, admin tables, status feedback, drawers, page headers, and service composition patterns.
4
4
 
5
- ## Package
5
+ ## Start Here
6
+
7
+ Install the package, import the stylesheet once in the app shell, and then import only the components needed by each screen.
6
8
 
7
9
  ```bash
8
10
  npm install bonsaif-ui
9
11
  ```
10
12
 
11
- ## Usage
12
-
13
13
  ```tsx
14
- import { Button, DataTable, PageHeader } from "bonsaif-ui";
14
+ import { Button, FileUpload, PageHeader } from "bonsaif-ui";
15
15
  import "bonsaif-ui/styles.css";
16
16
 
17
17
  export function Example() {
18
- return <Button>Save</Button>;
18
+ return (
19
+ <>
20
+ <PageHeader title="Documentos" currentPath="/admin/documents" />
21
+ <FileUpload
22
+ label="Adjuntos"
23
+ multiple
24
+ onFilesChange={(files) => console.log(files)}
25
+ />
26
+ <Button>Guardar</Button>
27
+ </>
28
+ );
19
29
  }
20
30
  ```
21
31
 
22
- ## Components
32
+ For Next.js consumers using a local package or monorepo setup, add `transpilePackages: ["bonsaif-ui"]` in `next.config.ts`.
33
+
34
+ ## Choose A Component
35
+
36
+ | Need | Start with | Why |
37
+ | --- | --- | --- |
38
+ | Build an admin page header | `PageHeader` | Breadcrumbs, metadata, page actions, and compact action buttons. |
39
+ | Capture form data | `InputField`, `EmailField`, `PhoneField`, `NumberField`, `FileUpload` | Shared labels, helpers, errors, focus states, and validation surfaces. |
40
+ | Search or filter a list | `SearchableSelect`, `CompactFilterSelect`, `CompactSearchInput` | Compact controls that work inside toolbars and table headers. |
41
+ | Show tabular records | `DataTable`, `Pagination` | Sorting, selection, loading, empty state, column width behavior, and paging. |
42
+ | Confirm or edit in context | `Drawer`, `Modal`, `ConfirmDialog` | Overlays with consistent chrome and guardrails for unsaved changes. |
43
+ | Explain status | `Alert`, `StatusBadge`, `StatusSelect`, `EmptyState`, `LoadingState` | Clear operational feedback for data states and workflows. |
44
+ | Compose related modules | `DynamicDetailTabs` | Parent-detail layout with lazy loaded child modules. |
45
+
46
+ ## Documentation Playground
47
+
48
+ Use Storybook for component documentation and the playground for full-screen integration examples.
49
+
50
+ ```bash
51
+ npm run storybook
52
+ npm run storybook:build
53
+ ```
54
+
55
+ Storybook is the main documentation surface for individual components. It includes autodocs, controls, accessibility checks, and isolated states such as `disabled`, `error`, `loading`, single-file upload, and multi-file upload.
56
+
57
+ Run the playground when you need to see spacing, page headers, navigation, copy buttons, dark mode, and integrated behavior in one app-like screen.
58
+
59
+ ```bash
60
+ npm run playground
61
+ ```
62
+
63
+ ## Component Map
23
64
 
24
65
  The package includes reusable components migrated from `prime-auth` and new shared primitives for Bonsaif apps.
25
66
 
@@ -32,12 +73,169 @@ The package includes reusable components migrated from `prime-auth` and new shar
32
73
 
33
74
  ### Forms
34
75
 
35
- - `InputField`, `TextInput`, `Textarea`: text inputs with Bonsaif styling.
76
+ - `InputField`, `EmailField`, `PhoneField`, `NumberField`, `TextInput`, `Textarea`: inputs with Bonsaif styling and inline validation for email and phone values.
77
+ - `FileUpload`: drag-and-drop or click-to-browse file selection with single-file and multi-file modes.
36
78
  - `SearchableSelect`, `CompactFilterSelect`, `CompactSearchInput`: select and filter controls.
37
79
  - `CalendarPicker`, `DateRangePicker`: single-date and range selection.
38
80
  - `Checkbox`, `RadioGroup`, `Toggle`: boolean and option controls.
39
81
  - `FormField`: label, helper, error, and required wrapper for custom controls.
40
82
 
83
+ ### File Uploads
84
+
85
+ Use `FileUpload` when a form needs attachments, CSV imports, evidence files, or any file selector that should support both drag-and-drop and regular browsing.
86
+
87
+ ```tsx
88
+ import { useState } from "react";
89
+ import { FileUpload } from "bonsaif-ui";
90
+
91
+ export function AttachmentField() {
92
+ const [files, setFiles] = useState<File[]>([]);
93
+
94
+ return (
95
+ <FileUpload
96
+ label="Adjuntos"
97
+ multiple
98
+ appendFiles
99
+ maxFiles={4}
100
+ accept=".pdf,.png,.jpg,.jpeg,.csv"
101
+ value={files}
102
+ onFilesChange={setFiles}
103
+ helperText="PDF, imagenes o CSV. Maximo 4 archivos."
104
+ onRejectedFiles={(rejectedFiles) => {
105
+ console.warn("Archivos rechazados", rejectedFiles);
106
+ }}
107
+ />
108
+ );
109
+ }
110
+ ```
111
+
112
+ Useful props:
113
+
114
+ | Prop | Description |
115
+ | --- | --- |
116
+ | `multiple` | Allows selecting or dropping more than one file. |
117
+ | `accept` | Native accept filter plus drag-and-drop filtering for MIME types and extensions. |
118
+ | `maxFiles` | Limits the accepted file list. |
119
+ | `appendFiles` | Adds new files to the current selection instead of replacing it. |
120
+ | `value` / `defaultValue` | Controlled or uncontrolled selected files. |
121
+ | `onFilesChange` | Receives the accepted `File[]`. |
122
+ | `onRejectedFiles` | Receives files blocked by `accept`. |
123
+ | `showFileList` | Shows or hides the selected file list. |
124
+
125
+ #### Form Validation
126
+
127
+ Use `validateForm` with reusable validators to validate complete forms before saving. Validators run in order and return the first error per field. Add `noValidate` to the form to avoid native browser validation, then pass each error to the field with `errorDisplay="tooltip"` when the message should appear in the compact validation tooltip.
128
+
129
+ Use `useValidationVisibility` when a form should validate immediately for save-button state but should not show red errors until the user touches a field or attempts to submit. Call `submit()` before blocking an invalid save, `touchField(field)` from `onChange`/`onBlur`, and `reset()` when opening a new draft.
130
+
131
+ ```tsx
132
+ import { useMemo, useState, type FormEvent } from "react";
133
+ import {
134
+ EmailField,
135
+ PhoneField,
136
+ emailFormat,
137
+ maxValue,
138
+ minLength,
139
+ minValue,
140
+ phoneFormat,
141
+ required,
142
+ validateForm,
143
+ useValidationVisibility,
144
+ type ValidationSchema,
145
+ } from "bonsaif-ui";
146
+
147
+ type AccountForm = {
148
+ contactName: string;
149
+ contactEmail: string;
150
+ contactCountryCode: string;
151
+ contactPhone: string;
152
+ seats: string;
153
+ discountCode: string;
154
+ };
155
+
156
+ const schema = {
157
+ contactName: [required("Escribe el nombre."), minLength(3)],
158
+ contactEmail: [required(), emailFormat()],
159
+ contactCountryCode: [required()],
160
+ contactPhone: (value, values) =>
161
+ phoneFormat()(`${values.contactCountryCode} ${value}`),
162
+ seats: [required(), minValue(1), maxValue(500)],
163
+ discountCode: (value, values) =>
164
+ Number(values.seats) > 100 && String(value).trim() === ""
165
+ ? "Solicita un codigo para cuentas de mas de 100 usuarios."
166
+ : undefined,
167
+ } satisfies ValidationSchema<AccountForm>;
168
+
169
+ function AccountFormExample() {
170
+ const [form, setForm] = useState<AccountForm>({
171
+ contactName: "",
172
+ contactEmail: "",
173
+ contactCountryCode: "+1",
174
+ contactPhone: "",
175
+ seats: "",
176
+ discountCode: "",
177
+ });
178
+ const validationResult = useMemo(
179
+ () => validateForm(form, schema),
180
+ [form],
181
+ );
182
+ const errors = validationResult.errors;
183
+ const validationVisibility = useValidationVisibility(errors);
184
+
185
+ function submitForm(event: FormEvent<HTMLFormElement>) {
186
+ event.preventDefault();
187
+ validationVisibility.submit();
188
+ if (!validationResult.valid) return;
189
+
190
+ saveAccount(form);
191
+ validationVisibility.reset();
192
+ }
193
+
194
+ return (
195
+ <form noValidate onSubmit={submitForm}>
196
+ <EmailField
197
+ label="Correo"
198
+ value={form.contactEmail}
199
+ error={validationVisibility.getFieldError("contactEmail")}
200
+ validate={false}
201
+ errorDisplay="tooltip"
202
+ onChange={(event) => {
203
+ validationVisibility.touchField("contactEmail");
204
+ setForm((current) => ({
205
+ ...current,
206
+ contactEmail: event.currentTarget.value,
207
+ }));
208
+ }}
209
+ onBlur={() => validationVisibility.touchField("contactEmail")}
210
+ />
211
+ <PhoneField
212
+ label="Telefono"
213
+ countryCode={form.contactCountryCode}
214
+ onCountryCodeChange={(countryCode) =>
215
+ setForm((current) => ({ ...current, contactCountryCode: countryCode }))
216
+ }
217
+ allowedCountryCodes={["+1", "+34", "+52", "+57", "+58"]}
218
+ value={form.contactPhone}
219
+ onChange={(event) => {
220
+ validationVisibility.touchField("contactPhone");
221
+ setForm((current) => ({
222
+ ...current,
223
+ contactPhone: event.currentTarget.value,
224
+ }));
225
+ }}
226
+ onBlur={() => validationVisibility.touchField("contactPhone")}
227
+ error={validationVisibility.getFieldError("contactPhone")}
228
+ validate={false}
229
+ errorDisplay="tooltip"
230
+ />
231
+ <button type="submit" disabled={!validationResult.valid}>
232
+ Guardar
233
+ </button>
234
+ </form>
235
+ );
236
+ }
237
+ ```
238
+
41
239
  ### Actions And Overlays
42
240
 
43
241
  - `Button`, `BonsaifButton`: action buttons.
@@ -139,14 +337,6 @@ How it works:
139
337
 
140
338
  App-coupled components were adapted to receive routing, session, and navigation data through props so the library does not import private `prime-auth` modules.
141
339
 
142
- ## Playground Documentation
143
-
144
- Run the playground to browse the components by category. Each code example includes a copy action powered by `CopyButton`.
145
-
146
- ```bash
147
- npm run playground
148
- ```
149
-
150
340
  ## UI Primitives
151
341
 
152
342
  Small primitives cover common product UI patterns while keeping the same Bonsaif visual tokens.