@dcs-tech/ui-native 0.0.0-stage → 0.16.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/CHANGELOG.md +186 -0
- package/README.md +179 -2
- package/dist/components/Button/Button.js +61 -0
- package/dist/components/Button/buttonStyle.js +100 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/Checkbox/Checkbox.js +60 -0
- package/dist/components/Checkbox/checkboxStyle.js +44 -0
- package/dist/components/Checkbox/index.js +1 -0
- package/dist/components/DataTable/BulkRun.js +85 -0
- package/dist/components/DataTable/CardList.js +70 -0
- package/dist/components/DataTable/DataTable.js +53 -0
- package/dist/components/DataTable/DataTableScrollView.js +33 -0
- package/dist/components/DataTable/DragSelect.js +153 -0
- package/dist/components/DataTable/LayoutSwitcher.js +48 -0
- package/dist/components/DataTable/Pager.js +15 -0
- package/dist/components/DataTable/RowActions.js +28 -0
- package/dist/components/DataTable/RowDetail.js +80 -0
- package/dist/components/DataTable/RowMenuSheet.js +72 -0
- package/dist/components/DataTable/SortSheet.js +25 -0
- package/dist/components/DataTable/SplitList.js +30 -0
- package/dist/components/DataTable/StatusRow.js +48 -0
- package/dist/components/DataTable/SwipeRow.js +125 -0
- package/dist/components/DataTable/ToolButton.js +9 -0
- package/dist/components/DataTable/Toolbar.js +53 -0
- package/dist/components/DataTable/cells.js +21 -0
- package/dist/components/DataTable/dataTableStyle.js +218 -0
- package/dist/components/DataTable/filters/FilterConditionRow.js +49 -0
- package/dist/components/DataTable/filters/FilterGroupEditor.js +21 -0
- package/dist/components/DataTable/filters/FilterSheet.js +69 -0
- package/dist/components/DataTable/filters/SavedFilterBar.js +39 -0
- package/dist/components/DataTable/filters/filterStyle.js +82 -0
- package/dist/components/DataTable/index.js +3 -0
- package/dist/components/DataTable/persistence/adapters.js +78 -0
- package/dist/components/DataTable/persistence/useViewPrefs.js +76 -0
- package/dist/components/DataTable/rowParts.js +47 -0
- package/dist/components/DataTable/useTableState.js +345 -0
- package/dist/components/DatePicker/Calendar.js +28 -0
- package/dist/components/DatePicker/DatePicker.js +300 -0
- package/dist/components/DatePicker/PeriodGrid.js +17 -0
- package/dist/components/DatePicker/PeriodPicker.js +216 -0
- package/dist/components/DatePicker/TimeField.js +50 -0
- package/dist/components/DatePicker/datePickerStyle.js +157 -0
- package/dist/components/DatePicker/index.js +2 -0
- package/dist/components/Dialog/Dialog.js +104 -0
- package/dist/components/Dialog/DialogHost.js +71 -0
- package/dist/components/Dialog/dialogStyle.js +72 -0
- package/dist/components/Dialog/index.js +2 -0
- package/dist/components/FieldContext/FieldContext.js +50 -0
- package/dist/components/FieldContext/index.js +1 -0
- package/dist/components/FieldWrapper/FieldWrapper.js +23 -0
- package/dist/components/FieldWrapper/fieldWrapperStyle.js +64 -0
- package/dist/components/FieldWrapper/index.js +1 -0
- package/dist/components/Icon/Icon.js +124 -0
- package/dist/components/Icon/IconContext.js +12 -0
- package/dist/components/Icon/iconStyle.js +59 -0
- package/dist/components/Icon/icons.js +252 -0
- package/dist/components/Icon/index.js +4 -0
- package/dist/components/Icon/useIconDone.js +19 -0
- package/dist/components/Input/Input.js +71 -0
- package/dist/components/Input/index.js +1 -0
- package/dist/components/Input/inputStyle.js +47 -0
- package/dist/components/Press/Ripple.js +92 -0
- package/dist/components/Press/index.js +1 -0
- package/dist/components/Press/measure.js +3 -0
- package/dist/components/Radio/Radio.js +54 -0
- package/dist/components/Radio/index.js +1 -0
- package/dist/components/Radio/radioStyle.js +45 -0
- package/dist/components/Select/Select.js +83 -0
- package/dist/components/Select/SelectSheet.js +85 -0
- package/dist/components/Select/index.js +1 -0
- package/dist/components/Suggest/Suggest.js +101 -0
- package/dist/components/Suggest/index.js +1 -0
- package/dist/components/Switch/Switch.js +71 -0
- package/dist/components/Switch/index.js +1 -0
- package/dist/components/Switch/switchStyle.js +59 -0
- package/dist/components/Toast/ToastHost.js +76 -0
- package/dist/components/Toast/ToastItem.js +115 -0
- package/dist/components/Toast/ToastLayer.js +21 -0
- package/dist/components/Toast/index.js +2 -0
- package/dist/components/Toast/toast.types.js +1 -0
- package/dist/components/Toast/toastStyle.js +73 -0
- package/dist/components/Toggle/ToggleField.js +20 -0
- package/dist/components/Toggle/ToggleGroupFrame.js +10 -0
- package/dist/components/UIProvider/UIProvider.js +14 -0
- package/dist/components/UIProvider/context.js +58 -0
- package/dist/components/UIProvider/index.js +1 -0
- package/dist/components/styles/color.js +35 -0
- package/dist/components/styles/fieldControl.js +102 -0
- package/dist/components/styles/popupList.js +102 -0
- package/dist/components/styles/toggle.js +64 -0
- package/dist/components/styles/webValues.js +147 -0
- package/dist/index.js +15 -0
- package/dist/locales/hi.js +1 -0
- package/dist/locales/ta.js +1 -0
- package/dist/types/components/Button/Button.d.ts +31 -0
- package/dist/types/components/Button/buttonStyle.d.ts +46 -0
- package/dist/types/components/Button/index.d.ts +3 -0
- package/dist/types/components/Checkbox/Checkbox.d.ts +60 -0
- package/dist/types/components/Checkbox/checkboxStyle.d.ts +16 -0
- package/dist/types/components/Checkbox/index.d.ts +3 -0
- package/dist/types/components/DataTable/BulkRun.d.ts +11 -0
- package/dist/types/components/DataTable/CardList.d.ts +18 -0
- package/dist/types/components/DataTable/DataTable.d.ts +11 -0
- package/dist/types/components/DataTable/DataTableScrollView.d.ts +10 -0
- package/dist/types/components/DataTable/DragSelect.d.ts +12 -0
- package/dist/types/components/DataTable/LayoutSwitcher.d.ts +23 -0
- package/dist/types/components/DataTable/Pager.d.ts +5 -0
- package/dist/types/components/DataTable/RowActions.d.ts +13 -0
- package/dist/types/components/DataTable/RowDetail.d.ts +15 -0
- package/dist/types/components/DataTable/RowMenuSheet.d.ts +5 -0
- package/dist/types/components/DataTable/SortSheet.d.ts +8 -0
- package/dist/types/components/DataTable/SplitList.d.ts +9 -0
- package/dist/types/components/DataTable/StatusRow.d.ts +7 -0
- package/dist/types/components/DataTable/SwipeRow.d.ts +25 -0
- package/dist/types/components/DataTable/ToolButton.d.ts +13 -0
- package/dist/types/components/DataTable/Toolbar.d.ts +8 -0
- package/dist/types/components/DataTable/cells.d.ts +13 -0
- package/dist/types/components/DataTable/dataTableStyle.d.ts +139 -0
- package/dist/types/components/DataTable/filters/FilterConditionRow.d.ts +12 -0
- package/dist/types/components/DataTable/filters/FilterGroupEditor.d.ts +13 -0
- package/dist/types/components/DataTable/filters/FilterSheet.d.ts +5 -0
- package/dist/types/components/DataTable/filters/SavedFilterBar.d.ts +20 -0
- package/dist/types/components/DataTable/filters/filterStyle.d.ts +46 -0
- package/dist/types/components/DataTable/index.d.ts +5 -0
- package/dist/types/components/DataTable/persistence/adapters.d.ts +12 -0
- package/dist/types/components/DataTable/persistence/useViewPrefs.d.ts +20 -0
- package/dist/types/components/DataTable/rowParts.d.ts +32 -0
- package/dist/types/components/DataTable/useTableState.d.ts +103 -0
- package/dist/types/components/DatePicker/Calendar.d.ts +11 -0
- package/dist/types/components/DatePicker/DatePicker.d.ts +65 -0
- package/dist/types/components/DatePicker/PeriodGrid.d.ts +11 -0
- package/dist/types/components/DatePicker/PeriodPicker.d.ts +10 -0
- package/dist/types/components/DatePicker/TimeField.d.ts +15 -0
- package/dist/types/components/DatePicker/datePickerStyle.d.ts +75 -0
- package/dist/types/components/DatePicker/index.d.ts +4 -0
- package/dist/types/components/Dialog/Dialog.d.ts +35 -0
- package/dist/types/components/Dialog/DialogHost.d.ts +45 -0
- package/dist/types/components/Dialog/dialogStyle.d.ts +23 -0
- package/dist/types/components/Dialog/index.d.ts +4 -0
- package/dist/types/components/FieldContext/FieldContext.d.ts +43 -0
- package/dist/types/components/FieldContext/index.d.ts +3 -0
- package/dist/types/components/FieldWrapper/FieldWrapper.d.ts +23 -0
- package/dist/types/components/FieldWrapper/fieldWrapperStyle.d.ts +24 -0
- package/dist/types/components/FieldWrapper/index.d.ts +3 -0
- package/dist/types/components/Icon/Icon.d.ts +37 -0
- package/dist/types/components/Icon/IconContext.d.ts +12 -0
- package/dist/types/components/Icon/iconStyle.d.ts +10 -0
- package/dist/types/components/Icon/icons.d.ts +250 -0
- package/dist/types/components/Icon/index.d.ts +7 -0
- package/dist/types/components/Icon/useIconDone.d.ts +4 -0
- package/dist/types/components/Input/Input.d.ts +53 -0
- package/dist/types/components/Input/index.d.ts +3 -0
- package/dist/types/components/Input/inputStyle.d.ts +11 -0
- package/dist/types/components/Press/Ripple.d.ts +20 -0
- package/dist/types/components/Press/index.d.ts +2 -0
- package/dist/types/components/Press/measure.d.ts +8 -0
- package/dist/types/components/Radio/Radio.d.ts +58 -0
- package/dist/types/components/Radio/index.d.ts +3 -0
- package/dist/types/components/Radio/radioStyle.d.ts +17 -0
- package/dist/types/components/Select/Select.d.ts +49 -0
- package/dist/types/components/Select/SelectSheet.d.ts +34 -0
- package/dist/types/components/Select/index.d.ts +3 -0
- package/dist/types/components/Suggest/Suggest.d.ts +44 -0
- package/dist/types/components/Suggest/index.d.ts +3 -0
- package/dist/types/components/Switch/Switch.d.ts +42 -0
- package/dist/types/components/Switch/index.d.ts +3 -0
- package/dist/types/components/Switch/switchStyle.d.ts +29 -0
- package/dist/types/components/Toast/ToastHost.d.ts +12 -0
- package/dist/types/components/Toast/ToastItem.d.ts +17 -0
- package/dist/types/components/Toast/ToastLayer.d.ts +11 -0
- package/dist/types/components/Toast/index.d.ts +5 -0
- package/dist/types/components/Toast/toast.types.d.ts +37 -0
- package/dist/types/components/Toast/toastStyle.d.ts +22 -0
- package/dist/types/components/Toggle/ToggleField.d.ts +31 -0
- package/dist/types/components/Toggle/ToggleGroupFrame.d.ts +14 -0
- package/dist/types/components/UIProvider/UIProvider.d.ts +17 -0
- package/dist/types/components/UIProvider/context.d.ts +22 -0
- package/dist/types/components/UIProvider/index.d.ts +2 -0
- package/dist/types/components/styles/color.d.ts +2 -0
- package/dist/types/components/styles/fieldControl.d.ts +26 -0
- package/dist/types/components/styles/popupList.d.ts +48 -0
- package/dist/types/components/styles/toggle.d.ts +26 -0
- package/dist/types/components/styles/webValues.d.ts +157 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/locales/hi.d.ts +1 -0
- package/dist/types/locales/ta.d.ts +1 -0
- package/package.json +85 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# @dcs-tech/ui-native
|
|
2
|
+
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2b41f48: DatePicker's first day of the week follows the app's locale, on the web and native: with no `weekStart` set, the calendar grid's first column — and where the "This Week" preset starts — is the first day of the week in UIProvider `locale` (`localeWeekStart`, as the EventCalendar already did; without a provider, the browser's or device's locale). Monday-first locales (en-GB, de, …) now start on Monday, and "This Week" runs Monday to Sunday there; en-IN and en-US stay on Sunday. A picker's own `weekStart` still wins. In `@dcs-tech/core`, `localeWeekStart` now lives with the date logic (`datePicker.logic`); it is exported as before.
|
|
8
|
+
- 2b41f48: DatePicker follows the app, as on the web: the month and weekday names come from Intl in UIProvider's `locale`, the words from its language pack, and the shown format from the new UIProvider `dateFormat` (a picker's own `displayFormat` still wins; default dd-mm-yyyy). A month picker names its month in the locale too. New: UIProvider `dateFormat`, `useUIDateFormat()`.
|
|
9
|
+
- 2b41f48: Rich text. New `RichTextEditor` in its own entry, `@dcs-tech/ui/rich-text` (Tiptap underneath, so only an app that imports it bundles the editor engine): headings, lists and checklists, quotes, code, rules, tables (rows, columns, header row, merge / split, column resize), images (`onImageUpload`, or kept in the document; pick, drop or paste; alt text), links (a link box that reads `example.com` / an email / a phone number as an address and refuses unsafe ones), theme text colours and highlights, alignment and text direction, @mentions (`mentions.items(query)`, async), `{{variables}}` (`variables`, from the toolbar or typed "{{"), a "/" menu of blocks, a menu over selected text, Markdown paste and import, HTML import read through the schema, `maxLength` (graphemes, any script) and a word / character count, min / max height (scrolls inside), read-only and disabled. A field like the others: label, hint, error, required (an empty document is missing), Form / Fields `field: 'richText'` with the editor handed over in `componentRegistry`, Tab leaves, Ctrl+Enter submits, Escape closes a menu first; its shortcuts follow the app's command key (Ctrl by default on every platform). The toolbar takes a preset (`full`, `basic`, `message`, `minimal`) or groups, and folds what does not fit into ⋯.
|
|
10
|
+
|
|
11
|
+
New in `@dcs-tech/ui`: `RichTextView` (a document drawn read-only, no editor loaded; variables filled or as chips; `onMentionClick`, `onLinkClick`) and `richTextClassName()` (the content look, for HTML from `richTextToHtml`); icons `IconListBulleted`, `IconQuote`, `IconHeading`, `IconAlignJustify`, `IconIndent`, `IconOutdent`, `IconCodeBlock`, `IconTextDirection`, `IconHighlighter`, `IconTextColor` (also in `@dcs-tech/ui-native`); words in `labels.richText`.
|
|
12
|
+
|
|
13
|
+
New in `@dcs-tech/core`: the document model `RichTextDoc` (ProseMirror / Tiptap JSON) with `normalizeRichText`, `richTextToPlain`, `richTextToMarkdown`, `richTextToHtml` (escaped, known tags only), `fillRichTextVariables`, `liftRichTextVariables`, `collectRichTextVariables`, `collectRichTextMentions`, `isEmptyRichText`, `richTextCharCount` / `richTextWordCount` / `graphemeCount` / `textWordCount` (`Intl.Segmenter`), `safeRichTextUrl`, `normalizeLinkInput`, `firstStrongDirection`, the editor's keys, toolbar presets and menu search (`richTextKeyCommand`, `richTextToolbarGroups`, `filterRichTextItems`); `isMissingRequired('richText', …)`; `FieldDefinition` `field: 'richText'` and `FieldComponentRegistry.RichTextEditor`.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 2b41f48: DataTable filter sheet: a condition's value list (a column with no `filterOptions`) comes from the rows the search and the sheet's other conditions keep, as in the web's Filters dialog: every condition on the column itself counts as passed (an OR group that holds one included), so choosing a value never narrows its own list. Core's `valueListRows`.
|
|
18
|
+
- Updated dependencies [2b41f48]
|
|
19
|
+
- Updated dependencies [2b41f48]
|
|
20
|
+
- Updated dependencies [2b41f48]
|
|
21
|
+
- Updated dependencies [2b41f48]
|
|
22
|
+
- Updated dependencies [2b41f48]
|
|
23
|
+
- Updated dependencies [2b41f48]
|
|
24
|
+
- Updated dependencies [2b41f48]
|
|
25
|
+
- Updated dependencies [2b41f48]
|
|
26
|
+
- Updated dependencies [2b41f48]
|
|
27
|
+
- Updated dependencies [2b41f48]
|
|
28
|
+
- Updated dependencies [2b41f48]
|
|
29
|
+
- Updated dependencies [2b41f48]
|
|
30
|
+
- Updated dependencies [2b41f48]
|
|
31
|
+
- Updated dependencies [2b41f48]
|
|
32
|
+
- Updated dependencies [2b41f48]
|
|
33
|
+
- Updated dependencies [2b41f48]
|
|
34
|
+
- Updated dependencies [2b41f48]
|
|
35
|
+
- Updated dependencies [2b41f48]
|
|
36
|
+
- Updated dependencies [2b41f48]
|
|
37
|
+
- Updated dependencies [2b41f48]
|
|
38
|
+
- Updated dependencies [2b41f48]
|
|
39
|
+
- Updated dependencies [2b41f48]
|
|
40
|
+
- Updated dependencies [2b41f48]
|
|
41
|
+
- Updated dependencies [2b41f48]
|
|
42
|
+
- Updated dependencies [2b41f48]
|
|
43
|
+
- Updated dependencies [2b41f48]
|
|
44
|
+
- Updated dependencies [2b41f48]
|
|
45
|
+
- Updated dependencies [2b41f48]
|
|
46
|
+
- Updated dependencies [2b41f48]
|
|
47
|
+
- Updated dependencies [2b41f48]
|
|
48
|
+
- Updated dependencies [2b41f48]
|
|
49
|
+
- Updated dependencies [2b41f48]
|
|
50
|
+
- Updated dependencies [2b41f48]
|
|
51
|
+
- Updated dependencies [2b41f48]
|
|
52
|
+
- Updated dependencies [2b41f48]
|
|
53
|
+
- Updated dependencies [2b41f48]
|
|
54
|
+
- Updated dependencies [2b41f48]
|
|
55
|
+
- Updated dependencies [2b41f48]
|
|
56
|
+
- Updated dependencies [2b41f48]
|
|
57
|
+
- Updated dependencies [2b41f48]
|
|
58
|
+
- Updated dependencies [2b41f48]
|
|
59
|
+
- Updated dependencies [2b41f48]
|
|
60
|
+
- Updated dependencies [2b41f48]
|
|
61
|
+
- @dcs-tech/core@0.16.0
|
|
62
|
+
- @dcs-tech/tokens@0.16.0
|
|
63
|
+
|
|
64
|
+
## 0.15.0
|
|
65
|
+
|
|
66
|
+
### Minor Changes
|
|
67
|
+
|
|
68
|
+
- c9eb745: Icon sizes follow MUI's model, sized to the reference app: **an icon's size comes from the slot it sits in, never from the text around it.** A visual change in every app.
|
|
69
|
+
|
|
70
|
+
- **One slot table**: `ICON_SLOT_SIZES` / type `IconSlot` in core and `--icon-slot-*` tokens (× `--ui-scale`): `button` 16 (icon buttons, the icon beside a small / medium Button's label), `prominent` 18 (app bar icon buttons, large / xl Buttons), `nav` 16 (Sidebar incl. rail, NavList, menu and option rows), `inline` 14 (chevrons, breadcrumb separators, sort arrows, header ⋮), `field` 16 (adornments, prefix / suffix, field icons), `dense` 13 (chips, xs / xxs Buttons, the table footer's pagination), `default` 16 (an icon in no slot). Every library component now sets one of these; the per-component numbers are gone.
|
|
71
|
+
- **Button**: `BUTTON_ICON_SLOTS` — xxs / xs → 13, small / medium → 16, large / xl → 18, with or without a label (medium icon-only was 20, large 24, xl 28; a label icon was 1em of the label).
|
|
72
|
+
- **Sidebar** top-level rows are 40px tall (the 16px nav icon and 12px above and below), the rail too; their icons are 16 (were 12). Child rows are a step smaller, as the reference app's: 30px tall, 13px icons, regular weight; a child row's trailing action fits the row. The collapse bar's chevron is 18 (was 14), the reference app's.
|
|
73
|
+
- **App bar** icon buttons carry 18px icons: an open line drawing reads larger than a filled glyph of the same extent, so 18 matches the reference app's 20px filled icons by eye.
|
|
74
|
+
- **Drawing margin**: the library's line icons (`IconDefinition.inset`, new) get Material's live area — the viewBox is inset by `ICON_INSET` (1.5 grid units; `iconInset`, `iconViewBox`) and the stroke thickened by `ICON_INSET_STROKE` (1.125), so an icon's ink fills about 76–83% of its box like Material's (was 84–92%) at the same line weight. Brand icons, artwork, wide icons and your own drawings are unchanged.
|
|
75
|
+
- **Icon-only Buttons without a `color` now use the text colour (`neutral`), like MUI's IconButton** (`resolveButtonColor`); a Button with a label stays `primary`, and a ButtonGroup's colour still wins.
|
|
76
|
+
- React Native: the same slot tokens through `useTokens()`, the same Button sizes, the same drawing margin and the same default colour.
|
|
77
|
+
|
|
78
|
+
Upgrading:
|
|
79
|
+
|
|
80
|
+
- An icon with no `size` outside a library component is now **16px** (it was 1em of the text around it). For an icon inside running text, pass **`size="inherit"`** (new, like MUI `fontSize="inherit"`).
|
|
81
|
+
- An explicit `size` (a name or pixels) still wins everywhere. The `--icon-size-*` tokens and the `action` / `marker` / `chip` / `status` names still work.
|
|
82
|
+
- Icon-only Buttons that should stay blue need `color="primary"`.
|
|
83
|
+
- Your own `IconDefinition`s are drawn edge to edge as before; add `inset: true` to give one the library's margin.
|
|
84
|
+
- A container of your own can size the icons in it with `--dcs-icon-size: var(--icon-slot-…)`.
|
|
85
|
+
|
|
86
|
+
- deefd41: `@dcs-tech/ui-native`: `DataTable`, taking the web DataTable's props and `views` / `columns` config: the views as tabs, a search, a sort (in a sheet), the rows as cards or a split list, a pager, and a row opening in a sheet (in a pane beside the list in a wide split view), with the built-in field list or the app's `renderDetail`. From `data`, or from a `dataSource` asked with the web's query. Filters, selection, row actions, export and the rest are not drawn yet (the package README lists them).
|
|
87
|
+
|
|
88
|
+
`@dcs-tech/core`: a table's rows in client mode, step by step (`shownViews`, `viewColumns`, `initialSorting`, `viewPageSize`, `clientRows`, `pageCountOf`, `pageOf`), `cardsPerLine` and `CARD_GAP` (from `@dcs-tech/ui`'s cards) and `sortWords` (the words of a sort, from its status row).
|
|
89
|
+
|
|
90
|
+
- f9bcf4e: `DatePicker`: `picker="month"` and `picker="year"`, as the web's. A sheet with the typed box and twelve months or years three to a row; one press chooses a period and closes, a range closes on its second end.
|
|
91
|
+
- 719196f: `DatePicker`: `withTime` and `timeToggle`, as the web's. Each date has a time box, typed or set by its hour / minute / AM-PM columns; a range's ends take 00:00 and 23:59, a single date now.
|
|
92
|
+
- 59cad30: `DatePicker`: the web's date field on a phone, days and ranges. The field shows the date or the preset's name; a sheet from the bottom holds the typed boxes, one month's calendar with month and year to jump to, the presets and Clear / Apply. The web's rules from core: typing, a range extending, presets, `min` / `max`. The calendar's grid is exported as `Calendar`.
|
|
93
|
+
- c0e2432: `@dcs-tech/ui-native`: a Dialog keeps its content clear of the status and navigation bars. It draws edge to edge, and a sheet from the bottom ran under Android's navigation bar (the DataTable's row detail lost its last line); it now measures the bars in its own window and pads by them — a sheet's panel still reaches the screen's edge behind the bar. New peer dependency: `react-native-safe-area-context` 5 or later (part of Expo); an app needs no `SafeAreaProvider` for this.
|
|
94
|
+
- 55e38ec: `@dcs-tech/ui-native`: `Dialog`, a dialog or a sheet from any edge (`placement`), with the web Dialog's sizes, title / subtitle / footer bands, a scrolling body, its close rules (`onBeforeClose`, the backdrop, Android's Back, the close button) and its enter and exit. `useDialog()` asks `confirm`, `choose` and `alert` and resolves with the answer, as on the web; `UIProvider` hosts it. `useDialogOpen()` tells whether one is open.
|
|
95
|
+
- 967f157: `@dcs-tech/ui-native` DataTable: drag to select. Where a long-press ticks a row, moving the finger without lifting it ticks every row from there to the one under it, and moving back unticks them. New: `DataTableScrollView`, a ScrollView (the same props) for the screen a table sits in — the drag holds it still and scrolls it at its top and bottom edges.
|
|
96
|
+
- f16579c: `@dcs-tech/ui-native`: the field foundation and `Input`. `FieldProvider` and `useFieldSurface()` hand size, variant, layout, disabled and read-only down to every field, as on the web; `FieldWrapper` draws the label, help and error around any control; `Input` has the web Input's sizes, variants and layouts, prefix and suffix, icons, a clear button, the password eye and a character count, with a phone keyboard per `type`. `UIProvider` takes `labels`, the same dictionary as the web's, and `useUILabels()` reads it.
|
|
97
|
+
|
|
98
|
+
`@dcs-tech/core`: the library's built-in words (`DEFAULT_UI_LABELS`, `mergeLabels`, `PartialLabels`, `UILabelDictionary`) moved here from `@dcs-tech/ui`, so both platforms share one dictionary. `@dcs-tech/ui` exports the same names as before.
|
|
99
|
+
|
|
100
|
+
- 1bfd3c5: `@dcs-tech/ui-native`: the DataTable's filter builder, as the web's Filters dialog: the toolbar's Filters with its count, a filter chip opening it, AND / OR, nested groups with NOT, each condition's column, operator and value (the DatePicker for dates), the JSON, Clear all / Cancel / Apply.
|
|
101
|
+
|
|
102
|
+
`@dcs-tech/core`: the builder's rules (`filterBuilder`: `emptyFilterCondition`, `emptyFilterSubgroup`, `withBlankCondition`, `countActiveConditions`, `filterColumnOptions`, `filterOperatorsFor`, `conditionWithColumn`, `conditionWithOperator`, `filterValueInput`, `betweenValueOf`, `dateFilterValueOf`, `filterValueOptions`), which `@dcs-tech/ui`'s filter dialog now uses with the same behaviour.
|
|
103
|
+
|
|
104
|
+
- 992ea58: `@dcs-tech/ui-native` DataTable: filters, as the web's. The view's `filtering` — quick filters (⚡ on a phone, beside the search wider), `defaultFilter` — the filter's chips in the status row (✕ to remove, Clear all), and the row menu's Filter by (Only / Add / Hide a value of the card). Server mode sends the filter in the query. The filter builder comes next.
|
|
105
|
+
|
|
106
|
+
`@dcs-tech/core`: the value filters moved from `@dcs-tech/ui` (`applyValueFilter`, `cellFilterValues`, `valueFilterKinds`, `canFilterByValue`, `chipShape`, `VALUE_FILTER_ID_PREFIX` and their types), with `valueFilterEntries` and `filterChipText`; `quickFilterGroup`; `clientRows` takes the filter (`filterGroup`).
|
|
107
|
+
|
|
108
|
+
- c9eb745: **UIProvider: language packs, as the web's.** `messages` and `locale`: `import ta from '@dcs-tech/ui-native/locales/ta'`, then `<UIProvider locale="ta-IN" messages={[ta]}>`. Per word: a component's own prop → `labels` → the exact locale's pack → its language's → English; nested providers inherit both. New entry points `@dcs-tech/ui-native/locales/ta` and `/hi` (the same DRAFT packs as the web's), and `useUILocale()`.
|
|
109
|
+
|
|
110
|
+
**DataTable** reads the app-wide table words (`UIProvider labels.table`, and a pack's) under its own `labels`, and takes UIProvider's `locale` when it sets none.
|
|
111
|
+
|
|
112
|
+
- 2b05857: `@dcs-tech/ui-native`: the DataTable keeps the user's choices (the layout, saved filters) as the web's: with a `tableId`, in the view's document through `persistence`, the same adapter and document as the web's. Without `persistence`, on the device with AsyncStorage (`@react-native-async-storage/async-storage`, a new optional peer), else in memory; `asyncStorageAdapter` and `memoryAdapter` are exported. `prefsVersion`, `migratePrefs` and `renamedViews` as the web's.
|
|
113
|
+
|
|
114
|
+
`@dcs-tech/core`: the saved preferences' shared rules (`viewPrefs`: `viewDocKey`, `readViewDoc`, `setDocPath`, `migratedPrefsDoc`, `prefsColumns`, `renamedKey`, `renameFilterColumns`, `conditionIssue`, `filterIssue`, `withoutStaleConditions`, `repairSavedFilters`, `reportsUserChange`, `prefsNotice`, `PREFS_SAVE_DEBOUNCE_MS`, `PREFS_NOTICE_MS`), which `@dcs-tech/ui`'s DataTable now uses with the same behaviour.
|
|
115
|
+
|
|
116
|
+
- 2002e5a: `@dcs-tech/ui-native` DataTable: row actions and the row menu. A card shows its first `primary` action and ⋮, a split item that action's icon and ⋮; ⋮ or a long-press (`rowMenu.longPress`) opens the row menu as a bottom sheet — the row's avatar and title, Open and the app's `rowMenu.iconActions`, then every action and `rowMenu.items`, the dangerous ones last. `rowMenu.enabled: false` turns the menu off.
|
|
117
|
+
|
|
118
|
+
`@dcs-tech/core`: the rules for a row's actions, moved from `@dcs-tech/ui` so both tables show the same ones — `primaryActionOf`, `inlineActionsOf`, `actionVariantOf`, `rowMenuEntries`, `rowMenuHostIcons` (and their types).
|
|
119
|
+
|
|
120
|
+
- fea8491: `@dcs-tech/ui-native`: the DataTable's saved filters, as the web's: the filter builder's list to load one from, Update, Save as new and delete; the user's offered with the quick filters. Kept for the session (as the web's without `persistence`).
|
|
121
|
+
|
|
122
|
+
`@dcs-tech/core`: the saved filters' rules (`savedFilters`: `SAVED_FILTER_PREFIX`, `savedFilterQuickId`, `isUsableSavedFilter`, `countFilterConditions`, `stripFilterIds`, `filterGroupsEqual`, `savedFilterOffText`, `mergedSavedFilters`, `withSavedFilter`, `withoutSavedFilter`, `newSavedFilter`, `updatedSavedFilter`, `pickQuickFilters`, `quickFilterOptions`, `savedFilterActions`), which `@dcs-tech/ui`'s DataTable now uses with the same behaviour.
|
|
123
|
+
|
|
124
|
+
- 246354f: `@dcs-tech/ui-native`: `Select`, with its list as a sheet from the bottom of the screen: search, sort, groups, one value or several (with the web's `maxSelection`, `minSelection`, `alwaysDisabled`, `defaultSelected` and select-all rules), clear, loading and empty states, custom rows and value, and a controllable `open`.
|
|
125
|
+
|
|
126
|
+
`@dcs-tech/core`: a Select's value rules as pure functions (`selectToggleValue`, `selectAllValue`, `selectClearValue`, `selectIsAllSelected`, `selectIsEmpty`, `selectDisplay`, `multiSelectRules`), which `@dcs-tech/ui`'s `useSelect` now uses with the same behaviour; and the word `select.itemsSelected`.
|
|
127
|
+
|
|
128
|
+
- 00f61d1: `@dcs-tech/ui-native` DataTable: row selection and bulk actions. The view's `selection` (on demand with the toolbar's Select button, `always`, single or multiple, `isSelectable`, `onSelectionChange`), a checkbox on each card / list item while selecting, a tap ticking a row; where the view has bulk actions a long-press ticks the row (the menu stays on ⋮), and the row menu has Select / Unselect. The status row under the toolbar, as on the web: the bulk buttons, "3 selected", Select all (N, or N matching in server mode), Clear, the sort's chips, the default order and the summary. The table's and the view's `bulkActions` run as on the web — eligible and skipped rows, limits, a confirm (with its note), the result in a toast with Undo, the selection let go or kept; server mode fetches again after.
|
|
129
|
+
|
|
130
|
+
`@dcs-tech/core`: the bulk actions' rules, moved from `@dcs-tech/ui` so both tables run them alike — `resolveBulkActions`, `planBulkAction`, `resolveConfirm`, `summarizeReasons`, `summarizeBulkResult`, `bulkResultOf` (and `BulkPlan`, `BulkSummary`); and the selection's — `toggleSelected`, `selectAllOffer`, `sameSortEntries`, `defaultOrderWords`, `statusSummaryText`.
|
|
131
|
+
|
|
132
|
+
- a1edb61: `@dcs-tech/ui-native`: `Suggest`, a text field that suggests as you type, with the list under the field: the same search engines, rows (primary, secondary and tertiary lines, labels, formatters), match highlighting and groups as the web's.
|
|
133
|
+
|
|
134
|
+
`@dcs-tech/core`: Suggest's search (`performSearch`, `matchSorterSearch`, `fuseSearch`), the `useSuggest` hook (`@dcs-tech/core/hooks`) and `highlightParts` moved here from `@dcs-tech/ui`, so both platforms search alike; `match-sorter` and `fuse.js` are now its dependencies.
|
|
135
|
+
|
|
136
|
+
`@dcs-tech/ui`: `useSuggest` is re-exported from core, unchanged except that its `handleInputChange` now accepts anything with the text as `target.value` (a DOM change event still fits).
|
|
137
|
+
|
|
138
|
+
- 7649405: `@dcs-tech/ui-native` DataTable: swipe actions. A view's `swipeActions` (`right`, `left`: some of its `actions` by id; `fullSwipe`) shows them behind a card or list item swiped sideways, in their colours; a tap runs one, a long swipe runs the outermost (never a dangerous one). One row open at a time; none while selecting.
|
|
139
|
+
|
|
140
|
+
`@dcs-tech/core`: the view's `swipeActions` (`DataTableSwipeActions`) and its rules, `swipeEntries` and `fullSwipeRuns` (with `DataTableSwipeEntry`). The web does not draw swipe actions.
|
|
141
|
+
|
|
142
|
+
- b2e40ff: `@dcs-tech/ui-native`: Toast — the web's `useToast()` (`toast`, `success`, `error`, `warning`, `info`, `update`, `dismiss`, `isActive`) with its options, hosted by `UIProvider` (new prop `toast` for the defaults: `position`, `autoClose`, `limit`, `newestOnTop`…). A finger on a toast pauses it, a swipe dismisses it; while a Dialog is open the toasts are drawn in it. Also exported: `ToastHost`, `ToastItem` and the types.
|
|
143
|
+
- 1717c0a: `@dcs-tech/ui-native`: `Checkbox`, `CheckboxGroup`, `Radio`, `RadioGroup` and `Switch`, with the web toggles' sizes, variants, colours, label positions, help and error, indeterminate state, custom marks, track text, thumb icons, state labels and loading. The same change event as every field; `onCheckedChange` for the new state alone. `useToggleSurface()` reads the toggles' settings from a FieldProvider.
|
|
144
|
+
- b9b7cf1: New package `@dcs-tech/ui-native`: React Native components on the same tokens, icon drawings and logic as `@dcs-tech/ui`. This first release has `Icon` (every library icon, with sizes, tones, weights with optical sizing, duotone, filled, done, badges and marks; `IconSwap`, `createIcon`, `IconProvider`, `useIconDone` and one component per icon, named as on the web), `Button` (the web Button's variants, sizes, colours, shapes and loading positions, with press feedback for touch) and `UIProvider` / `useTokens` (light, dark or the device's scheme, and reduced motion). Peers: `react` 19.3+, `react-native` 0.88+ (Expo SDK 58), `react-native-svg` 15.16+. It works in Expo and bare apps alike. The icons do not animate yet. It joins the fixed version group, so it shares its version with `@dcs-tech/tokens`, `@dcs-tech/core` and `@dcs-tech/ui`.
|
|
145
|
+
|
|
146
|
+
### Patch Changes
|
|
147
|
+
|
|
148
|
+
- c4b14d4: Dialog: stays above the keyboard on Android too. A dialog or sheet with a text field was covered by the keyboard on Android (its buttons out of reach); it now moves up on both platforms. On iOS a dialog also lost its room clear of the system bars at its bottom; it keeps it.
|
|
149
|
+
- 414fb1f: DataTable: the layout is one toolbar button, as on the web — the current layout's icon and a ▾ (its name too, wider than a phone) — opening the view's layouts in a menu under it, the current one ticked. It was a button per layout.
|
|
150
|
+
- b673e6f: `@dcs-tech/ui-native`, checked on an Android phone:
|
|
151
|
+
- Button: the web's press wave (from the finger, sized by core's `rippleGeometry`, growing and fading as on the web) replaces Android's system ripple, and now shows on iOS too. The pressed look is held at least `--duration-short`, so a quick tap is seen.
|
|
152
|
+
- Checkbox, Radio, Switch: the halo is round on Android (it drew square), and the web's wave plays on it from its centre; `ripple={false}` turns it off on Checkbox and Radio.
|
|
153
|
+
- DataTable: on a phone the cards stack one per line (they were squeezed side by side), wider screens measure the room the cards really have, a card's fields go two by two as on the web, and the toolbar's search no longer leaves a gap under it.
|
|
154
|
+
- Updated dependencies [c9eb745]
|
|
155
|
+
- Updated dependencies [c9eb745]
|
|
156
|
+
- Updated dependencies [3ead527]
|
|
157
|
+
- Updated dependencies [9194df8]
|
|
158
|
+
- Updated dependencies [218e6be]
|
|
159
|
+
- Updated dependencies [c9eb745]
|
|
160
|
+
- Updated dependencies [c9eb745]
|
|
161
|
+
- Updated dependencies [c9eb745]
|
|
162
|
+
- Updated dependencies [c9eb745]
|
|
163
|
+
- Updated dependencies [c9eb745]
|
|
164
|
+
- Updated dependencies [c9eb745]
|
|
165
|
+
- Updated dependencies [c9eb745]
|
|
166
|
+
- Updated dependencies [c9eb745]
|
|
167
|
+
- Updated dependencies [c9eb745]
|
|
168
|
+
- Updated dependencies [c9eb745]
|
|
169
|
+
- Updated dependencies [c9eb745]
|
|
170
|
+
- Updated dependencies [deefd41]
|
|
171
|
+
- Updated dependencies [f16579c]
|
|
172
|
+
- Updated dependencies [1bfd3c5]
|
|
173
|
+
- Updated dependencies [992ea58]
|
|
174
|
+
- Updated dependencies [2b05857]
|
|
175
|
+
- Updated dependencies [2002e5a]
|
|
176
|
+
- Updated dependencies [fea8491]
|
|
177
|
+
- Updated dependencies [246354f]
|
|
178
|
+
- Updated dependencies [00f61d1]
|
|
179
|
+
- Updated dependencies [a1edb61]
|
|
180
|
+
- Updated dependencies [7649405]
|
|
181
|
+
- Updated dependencies [c9eb745]
|
|
182
|
+
- Updated dependencies [c9eb745]
|
|
183
|
+
- Updated dependencies [c9eb745]
|
|
184
|
+
- Updated dependencies [3357a5b]
|
|
185
|
+
- @dcs-tech/core@0.15.0
|
|
186
|
+
- @dcs-tech/tokens@0.15.0
|
package/README.md
CHANGED
|
@@ -1,3 +1,180 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dcs-tech/ui-native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React Native components of the DCS Tech UI library. They are drawn from the same design tokens
|
|
4
|
+
(`@dcs-tech/tokens`), icon drawings and UI logic (`@dcs-tech/core`) as the web components
|
|
5
|
+
(`@dcs-tech/ui`), so a button or an icon looks and behaves alike on both. This is a separate
|
|
6
|
+
package from `@dcs-tech/ui`: it shares no component code with it and has its own peers.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @dcs-tech/ui-native react-native-svg
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
| Peer | Version |
|
|
13
|
+
|---|---|
|
|
14
|
+
| `react` | 19.3 or later |
|
|
15
|
+
| `react-native` | 0.88 or later (Expo SDK 58) |
|
|
16
|
+
| `react-native-svg` | 15.16 or later (included in Expo) |
|
|
17
|
+
| `react-native-safe-area-context` | 5 or later (included in Expo) |
|
|
18
|
+
| `@react-native-async-storage/async-storage` | Optional, 2 or later (included in Expo Go): where a DataTable keeps the user's choices when the app passes no `persistence` |
|
|
19
|
+
|
|
20
|
+
It works the same in Expo and in bare React Native apps: it uses only `react-native`,
|
|
21
|
+
`react-native-svg` and `react-native-safe-area-context` (a Dialog measures the system bars with it;
|
|
22
|
+
the app needs no `SafeAreaProvider` for that).
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { Button, IconAdd, UIProvider } from '@dcs-tech/ui-native';
|
|
26
|
+
|
|
27
|
+
<UIProvider theme="system">
|
|
28
|
+
<Button variant="filled" startIcon={<IconAdd />} onPress={add}>Add</Button>
|
|
29
|
+
</UIProvider>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## What is in it
|
|
33
|
+
|
|
34
|
+
| Export | What it is |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `UIProvider` | Optional. `theme` (`'light'`, `'dark'` or `'system'`, the default), `icons` (icon defaults), `labels` (the library's words, the same dictionary as the web's, `table` included), and `messages` + `locale` (language packs, the web's: `import ta from '@dcs-tech/ui-native/locales/ta'`, `<UIProvider locale="ta-IN" messages={[ta]}>`; per word the exact locale's pack, then its language's, then English; `locale` is also the DataTable's default locale and the DatePicker's month and weekday names), `dateFormat` (how every DatePicker shows a day unless it sets `displayFormat`, the web's) for the tree below, and `toast` (toast defaults); it also hosts `useDialog()` and `useToast()`. Put it at the app's root: the toasts are drawn over the view it sits in. |
|
|
37
|
+
| `useTokens()` | The design tokens in force: the light or dark set, with the motion tokens zeroed when the device asks for reduced motion. For an app's own styles too. |
|
|
38
|
+
| `Icon`, `IconSwap`, `createIcon`, `IconProvider`, `useIconDone` | Icons, as on the web. |
|
|
39
|
+
| `IconAdd`, `IconFilter`, … | One component per icon in `@dcs-tech/core`, the same names as the web's. |
|
|
40
|
+
| `Button` | The web Button's variants, sizes, colours and shapes, pressed with a finger. |
|
|
41
|
+
| `useUILabels()` | The library's words as the nearest `UIProvider` set them. |
|
|
42
|
+
| `useUILocale()` | The nearest `UIProvider`'s `locale`, or undefined (the device's). |
|
|
43
|
+
| `useUIDateFormat()` | The nearest `UIProvider`'s `dateFormat`, or undefined (dd-mm-yyyy). |
|
|
44
|
+
| `FieldProvider`, `useFieldSurface()` | Size, variant, layout, disabled and read-only for every field below; a field's own prop wins. |
|
|
45
|
+
| `FieldWrapper` | The label, help and error around a control: the same look for a control of your own. |
|
|
46
|
+
| `Input` | A text field: sizes, variants, layouts, prefix and suffix, icons, clear button, password eye, character count. |
|
|
47
|
+
| `Checkbox`, `CheckboxGroup` | A checkbox, and several that make one list of values. |
|
|
48
|
+
| `Radio`, `RadioGroup` | One choice out of several. |
|
|
49
|
+
| `Switch` | On / off, with track text, thumb icons, state labels and a loading state. |
|
|
50
|
+
| `useToggleSurface()` | The toggles' size, variant, disabled and read-only, from a FieldProvider. |
|
|
51
|
+
| `Select` | A choice from a list: the field, and its list as a sheet from the bottom of the screen — searched, grouped, one value or several. |
|
|
52
|
+
| `DatePicker` | A date (with a time, if asked), a month or a year, or a range of two: typed, or picked in a sheet from the bottom, with the web's presets. |
|
|
53
|
+
| `Calendar` | One month's days, the DatePicker's grid. |
|
|
54
|
+
| `Suggest` | A text field that suggests as you type, with the list under the field: the web's search engines and rows. |
|
|
55
|
+
| `Dialog` | A dialog, or a sheet from any edge, over a dimmed screen: title, subtitle, a scrolling body, a footer of actions. |
|
|
56
|
+
| `useDialog()`, `DialogHost` | Ask and wait: `confirm`, `choose`, `alert`, as on the web. UIProvider hosts them. |
|
|
57
|
+
| `useDialogOpen()` | Whether a library dialog is open, for an app's own overlay to step aside. |
|
|
58
|
+
| `useToast()`, `ToastHost`, `ToastItem` | Toasts: `toast`, `success`, `error`, `warning`, `info`, `update`, `dismiss`, as on the web. UIProvider hosts them; while a Dialog is open they are drawn in it. |
|
|
59
|
+
| `DataTableScrollView` | A ScrollView for the screen a DataTable sits in: a drag to select holds it still and scrolls it at its edges. |
|
|
60
|
+
| `DataTable` | The web DataTable's `views` / `columns` config on a phone: the views as tabs, a search, a sort, the rows as cards or a split list, a pager, and a row opening in a sheet (beside the list in a wide split view); from `data`, or from a `dataSource` with the web's query. |
|
|
61
|
+
|
|
62
|
+
The logic, types and drawings come from `@dcs-tech/core` (`import { addIcon } from '@dcs-tech/core'`),
|
|
63
|
+
the token values from `@dcs-tech/tokens`.
|
|
64
|
+
|
|
65
|
+
## Same as the web, and not
|
|
66
|
+
|
|
67
|
+
A prop marked **same** takes the same values and does the same thing as on `@dcs-tech/ui`.
|
|
68
|
+
|
|
69
|
+
**Icon**
|
|
70
|
+
|
|
71
|
+
| | Props |
|
|
72
|
+
|---|---|
|
|
73
|
+
| Same | `icon`, `size`, `tone`, `filled`, `weight` (with optical sizing), `variant` (`duotone`), `duotoneTone`, `label`, `done`, `badge`, `badgeTone`, `badgeMax`, `badgeLabel`, `mark`, `markTone`; `createIcon`, `IconSwap`, `IconProvider`, `useIconDone`, the per-icon components |
|
|
74
|
+
| Adapted | `color`: any colour, where the web takes the CSS colour around it. With no `size`, an icon is the size of the slot it sits in (a Button's, a field's: the same `--icon-slot-*` tokens), else the default slot, 16 — as on the web. `size="inherit"` is the body text's size (the web: `1em` of the text around it). The library's line icons get the web's live-area margin (`iconInset`). `useIconDone` speaks through the screen reader's announcement. |
|
|
75
|
+
| Not yet | the motion: `appear`, `animate`, `motion`, `animateChanges`, `press`. Icons are still, except a spinning one (the loader), which turns. The brand marks (0.14.0: WhatsApp, Google, Visa, … and their mono forms; colour fills from the brand tokens, gradients, a brand's own artwork) have no component yet. |
|
|
76
|
+
| Web only | SVG and DOM attributes, `className` |
|
|
77
|
+
|
|
78
|
+
**Button**
|
|
79
|
+
|
|
80
|
+
| | Props |
|
|
81
|
+
|---|---|
|
|
82
|
+
| Same | `children` / `label`, `startIcon`, `endIcon`, `icon`, `variant`, `size`, `color`, `shape`, `disabled`, `loading`, `loadingPosition`, `loadingIndicator`, `fullWidth`, `disableTextTransform`, `disableElevation`, `aria-label`, `aria-expanded` |
|
|
83
|
+
| Adapted | `onPress` / `onLongPress` for `onClick`. `feedback`: every press shows the pressed colours (the web's `:active`), held at least `--duration-short` so a quick tap is seen; `'ripple'` adds the web's wave (from the finger, sized by core's `rippleGeometry`, on Android and iOS alike), `'press'` a press-down. The loader is the platform's. |
|
|
84
|
+
| Not yet | `ButtonGroup`, `tooltip` (a long-press tooltip comes with the Tooltip component) |
|
|
85
|
+
| Web only | links (`href`, `target`, `rel`, `download`), forms (`type`, `name`, `value`), `component`, hover, the focus ring, `autoFocus`, `tabIndex`, `className` |
|
|
86
|
+
|
|
87
|
+
**FieldProvider, FieldWrapper**
|
|
88
|
+
|
|
89
|
+
| | Props |
|
|
90
|
+
|---|---|
|
|
91
|
+
| Same | `size`, `variant`, `layout` (`horizontal` is the default, and puts the label on top below 640 wide, as on the web), `disabled`, `readOnly`; `label`, `hint`, `error`, `required`, `width` |
|
|
92
|
+
| Adapted | `focused` on FieldWrapper: the web follows `:focus-within`, here the field says so. `width` takes a number or a percentage; another CSS length (`12rem`) is ignored. |
|
|
93
|
+
| Not yet | `tooltip` (with the Tooltip component), `keyboard` (a grid's arrow-key rules) |
|
|
94
|
+
| Web only | `className`, `labelClassName` |
|
|
95
|
+
|
|
96
|
+
**Input**
|
|
97
|
+
|
|
98
|
+
| | Props |
|
|
99
|
+
|---|---|
|
|
100
|
+
| Same | `name`, `value`, `onChange` (the same `{ target: { name, value, type } }` event), `type` (`text`, `number`, `email`, `password`, `tel`, `url`, `search`), `label`, `placeholder`, `hint`, `error`, `required`, `disabled`, `readOnly`, `autoFocus`, `maxLength`, `showCharCount`, `clearable`, `prefix`, `suffix`, `icon`, `multiline`, `rows`, `size`, `variant`, `layout`, `width`, `inputMode`, `spellCheck`, `aria-label` |
|
|
101
|
+
| Adapted | `defaultValue` and `onChangeText` as well (the web is controlled only). Each `type` picks a phone keyboard. `ref` has `focus({ select, caret })`, `blur()` and `element` (the text box). `returnKeyType` / `onSubmitEditing` for the keyboard's return key. A multi-line field is at least `rows` lines (3) of text tall, where the web uses a fixed 80px. |
|
|
102
|
+
| Not yet | moving to the next field from the return key, a Button in `icon` that keeps the field's height |
|
|
103
|
+
| Web only | `type` `date`, `time`, `color`, `file` and the rest (a date picker comes later), `min` / `max` / `step` / `pattern`, `resize`, `formData`, the grid-cell props, the class names |
|
|
104
|
+
|
|
105
|
+
**Checkbox, Radio, Switch** (and the two groups)
|
|
106
|
+
|
|
107
|
+
| | Props |
|
|
108
|
+
|---|---|
|
|
109
|
+
| Same | `name`, `value`, `checked`, `defaultChecked`, `onChange` (`{ target: { name, value, type, checked } }`), `label`, `hint`, `error`, `required`, `labelPosition`, `disabled`, `readOnly`, `size`, `variant` (Checkbox, Radio), `color`, `fullWidth`, `aria-label`; Checkbox `indeterminate`, `checkedIcon` / `uncheckedIcon` / `indeterminateIcon`, `ripple`; Radio `checkedIcon` / `uncheckedIcon`, `ripple`; Switch `onText` / `offText`, `onIcon` / `offIcon`, `labelOn` / `labelOff`, `stateLabelMode`, `justSwitch`, `loading`, `loadingIndicator`, `animated`; the groups' `name`, `value`, `onChange`, `label`, `helperText`, `error`, `orientation`, `required`, `size`, `variant`, `color`, `disabled`, `readOnly` (RadioGroup also `onChangeEvent`) |
|
|
110
|
+
| Adapted | `onCheckedChange` on Checkbox and Switch, for the new state alone. The halo shows while pressed, where the web shows it on hover and keyboard focus; the press wave plays on it from its centre, as on the web (`ripple` on Checkbox and Radio turns it off). A loading Switch shows the platform's loader in the switch's colour (the web's draws in the thumb's own colour, so it does not show). The groups' `defaultValue` works (the web declares it but does not read it). |
|
|
111
|
+
| Not yet | the tick and dot animating in |
|
|
112
|
+
| Web only | `showFocusRing`, `tabIndex`, `autoFocus`, the ref, the class names, `keyboard` and the grid-cell props |
|
|
113
|
+
|
|
114
|
+
**Select**
|
|
115
|
+
|
|
116
|
+
| | Props |
|
|
117
|
+
|---|---|
|
|
118
|
+
| Same | `name`, `options`, `value`, `onChange` (`{ target: { name, value, type: 'select' } }`), `label`, `hint`, `error`, `required`, `defaultText`, `disabled`, `readOnly`, `size`, `variant`, `layout`, `width`, `clearable`, `multiSelect` (`maxSelection`, `minSelection`, `alwaysDisabled`, `defaultSelected`, `showSelectAll`, `maxDisplayItems`), `search` (on by default), `sort` (on by default), `group`, `emptyState`, `loading`, `renderOption`, `renderSelectedValue`, `open` / `defaultOpen` / `onOpenChange`, `onOpen`, `onClose`, `onSearch`, `onSelect`, `onDeselect`, `onClear`, `aria-label` |
|
|
119
|
+
| Adapted | The list is a sheet from the bottom of the screen, with a title, a close button (single) or OK (several). `autoFocusSearch` is off by default: the phone's keyboard would come up over the list. `defaultValue` and `placeholder` as well. The count text ("3 items selected") is `labels.select.itemsSelected`. |
|
|
120
|
+
| Not yet | `reorder`, `renderTrigger`, `renderChip`, `multiSelect.displayFormat` (declared on the web, not drawn there either) |
|
|
121
|
+
| Web only | `position`, `listWidth`, `virtualScroll` (a phone list scrolls by itself), `keyboard`, the class names, `parentDivStyle`, the grid-cell props |
|
|
122
|
+
|
|
123
|
+
**DatePicker**
|
|
124
|
+
|
|
125
|
+
| | Props |
|
|
126
|
+
|---|---|
|
|
127
|
+
| Same | `name`, `value` (`yyyy-mm-dd`, or `{ from, to }` with `range`), `onChange` (`{ target: { name, value, type: 'date' } }`), `onApply`, `range`, `label`, `hint`, `error`, `required`, `placeholder`, `disabled`, `readOnly`, `size`, `variant`, `layout`, `width`, `min`, `max`, `yearRange`, `displayFormat`, `textOrder`, `weekStart`, `presets`, `fyStartMonth`, `monthNames`, `weekdayNames`, `clearLabel`, `applyLabel`, `showCalendarIcon`, `clearable`, `autoComplete`, `withTime` (a range's ends 00:00 and 23:59, a single date now), `timeToggle`, `picker` (`'month'` → `yyyy-mm`, `'year'` → `yyyy`: twelve cells three to a row; one press chooses and closes, a range closes on its second end; Apply on a range only with `applyLabel`), `open` / `defaultOpen` / `onOpenChange`, `aria-label` |
|
|
128
|
+
| Adapted | The panel is a sheet from the bottom, the web's phone panel: one month, the presets below the calendar two to a row, the month and year as two Selects. The return key does what Enter does (From → To → close). The time boxes go two to a row under the dates (Start time, End time), and the hour / minute / AM-PM columns open under the box in the flow while it has the focus, as on the web's phone panel; the keypad has digits only, so AM / PM is pointed at in its column (the web also reads a typed `9pm`). As on the web, `displayFormat` defaults to UIProvider's `dateFormat` (else dd-mm-yyyy), the month and weekday names come from Intl in UIProvider's `locale` (else the device's language), the words from its language pack, and `weekStart` (the grid's first column and the "This Week" preset) from `localeWeekStart` of that locale, as on the web: Monday for en-GB, Sunday for en-IN / en-US — where the device's Intl has no week info (older Hermes), Sunday. |
|
|
129
|
+
| Web only | `months`, `currentMonthSide`, `showOutsideDays` (a phone shows one month, its neighbours' days with it), `placement`, the keyboard's arrows, `keyboard`, the class names, the grid-cell props |
|
|
130
|
+
|
|
131
|
+
**Suggest**
|
|
132
|
+
|
|
133
|
+
| | Props |
|
|
134
|
+
|---|---|
|
|
135
|
+
| Same | `name`, `data`, `config` (`searchKeys`, `renderKeys` with `p` / `s` / `t` lines, labels, formatters and `hideWhenEmpty`, `maxResults`, `highlightMatches`, `groupBy`, `sortBy`, `searchEngine`, `searchMode`, `fuseThreshold`, `uniqueKey`), `value`, `onChange`, `onSelect` (item, name), `label`, `placeholder`, `hint`, `error`, `required`, `disabled`, `readOnly`, `size`, `variant`, `layout`, `width`, `minSearchLength`, `debounceMs`, `showAllOnFocus`, `openOnFocus`, `clearOnSelect`, `closeOnSelect`, `renderItem` (item, isHighlighted, searchValue), `renderGroup` |
|
|
136
|
+
| Adapted | The list sits under the field, in the layout, up to 300 points or 40% of the screen. `defaultValue` and `onChangeText` as well. A formatter's tags: `strong` is bold, `em` italic, the rest plain text; its class names and styles are web only. Inside a ScrollView, set `keyboardShouldPersistTaps="handled"` on it, or the first tap on a suggestion only puts the keyboard away. |
|
|
137
|
+
| Not yet | `renderEmptyState`, `selectFirstOnEnter` |
|
|
138
|
+
| Web only | the arrow keys and Enter, `portal`, `position`, `listWidth`, `renderInput`, `type`, the class names, the grid-cell props |
|
|
139
|
+
|
|
140
|
+
**Dialog, useDialog**
|
|
141
|
+
|
|
142
|
+
| | Props |
|
|
143
|
+
|---|---|
|
|
144
|
+
| Same | `open`, `onClose`, `onBeforeClose`, `onAnimationEnd`, `title`, `subtitle`, `footer`, `placement` (`center`, `bottom`, `right`, `left`, `top`), `size` (`sm` 420 … `xl` 960, `full`), `closeOnBackdrop`, `closeOnEscape` (Android's Back), `showCloseButton`, `closeIcon`, `animationDuration`, `padded`, `aria-label`; `useDialog().confirm` / `choose` / `alert` with their options, actions and rejections |
|
|
145
|
+
| Adapted | `onBackdropPress` for `onOverlayClick`. On a phone a centred dialog is as wide as the screen. The body scrolls; the keyboard pushes a dialog or a sheet up, on iOS and Android (its buttons stay in reach). It draws edge to edge and keeps its content clear of the status and navigation bars, measured in its own window: a sheet's panel runs behind the bar, its content above it. The questions' buttons cannot take the keyboard's focus (`focus`): a phone has none. |
|
|
146
|
+
| Not yet | `modal={false}` (a non-blocking panel), the header / footer slots, dragging a sheet away |
|
|
147
|
+
| Web only | `onEscKeyDown`, `blockScroll`, `reserveScrollBarGap`, `initialFocusRef`, `container`, `classNames`, `styleSlots`, `className`, `role`, `id` |
|
|
148
|
+
|
|
149
|
+
**Toast, useToast**
|
|
150
|
+
|
|
151
|
+
| | Props |
|
|
152
|
+
|---|---|
|
|
153
|
+
| Same | `useToast()` and its calls; the options `type`, `autoClose` (or `false`), `position`, `hideProgressBar`, `closeOnClick`, `pauseOnFocusLoss` (the app in the background), `draggable` (swipe sideways), `closeButton`, `icon`, `id` (updates in place), `onClose`; UIProvider's `toast` defaults with `newestOnTop` and `limit` |
|
|
154
|
+
| Adapted | A finger on a toast pauses it, where the web pauses on hover (`pauseOnHover`). `style` is a view style; `testID` as well. Below 600 wide a toast takes the width. The toasts are drawn over the view UIProvider sits in, clear of the system bars (those an app's `SafeAreaProvider` measured, else the window's at start); while a library Dialog is open, in the topmost one, as the web draws them in the topmost modal. An update (`update`, or the same `id`) starts its time again; moving into or out of a dialog does not. Letting go after holding a toast is not a tap. |
|
|
155
|
+
| Not yet | Over Select's sheet (its own window): a toast fired while it is open shows when it closes |
|
|
156
|
+
| Web only | `pauseOnHover`, `className` |
|
|
157
|
+
|
|
158
|
+
**DataTable**
|
|
159
|
+
|
|
160
|
+
It takes the web's props (`DataTableProps` from `@dcs-tech/core`), so one config serves both
|
|
161
|
+
apps. The rows are found, sorted and paged by the web table's rules (`@dcs-tech/core`'s
|
|
162
|
+
`clientRows`, `sortRows`, `rankText`).
|
|
163
|
+
|
|
164
|
+
| | Props |
|
|
165
|
+
|---|---|
|
|
166
|
+
| Same | `data`, `dataSource` (`fetchRows`, `subscribe`, `searchDebounceMs`), `views` (tabs; `authorized`, `defaultVisible`), `labels` (over UIProvider's `labels.table` and its language pack's), `locale` (else UIProvider's), `initialState` (view, search, sort, page, page size), `onStateChange` (the web's query), `renderDetail` (and a view's own), `detailBar`, `openRowId`, `onOpenRowChange`. A view's `columns`, `resolveColumns`, `rowKey`, `params`, `transform`, `search`, `sorting` (`defaultSort`), `pagination` (`pageSize`, `pageSizeOptions`), `layouts` / `defaultLayout` (`cards`, `split`), `cardFields`, `listFields`, `cardMinWidth`, `cardsExpanded`, `avatar`, `actions` (`label`, `icon`, `onClick`, `variant`, `primary`, `showWhen`, `disabledWhen`, `disableTextTransform`), `rowMenu` (`enabled`, `onOpen`, `openView`, `openHeader`, `openSubheader`, `openFooter`, `items`, `iconActions`, `longPress`, `builtIns`), `emptyMessage`, `noResultsMessage`, `loading`, `loadingMessage`, `swipeActions` (`right`, `left`, `fullSwipe`), `filtering` (`quickFilters`, `quickFilterMode`, `quickFilterLabel`, `defaultFilter`; `false` for none), `selection` (`true` / `onDemand`, `always`, `false`, or `mode`, `isSelectable`, `onSelectionChange`, `show`), `bulkActions` and `hideBulkActions`. Which actions are buttons and what the menu lists are core's rules (`inlineActionsOf`, `rowMenuEntries`). The table's `bulkActions` (`label`, `icon`, `variant`, `display`, `views`, `authorize`, `eligible`, `minSelected`, `maxSelected`, `allowAllMatching`, `confirm` with its `message`, `confirmLabel`, `danger` and `input`, `undoTimeoutMs`, `onRun` and what it returns), run by core's rules (`planBulkAction`, `summarizeBulkResult`): the eligible and skipped rows, the limits, the confirm, the result line, Undo, keeping or letting go of the selection, server mode fetching again. `authorize` for its `selection` and `bulkAction` gates. The filter is the web's one filter, by core's rules (`evaluateGroup`, `quickFilterGroup`, `valueFilterEntries`): a quick filter replaces it, a chip's ✕ or the row menu's Filter by (Only / Add / Hide) change it by hand and the quick filter it came from goes off; it goes in the query in server mode (`filterGroup`, `quickFilterIds`). The status row under the toolbar: the bulk buttons, "3 selected", Select all (N matching), Clear, the sort's chips, the filter's chips, the default order, the summary ("Showing all 48 rows"); the row menu's Select / Unselect (`builtIns`). A column's `header`, `type`, `value`, `field`, `format`, `numberFormat`, `dateFormat`, `options`, `searchText`, `sortValue`, `compare`, `sortable`, `authorized`, `dataOnly`, `exportValue`. |
|
|
167
|
+
| Adapted | The row menu is a bottom sheet (the web's on a phone), opened by ⋮ or a long-press; its icons show their short labels. Where the view has bulk actions, a long-press ticks the row instead (starting to select, as a phone's lists do; the web's opens the menu, and the menu stays on ⋮); while selecting, a tap ticks / unticks a row. Swipe actions, a phone's own (the web has none): a card or list item swiped sideways shows the actions the view names in `swipeActions` behind it, in their colours; let go past half of them it stays open, a tap runs one, a tap on the row closes it; a long swipe runs the outermost one, which stretches across first (never a dangerous one, nor with `fullSwipe: false`); one row open at a time, none while selecting. Drag to select, a phone's own (the web has none): after that long-press, moving the finger without lifting it ticks every row from there to the one under it, and moving back unticks them; put the table in a `DataTableScrollView` (a ScrollView of the library's, the same props) and the drag holds it still and scrolls it near its top and bottom edges (beside a pane, the split list scrolls on its own). A bulk action's reason for being disabled and its `tooltip` are read out by a screen reader (no hover). Its result shows at the bottom in the app's toast (`useToast`, UIProvider's), else in one of the table's own. A view change lets go of the selection. The checkbox is the library Checkbox (16; the web's card one is 18). A card shows its first `primary` action with its icon and label, a list item that action's icon, as the web's defaults (Display's choices are not drawn yet). An action's `icon`, a menu item's and an icon action's `icon`, a column's `cell`, a view's `avatar`, `renderDetail` and `rowMenu.openView` / `openHeader` / `openFooter` return what the platform draws: give native nodes on a phone (text alone works on both). The table layout is not drawn: a view that offers only `table` shows cards, and dynamic columns (`resolveColumns`) show cards. A row opens in a sheet from the bottom on a phone (the web goes full screen) and from the right wider (the web's drawer, as wide); in a split view 768 or wider, in the pane beside the list. The sort is chosen in a sheet, one column at a time (a view's `defaultSort` of several still sorts by all of them). The layout is one button, as the web's (its icon and a ▾; its name too wider than a phone, where the web's is the icon and ▾ on every size), opening the view's layouts in a menu under it; the web's Columns / Card fields / List fields button after it is not drawn yet. The filter builder (the toolbar's Filters, with its count, or a filter chip) is the web's Filters dialog as a sheet from the bottom, in its phone layout: AND / OR, nested groups with NOT, each condition's column, operator and value one under another (a date's value is the DatePicker, one date or a range), the JSON folded away, Clear all / Cancel / Apply; a value's options are the column's `filterOptions`, else the distinct values of the rows (client mode) the search and the sheet's other conditions keep, as the web's: every condition on the column itself counts as passed, an OR group holding one included (core `valueListRows`). Saved filters, as the web's: the builder's list to load one from (★ the view's quick filters, 🔖 the user's, with their count of conditions and 🗑), Update and Save as new beside it, the name box under it; the user's are offered with the quick filters (⚡) too, and are kept with the view's preferences; `authorize('savedFilters')` false: they may be loaded, not saved or deleted. The user's choices (the layout, saved filters) are kept as the web's: with a `tableId`, in the same document (`<tableId>.<viewId>`) through the same `persistence` adapter, so an app's adapter (its server) gives the same choices on the web and the phone; the parts the phone does not draw (columns, export, summary, …) are kept as they are. Without `persistence` the phone's default is the device (`asyncStorageAdapter` over AsyncStorage, the web's localStorage) when the app has AsyncStorage installed, else memory until the app reloads; `null` keeps nothing. `prefsVersion` / `migratePrefs`, `renamedViews` and the one-time notice of a repair as the web's. The page size is the view's (no size picker yet). A row is pressed where the web clicks; there is no hover. Choices (layout, sort, page) last while the table is mounted (`persistence` is not read yet). |
|
|
168
|
+
| Not yet | export, a whole group selected (grouping is not drawn), `DataTableApi.clearSelection`, the row menu's built-in Copy, Select, Only / Hide and Open in new tab (they come with a clipboard module, selection and filters), the summary (a breakdown card's `order` / `showEmpty` are core's rules, `orderBreakdown` and `emptyListedBuckets`, ready for it), grouping, tree data, pivot, row styles (`rowStyles` / `rowStyle`), cell charts, rows animating in and out and cell flashes, `pinnedRows`, transactions (`apiRef`), counts on the view tabs, Manage views & templates, Display settings, the card / list fields editors, `HeaderComponent` / `FooterComponent`, `expandRow`, `sharing`, `authorize`, `virtualize` |
|
|
169
|
+
| Web only | the table layout's grid (columns, widths, pinning, resizing, keyboard navigation, cell selection, `inlineActions`, the header checkbox and so `selection.headerSelects`: on a phone "Select all" is the status row's, which ticks every row found as the web's offer does), an action's `shortcut` and `tooltip`, `className`, the keyboard shortcuts, `getRowHref` / opening in a new tab |
|
|
170
|
+
|
|
171
|
+
Text uses the platform's font: the tokens name the web font, which an app loads itself if it
|
|
172
|
+
wants it.
|
|
173
|
+
|
|
174
|
+
## Rules for code here
|
|
175
|
+
|
|
176
|
+
- Styles use only the tokens, through `useTokens()`. A value the web writes out in its CSS
|
|
177
|
+
because it has no token (the disabled fade, the label's letter spacing) is written out here
|
|
178
|
+
too, as a named constant beside the style that uses it.
|
|
179
|
+
- A calculation or "given X decide Y" that is not about drawing goes in `@dcs-tech/core`.
|
|
180
|
+
- Every component has a `*.stories.tsx` next to it, and tests under `__tests__`.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useMemo } from 'react';
|
|
3
|
+
import { ActivityIndicator, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
4
|
+
import { resolveButtonColor } from '@dcs-tech/core';
|
|
5
|
+
import { useTokens } from '../UIProvider/context';
|
|
6
|
+
import { IconSlotContext } from '../Icon/IconContext';
|
|
7
|
+
import { buttonLook } from './buttonStyle';
|
|
8
|
+
import { usePressHold, useRipple } from '../Press';
|
|
9
|
+
export const Button = forwardRef(function Button({ children, label, startIcon, endIcon, icon, onPress, onLongPress, disabled = false, loading = false, loadingPosition = 'center', loadingIndicator, variant = 'elevated', size = 'small', color: colorProp, shape = 'rounded', fullWidth = false, disableTextTransform = false, disableElevation = false, feedback = 'ripple', style, testID, 'aria-label': ariaLabel, 'aria-expanded': ariaExpanded, accessibilityHint, }, ref) {
|
|
10
|
+
const t = useTokens();
|
|
11
|
+
const loneIcon = icon ?? (startIcon && !endIcon ? startIcon : endIcon && !startIcon ? endIcon : undefined);
|
|
12
|
+
const content = children ?? label;
|
|
13
|
+
const hasLabel = content !== undefined && content !== null && content !== false && content !== '';
|
|
14
|
+
const iconOnly = !!loneIcon && !hasLabel;
|
|
15
|
+
const leadIcon = startIcon ?? (!iconOnly ? icon : undefined);
|
|
16
|
+
const color = resolveButtonColor(colorProp, iconOnly);
|
|
17
|
+
const inactive = disabled || loading;
|
|
18
|
+
const options = { variant, size, color, shape, iconOnly, disabled, fullWidth, disableTextTransform, disableElevation, pressDown: feedback === 'press' };
|
|
19
|
+
const rest = buttonLook(t, { ...options, pressed: false });
|
|
20
|
+
const slot = useMemo(() => ({ size: rest.iconSize, color: rest.fg }), [rest.iconSize, rest.fg]);
|
|
21
|
+
const loader = loadingIndicator ?? _jsx(ActivityIndicator, { size: "small", color: rest.fg });
|
|
22
|
+
const covers = loading && (loadingPosition === 'center' || loadingPosition === 'overlay');
|
|
23
|
+
const hold = usePressHold(!inactive);
|
|
24
|
+
const ripple = useRipple({ color: rest.fg, enabled: feedback === 'ripple' && !inactive }, rest.container.borderRadius);
|
|
25
|
+
const pressed = hold.pressed;
|
|
26
|
+
const setRef = useCallback((node) => {
|
|
27
|
+
ripple.ref.current = node;
|
|
28
|
+
if (typeof ref === 'function')
|
|
29
|
+
ref(node);
|
|
30
|
+
else if (ref)
|
|
31
|
+
ref.current = node;
|
|
32
|
+
}, [ref, ripple.ref]);
|
|
33
|
+
const renderBody = (fg) => {
|
|
34
|
+
if (iconOnly)
|
|
35
|
+
return loneIcon;
|
|
36
|
+
const text = typeof content === 'string' || typeof content === 'number'
|
|
37
|
+
? _jsx(Text, { style: fg === rest.fg ? rest.text : [rest.text, { color: fg }], children: content })
|
|
38
|
+
: content;
|
|
39
|
+
return (_jsxs(_Fragment, { children: [loading && loadingPosition === 'start' ? loader : leadIcon, text, loading && loadingPosition === 'end' ? loader : endIcon] }));
|
|
40
|
+
};
|
|
41
|
+
return (_jsx(Pressable, { ref: setRef, testID: testID, onPress: onPress, onPressIn: e => { hold.onPressIn(); ripple.onPressIn(e); }, onPressOut: () => { hold.onPressOut(); ripple.onPressOut(); }, onLongPress: onLongPress, disabled: inactive, role: "button", "aria-label": ariaLabel, accessibilityHint: accessibilityHint, accessibilityState: { disabled: inactive, busy: loading, expanded: ariaExpanded }, style: [pressed ? buttonLook(t, { ...options, pressed }).container : rest.container, style], children: (() => {
|
|
42
|
+
const fg = pressed ? buttonLook(t, { ...options, pressed }).fg : rest.fg;
|
|
43
|
+
return (_jsxs(IconSlotContext.Provider, { value: fg === rest.fg ? slot : { ...slot, color: fg }, children: [_jsx(View, { style: [styles.content, { gap: rest.gap }, covers && styles.hidden], children: renderBody(fg) }), covers && _jsx(View, { style: styles.cover, children: loader }), ripple.layer] }));
|
|
44
|
+
})() }));
|
|
45
|
+
});
|
|
46
|
+
Button.displayName = 'Button';
|
|
47
|
+
const styles = StyleSheet.create({
|
|
48
|
+
content: {
|
|
49
|
+
flexDirection: 'row',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
justifyContent: 'center',
|
|
52
|
+
},
|
|
53
|
+
hidden: {
|
|
54
|
+
opacity: 0,
|
|
55
|
+
},
|
|
56
|
+
cover: {
|
|
57
|
+
...StyleSheet.absoluteFill,
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
justifyContent: 'center',
|
|
60
|
+
},
|
|
61
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { CAPS_LETTER_SPACING, DISABLED_OPACITY } from '../styles/webValues';
|
|
2
|
+
const BORDER_WIDTH = 1;
|
|
3
|
+
export function buttonColors(t, color) {
|
|
4
|
+
switch (color) {
|
|
5
|
+
case 'primary': return { text: t.accentPrimaryText, solid: t.accentPrimary, strong: t.accentPrimaryHover, light: t.accentPrimaryLight, on: t.onPrimary };
|
|
6
|
+
case 'secondary': return { text: t.accentSecondaryText, solid: t.accentSecondary, strong: t.accentSecondaryHover, light: t.accentSecondaryLight, on: t.onSecondary };
|
|
7
|
+
case 'success': return { text: t.successText, solid: t.success, strong: t.successHover, light: t.successLight, on: t.onSuccess };
|
|
8
|
+
case 'error': return { text: t.errorText, solid: t.error, strong: t.errorHover, light: t.errorLight, on: t.onError };
|
|
9
|
+
case 'warning': return { text: t.warningText, solid: t.warning, strong: t.warningHover, light: t.warningLight, on: t.onWarning };
|
|
10
|
+
case 'info': return { text: t.infoText, solid: t.info, strong: t.infoHover, light: t.infoLight, on: t.onInfo };
|
|
11
|
+
case 'neutral': return { text: t.textSecondary, solid: t.textSecondary, strong: t.textPrimary, light: t.bgTertiary, outline: t.borderHover };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function buttonSize(t, size) {
|
|
15
|
+
switch (size) {
|
|
16
|
+
case 'xxs': return { padY: t.spacingXs, padX: t.spacingMd, fontSize: t.fontSizeXxs, height: t.fieldHeightXxs, gap: t.spacingXs, iconPad: t.spacingXs, iconStep: t.iconSlotDense };
|
|
17
|
+
case 'xs': return { padY: t.spacingXs, padX: t.spacingLg, fontSize: t.fontSizeXs, height: t.fieldHeightXs, gap: t.spacingXs, iconPad: t.spacingXs, iconStep: t.iconSlotDense };
|
|
18
|
+
case 'small': return { padY: t.spacingSm, padX: t.spacingLg, fontSize: t.fontSizeSm, height: t.fieldHeightSm, gap: t.spacingSm, iconPad: t.spacingSm, iconStep: t.iconSlotButton };
|
|
19
|
+
case 'medium': return { padY: t.spacingMd, padX: t.spacingXl, fontSize: t.fontSizeMd, height: t.fieldHeightMd, gap: t.spacingMd, iconPad: t.spacingMd, iconStep: t.iconSlotButton };
|
|
20
|
+
case 'large': return { padY: t.spacingLg, padX: t.spacingXl, fontSize: t.fontSizeLg, height: t.fieldHeightLg, gap: t.spacingLg, iconPad: t.spacingLg, iconStep: t.iconSlotProminent };
|
|
21
|
+
case 'xl': return { padY: t.spacingLg, padX: t.spacingXl + t.spacingMd, fontSize: t.fontSizeXl, height: t.fieldHeightXl, gap: t.spacingLg, iconPad: t.spacingLg, iconStep: t.iconSlotProminent };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export const boxShadow = (shadow) => shadow.map(s => ({ offsetX: s.offsetX, offsetY: s.offsetY, blurRadius: s.blur, spreadDistance: s.spread, color: s.color, inset: s.inset }));
|
|
25
|
+
export function withAlpha(color, alpha) {
|
|
26
|
+
const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color)?.[1];
|
|
27
|
+
if (!hex)
|
|
28
|
+
return color;
|
|
29
|
+
const full = hex.length === 3 ? [...hex].map(c => c + c).join('') : hex;
|
|
30
|
+
const n = parseInt(full, 16);
|
|
31
|
+
return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;
|
|
32
|
+
}
|
|
33
|
+
export function buttonLook(t, o) {
|
|
34
|
+
const c = buttonColors(t, o.color);
|
|
35
|
+
const s = buttonSize(t, o.size);
|
|
36
|
+
const shape = o.iconOnly && o.shape === 'rounded' ? 'circle' : o.shape;
|
|
37
|
+
const pressed = o.pressed && !o.disabled;
|
|
38
|
+
const onSolid = c.on ?? t.bgPrimary;
|
|
39
|
+
let bg = 'transparent';
|
|
40
|
+
let fg = c.text;
|
|
41
|
+
let border;
|
|
42
|
+
let shadow;
|
|
43
|
+
switch (o.variant) {
|
|
44
|
+
case 'filled':
|
|
45
|
+
bg = pressed ? c.strong : c.solid;
|
|
46
|
+
fg = onSolid;
|
|
47
|
+
shadow = pressed ? t.shadowMd : t.shadowSm;
|
|
48
|
+
break;
|
|
49
|
+
case 'outlined':
|
|
50
|
+
if (pressed)
|
|
51
|
+
bg = c.light;
|
|
52
|
+
border = pressed ? c.strong : c.outline ?? c.solid;
|
|
53
|
+
break;
|
|
54
|
+
case 'text':
|
|
55
|
+
if (pressed)
|
|
56
|
+
bg = c.light;
|
|
57
|
+
break;
|
|
58
|
+
case 'elevated':
|
|
59
|
+
bg = pressed ? c.light : t.cardBg;
|
|
60
|
+
shadow = pressed ? t.shadowSm : t.shadowMd;
|
|
61
|
+
break;
|
|
62
|
+
case 'tonal':
|
|
63
|
+
bg = pressed ? c.strong : c.light;
|
|
64
|
+
if (pressed)
|
|
65
|
+
fg = onSolid;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
if (o.disableElevation)
|
|
69
|
+
shadow = undefined;
|
|
70
|
+
const square = shape === 'circle' || shape === 'square';
|
|
71
|
+
const pad = o.iconOnly || shape === 'circle' ? { padding: s.iconPad } : { paddingVertical: s.padY, paddingHorizontal: s.padX };
|
|
72
|
+
const radius = shape === 'pill' || shape === 'circle' ? t.borderRadiusFull : shape === 'rounded' ? t.borderRadiusSm : t.borderRadiusSm / 2;
|
|
73
|
+
const container = {
|
|
74
|
+
flexDirection: 'row',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
overflow: 'hidden',
|
|
78
|
+
gap: s.gap,
|
|
79
|
+
minHeight: s.height,
|
|
80
|
+
...(o.iconOnly ? { minWidth: s.height } : {}),
|
|
81
|
+
...pad,
|
|
82
|
+
borderRadius: radius,
|
|
83
|
+
backgroundColor: bg,
|
|
84
|
+
...(border ? { borderWidth: BORDER_WIDTH, borderColor: border } : {}),
|
|
85
|
+
...(shadow && shadow.length ? { boxShadow: boxShadow(shadow) } : {}),
|
|
86
|
+
...(square ? { aspectRatio: 1 } : {}),
|
|
87
|
+
...(o.fullWidth ? { alignSelf: 'stretch' } : {}),
|
|
88
|
+
...(o.disabled ? { opacity: DISABLED_OPACITY } : {}),
|
|
89
|
+
...(pressed && o.pressDown ? { transform: [{ scale: t.pressScale }] } : {}),
|
|
90
|
+
};
|
|
91
|
+
const text = {
|
|
92
|
+
color: fg,
|
|
93
|
+
fontSize: s.fontSize,
|
|
94
|
+
lineHeight: Math.round(s.fontSize * t.lineHeightNormal),
|
|
95
|
+
fontWeight: String(t.fontWeightMedium),
|
|
96
|
+
textAlign: 'center',
|
|
97
|
+
...(o.disableTextTransform ? {} : { textTransform: 'uppercase', letterSpacing: CAPS_LETTER_SPACING }),
|
|
98
|
+
};
|
|
99
|
+
return { container, text, fg, iconSize: s.iconStep, gap: s.gap };
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Button } from './Button';
|