@passui/react 0.0.0-stage → 0.1.14
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/LICENSE +21 -0
- package/README.md +83 -2
- package/package.json +96 -5
- package/src/appearance/index.ts +2 -0
- package/src/appearance/platform.tsx +123 -0
- package/src/appearance/theme.tsx +535 -0
- package/src/components/ambient/ambient.docs.tsx +68 -0
- package/src/components/ambient/ambient.tsx +43 -0
- package/src/components/ambient/examples/ambient-images.tsx +30 -0
- package/src/components/ambient/examples/ambient-now-playing.tsx +55 -0
- package/src/components/ambient/examples/ambient-showcase.tsx +33 -0
- package/src/components/ambient/examples/ambient-usage.tsx +19 -0
- package/src/components/ambient/index.ts +1 -0
- package/src/components/button/button-styles.ts +60 -0
- package/src/components/button/button.docs.tsx +116 -0
- package/src/components/button/button.tsx +91 -0
- package/src/components/button/examples/button-disabled.tsx +19 -0
- package/src/components/button/examples/button-icon.tsx +39 -0
- package/src/components/button/examples/button-link.tsx +12 -0
- package/src/components/button/examples/button-pending.tsx +27 -0
- package/src/components/button/examples/button-showcase.tsx +115 -0
- package/src/components/button/examples/button-sizes.tsx +12 -0
- package/src/components/button/examples/button-usage.tsx +12 -0
- package/src/components/button/examples/button-variants.tsx +15 -0
- package/src/components/button/examples/button-with-icon.tsx +32 -0
- package/src/components/button/examples/icon-button-player.tsx +38 -0
- package/src/components/button/examples/icon-button-showcase.tsx +83 -0
- package/src/components/button/examples/icon-button-usage.tsx +11 -0
- package/src/components/button/examples/icon-button-variants.tsx +39 -0
- package/src/components/button/icon-button.docs.tsx +68 -0
- package/src/components/button/icon-button.tsx +73 -0
- package/src/components/button/pending-spinner.tsx +14 -0
- package/src/components/button/use-pending-indicator.ts +27 -0
- package/src/components/chip/chip.docs.tsx +37 -0
- package/src/components/chip/chip.tsx +35 -0
- package/src/components/chip/examples/chip-in-rows.tsx +19 -0
- package/src/components/chip/examples/chip-showcase.tsx +51 -0
- package/src/components/chip/examples/chip-tones.tsx +13 -0
- package/src/components/chip/examples/chip-usage.tsx +5 -0
- package/src/components/compact-date-picker/calendar-month.ts +131 -0
- package/src/components/compact-date-picker/compact-date-picker.docs.tsx +81 -0
- package/src/components/compact-date-picker/compact-date-picker.tsx +438 -0
- package/src/components/compact-date-picker/examples/compact-date-picker-showcase.tsx +35 -0
- package/src/components/compact-date-picker/examples/compact-date-picker-usage.tsx +22 -0
- package/src/components/compact-time-picker/compact-time-picker.docs.tsx +80 -0
- package/src/components/compact-time-picker/compact-time-picker.tsx +432 -0
- package/src/components/compact-time-picker/examples/compact-time-picker-showcase.tsx +31 -0
- package/src/components/compact-time-picker/examples/compact-time-picker-usage.tsx +21 -0
- package/src/components/compact-time-picker/time-value.ts +67 -0
- package/src/components/content-view/content-view.docs.tsx +61 -0
- package/src/components/content-view/content-view.tsx +197 -0
- package/src/components/content-view/examples/content-view-header-action.tsx +33 -0
- package/src/components/content-view/examples/content-view-showcase.tsx +65 -0
- package/src/components/content-view/examples/content-view-stats.tsx +35 -0
- package/src/components/content-view/examples/content-view-usage.tsx +14 -0
- package/src/components/content-view/index.ts +1 -0
- package/src/components/context-menu/conceal-menu-source.ts +33 -0
- package/src/components/context-menu/context-menu-host.tsx +445 -0
- package/src/components/context-menu/context-menu-store.ts +165 -0
- package/src/components/context-menu/context-menu.docs.tsx +92 -0
- package/src/components/context-menu/examples/context-menu-checked.tsx +37 -0
- package/src/components/context-menu/examples/context-menu-list.tsx +85 -0
- package/src/components/context-menu/examples/context-menu-showcase.tsx +56 -0
- package/src/components/context-menu/examples/context-menu-toolbar.tsx +63 -0
- package/src/components/context-menu/examples/context-menu-usage.tsx +24 -0
- package/src/components/context-menu/menu-position.ts +55 -0
- package/src/components/context-menu/menu-reveal.ts +75 -0
- package/src/components/context-menu/use-context-menu.ts +90 -0
- package/src/components/conversation/conversation.docs.tsx +88 -0
- package/src/components/conversation/conversation.tsx +279 -0
- package/src/components/conversation/examples/conversation-composer.tsx +36 -0
- package/src/components/conversation/examples/conversation-days.tsx +48 -0
- package/src/components/conversation/examples/conversation-showcase.tsx +71 -0
- package/src/components/conversation/examples/conversation-usage.tsx +28 -0
- package/src/components/conversation/index.ts +1 -0
- package/src/components/date-picker/date-picker.docs.tsx +88 -0
- package/src/components/date-picker/date-picker.tsx +103 -0
- package/src/components/date-picker/date-value.ts +37 -0
- package/src/components/date-picker/examples/date-picker-locales.tsx +41 -0
- package/src/components/date-picker/examples/date-picker-past-only.tsx +29 -0
- package/src/components/date-picker/examples/date-picker-showcase.tsx +49 -0
- package/src/components/date-picker/examples/date-picker-usage.tsx +22 -0
- package/src/components/dialog/dialog-host.tsx +156 -0
- package/src/components/dialog/dialog-store.ts +56 -0
- package/src/components/dialog/dialog.docs.tsx +114 -0
- package/src/components/dialog/dialog.tsx +200 -0
- package/src/components/dialog/examples/dialog-confirm.tsx +24 -0
- package/src/components/dialog/examples/dialog-form.tsx +46 -0
- package/src/components/dialog/examples/dialog-inline.tsx +48 -0
- package/src/components/dialog/examples/dialog-showcase.tsx +53 -0
- package/src/components/dialog/examples/dialog-usage.tsx +31 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/labeled-content/examples/labeled-content-descriptions.tsx +37 -0
- package/src/components/labeled-content/examples/labeled-content-showcase.tsx +54 -0
- package/src/components/labeled-content/examples/labeled-content-usage.tsx +22 -0
- package/src/components/labeled-content/examples/labeled-content-values.tsx +26 -0
- package/src/components/labeled-content/examples/labeled-content-wide.tsx +46 -0
- package/src/components/labeled-content/labeled-content.docs.tsx +69 -0
- package/src/components/labeled-content/labeled-content.tsx +66 -0
- package/src/components/locale-switcher/examples/locale-switcher-native-names.tsx +30 -0
- package/src/components/locale-switcher/examples/locale-switcher-showcase.tsx +46 -0
- package/src/components/locale-switcher/examples/locale-switcher-translated-page.tsx +35 -0
- package/src/components/locale-switcher/examples/locale-switcher-usage.tsx +20 -0
- package/src/components/locale-switcher/index.ts +1 -0
- package/src/components/locale-switcher/locale-switcher.docs.tsx +91 -0
- package/src/components/locale-switcher/locale-switcher.tsx +252 -0
- package/src/components/picker/examples/picker-details.tsx +44 -0
- package/src/components/picker/examples/picker-searchable.tsx +48 -0
- package/src/components/picker/examples/picker-showcase.tsx +66 -0
- package/src/components/picker/examples/picker-usage.tsx +20 -0
- package/src/components/picker/picker.docs.tsx +68 -0
- package/src/components/picker/picker.tsx +493 -0
- package/src/components/popover/examples/popover-help.tsx +57 -0
- package/src/components/popover/examples/popover-menu.tsx +51 -0
- package/src/components/popover/examples/popover-showcase.tsx +61 -0
- package/src/components/popover/examples/popover-usage.tsx +31 -0
- package/src/components/popover/popover.docs.tsx +84 -0
- package/src/components/popover/popover.tsx +138 -0
- package/src/components/profile-image/examples/profile-image-fallbacks.tsx +29 -0
- package/src/components/profile-image/examples/profile-image-group.tsx +34 -0
- package/src/components/profile-image/examples/profile-image-showcase.tsx +30 -0
- package/src/components/profile-image/examples/profile-image-usage.tsx +14 -0
- package/src/components/profile-image/profile-image.docs.tsx +81 -0
- package/src/components/profile-image/profile-image.tsx +80 -0
- package/src/components/search-field/examples/search-field-filter.tsx +53 -0
- package/src/components/search-field/examples/search-field-showcase.tsx +56 -0
- package/src/components/search-field/examples/search-field-toolbar.tsx +27 -0
- package/src/components/search-field/examples/search-field-usage.tsx +18 -0
- package/src/components/search-field/search-field.docs.tsx +58 -0
- package/src/components/search-field/search-field.tsx +29 -0
- package/src/components/search-list/examples/search-list-dropdown.tsx +53 -0
- package/src/components/search-list/examples/search-list-groups.tsx +64 -0
- package/src/components/search-list/examples/search-list-showcase.tsx +67 -0
- package/src/components/search-list/examples/search-list-usage.tsx +27 -0
- package/src/components/search-list/search-list.docs.tsx +87 -0
- package/src/components/search-list/search-list.tsx +265 -0
- package/src/components/section/examples/section-actions.tsx +35 -0
- package/src/components/section/examples/section-groups.tsx +41 -0
- package/src/components/section/examples/section-showcase.tsx +63 -0
- package/src/components/section/examples/section-usage.tsx +19 -0
- package/src/components/section/section.docs.tsx +51 -0
- package/src/components/section/section.tsx +41 -0
- package/src/components/secure-field/examples/secure-field-new-password.tsx +56 -0
- package/src/components/secure-field/examples/secure-field-reveal.tsx +20 -0
- package/src/components/secure-field/examples/secure-field-showcase.tsx +62 -0
- package/src/components/secure-field/examples/secure-field-usage.tsx +19 -0
- package/src/components/secure-field/secure-field.docs.tsx +72 -0
- package/src/components/secure-field/secure-field.tsx +10 -0
- package/src/components/segmented-control/examples/segmented-control-overflow.tsx +28 -0
- package/src/components/segmented-control/examples/segmented-control-showcase.tsx +59 -0
- package/src/components/segmented-control/examples/segmented-control-usage.tsx +20 -0
- package/src/components/segmented-control/examples/segmented-control-views.tsx +32 -0
- package/src/components/segmented-control/segmented-control.docs.tsx +61 -0
- package/src/components/segmented-control/segmented-control.tsx +122 -0
- package/src/components/sheet/examples/sheet-choices.tsx +58 -0
- package/src/components/sheet/examples/sheet-share.tsx +51 -0
- package/src/components/sheet/examples/sheet-showcase.tsx +74 -0
- package/src/components/sheet/examples/sheet-usage.tsx +32 -0
- package/src/components/sheet/modal-environment.ts +113 -0
- package/src/components/sheet/sheet-portal.tsx +89 -0
- package/src/components/sheet/sheet.docs.tsx +75 -0
- package/src/components/sheet/sheet.tsx +112 -0
- package/src/components/sheet/use-sheet-focus.ts +130 -0
- package/src/components/sidebar/examples/sidebar-groups.tsx +133 -0
- package/src/components/sidebar/examples/sidebar-showcase.tsx +123 -0
- package/src/components/sidebar/examples/sidebar-unread.tsx +66 -0
- package/src/components/sidebar/examples/sidebar-usage.tsx +52 -0
- package/src/components/sidebar/sidebar.docs.tsx +135 -0
- package/src/components/sidebar/sidebar.tsx +69 -0
- package/src/components/stat-tile/examples/stat-tile-filters.tsx +32 -0
- package/src/components/stat-tile/examples/stat-tile-grid.tsx +21 -0
- package/src/components/stat-tile/examples/stat-tile-showcase.tsx +52 -0
- package/src/components/stat-tile/examples/stat-tile-usage.tsx +13 -0
- package/src/components/stat-tile/index.ts +1 -0
- package/src/components/stat-tile/stat-tile.docs.tsx +60 -0
- package/src/components/stat-tile/stat-tile.tsx +68 -0
- package/src/components/status-indicator/examples/status-indicator-live.tsx +34 -0
- package/src/components/status-indicator/examples/status-indicator-showcase.tsx +39 -0
- package/src/components/status-indicator/examples/status-indicator-states.tsx +17 -0
- package/src/components/status-indicator/examples/status-indicator-usage.tsx +9 -0
- package/src/components/status-indicator/status-indicator.docs.tsx +43 -0
- package/src/components/status-indicator/status-indicator.tsx +35 -0
- package/src/components/swatch-picker/examples/swatch-picker-accents.tsx +42 -0
- package/src/components/swatch-picker/examples/swatch-picker-labels.tsx +45 -0
- package/src/components/swatch-picker/examples/swatch-picker-showcase.tsx +70 -0
- package/src/components/swatch-picker/examples/swatch-picker-usage.tsx +39 -0
- package/src/components/swatch-picker/swatch-picker.docs.tsx +60 -0
- package/src/components/swatch-picker/swatch-picker.tsx +96 -0
- package/src/components/tab-bar/examples/tab-bar-five-tabs.tsx +66 -0
- package/src/components/tab-bar/examples/tab-bar-minimize.tsx +71 -0
- package/src/components/tab-bar/examples/tab-bar-showcase.tsx +82 -0
- package/src/components/tab-bar/examples/tab-bar-usage.tsx +54 -0
- package/src/components/tab-bar/tab-bar.docs.tsx +136 -0
- package/src/components/tab-bar/tab-bar.tsx +148 -0
- package/src/components/tab-view/examples/tab-view-keyboard.tsx +39 -0
- package/src/components/tab-view/examples/tab-view-settings.tsx +56 -0
- package/src/components/tab-view/examples/tab-view-showcase.tsx +53 -0
- package/src/components/tab-view/examples/tab-view-usage.tsx +23 -0
- package/src/components/tab-view/tab-view.docs.tsx +77 -0
- package/src/components/tab-view/tab-view.tsx +117 -0
- package/src/components/table/examples/table-empty.tsx +53 -0
- package/src/components/table/examples/table-invoices.tsx +102 -0
- package/src/components/table/examples/table-selection.tsx +150 -0
- package/src/components/table/examples/table-showcase.tsx +115 -0
- package/src/components/table/examples/table-usage.tsx +67 -0
- package/src/components/table/examples/table-wide.tsx +75 -0
- package/src/components/table/table.docs.tsx +131 -0
- package/src/components/table/table.tsx +149 -0
- package/src/components/text-editor/examples/text-editor-comment.tsx +48 -0
- package/src/components/text-editor/examples/text-editor-count.tsx +38 -0
- package/src/components/text-editor/examples/text-editor-showcase.tsx +58 -0
- package/src/components/text-editor/examples/text-editor-usage.tsx +25 -0
- package/src/components/text-editor/text-editor.docs.tsx +61 -0
- package/src/components/text-editor/text-editor.tsx +19 -0
- package/src/components/text-field/examples/text-field-icons.tsx +72 -0
- package/src/components/text-field/examples/text-field-showcase.tsx +50 -0
- package/src/components/text-field/examples/text-field-usage.tsx +18 -0
- package/src/components/text-field/examples/text-field-validation.tsx +27 -0
- package/src/components/text-field/text-field.docs.tsx +118 -0
- package/src/components/text-field/text-field.tsx +135 -0
- package/src/components/toast/examples/toast-action.tsx +32 -0
- package/src/components/toast/examples/toast-promise.tsx +45 -0
- package/src/components/toast/examples/toast-showcase.tsx +49 -0
- package/src/components/toast/examples/toast-usage.tsx +13 -0
- package/src/components/toast/toast-store.ts +166 -0
- package/src/components/toast/toast.docs.tsx +79 -0
- package/src/components/toast/toaster.tsx +374 -0
- package/src/components/toggle/examples/toggle-checkboxes.tsx +43 -0
- package/src/components/toggle/examples/toggle-settings.tsx +31 -0
- package/src/components/toggle/examples/toggle-showcase.tsx +59 -0
- package/src/components/toggle/examples/toggle-usage.tsx +13 -0
- package/src/components/toggle/toggle.docs.tsx +69 -0
- package/src/components/toggle/toggle.tsx +85 -0
- package/src/components/tooltip/examples/tooltip-icon-buttons.tsx +27 -0
- package/src/components/tooltip/examples/tooltip-shortcuts.tsx +38 -0
- package/src/components/tooltip/examples/tooltip-showcase.tsx +44 -0
- package/src/components/tooltip/examples/tooltip-usage.tsx +13 -0
- package/src/components/tooltip/tooltip-host.tsx +156 -0
- package/src/components/tooltip/tooltip.docs.tsx +56 -0
- package/src/components/view-controller/examples/view-controller-action.tsx +27 -0
- package/src/components/view-controller/examples/view-controller-settings.tsx +31 -0
- package/src/components/view-controller/examples/view-controller-showcase.tsx +45 -0
- package/src/components/view-controller/examples/view-controller-usage.tsx +19 -0
- package/src/components/view-controller/index.ts +1 -0
- package/src/components/view-controller/view-controller.docs.tsx +71 -0
- package/src/components/view-controller/view-controller.tsx +81 -0
- package/src/docs/index.ts +3 -0
- package/src/docs/registry.ts +113 -0
- package/src/docs/snippet.ts +17 -0
- package/src/docs/types.ts +180 -0
- package/src/hooks/scroll/minimize-decision.ts +13 -0
- package/src/hooks/use-anchored-placement.ts +43 -0
- package/src/hooks/use-dismiss.ts +58 -0
- package/src/hooks/use-media-query.ts +106 -0
- package/src/hooks/use-minimize-on-scroll.ts +92 -0
- package/src/hooks/use-visual-viewport.ts +76 -0
- package/src/hooks/viewport/types.ts +19 -0
- package/src/hooks/viewport/viewport-metrics.ts +25 -0
- package/src/icons/icons.tsx +298 -0
- package/src/index.ts +78 -0
- package/src/lib/anchored-placement.ts +92 -0
- package/src/lib/class-names.ts +21 -0
- package/src/lib/date.ts +96 -0
- package/src/lib/floating-layers.ts +28 -0
- package/src/lib/haptics.ts +25 -0
- package/src/lib/language.ts +21 -0
- package/src/lib/screen-edges.ts +45 -0
- package/src/lib/shapes.ts +70 -0
- package/src/motion/transitions.ts +30 -0
- package/src/styles/base.css +1 -0
- package/src/styles/styles.css +3 -0
- package/src/styles/theme.css +1 -0
- package/src/styles/typeset.css +1 -0
- package/src/styles/utilities.css +1 -0
- package/src/tokens.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pherus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,84 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Passui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Passui is Pherus's design system: native React controls, design tokens and
|
|
4
|
+
themes, with names drawn from SwiftUI. What Liquid Glass is to Apple and
|
|
5
|
+
Material 3 is to Google, built for any React app.
|
|
6
|
+
|
|
7
|
+
**Docs, live playgrounds and examples: [passui.pherus.org](https://passui.pherus.org)**
|
|
8
|
+
|
|
9
|
+
## What's inside
|
|
10
|
+
|
|
11
|
+
- **Controls**: buttons, fields, pickers, toggles, sheets, dialogs,
|
|
12
|
+
popovers, toasts, menus, tables and more, written as plain React you
|
|
13
|
+
can read.
|
|
14
|
+
- **Design tokens**: color roles for light and dark, seven accents, text
|
|
15
|
+
styles named as SwiftUI names them, corners and springs.
|
|
16
|
+
- **Appearance**: theme and platform providers, so every control follows
|
|
17
|
+
the system it runs on, with `ios:`, `android:`, `macos:`, `windows:`
|
|
18
|
+
and `linux:` variants.
|
|
19
|
+
- **Typeset**: calm styles for long-form writing.
|
|
20
|
+
|
|
21
|
+
## Using it
|
|
22
|
+
|
|
23
|
+
Install the public npm package in a React 19 app with Tailwind CSS 4:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
bun add @passui/react
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Import the styles once and each control from its own entry point:
|
|
30
|
+
|
|
31
|
+
```css
|
|
32
|
+
@import "@passui/react/styles.css";
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { Button } from "@passui/react/button"
|
|
37
|
+
|
|
38
|
+
export function SaveButton() {
|
|
39
|
+
return <Button variant="accent">Save</Button>
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
See [Installation](https://passui.pherus.org/docs/installation) for the
|
|
44
|
+
root setup, and [Skills](https://passui.pherus.org/docs/skills) to give AI
|
|
45
|
+
agents Passui's rules.
|
|
46
|
+
|
|
47
|
+
Passui works independently of TanStack. If your app uses TanStack Form,
|
|
48
|
+
Table or Router, the optional `@passui/tanstack` package connects them to
|
|
49
|
+
Passui's controls.
|
|
50
|
+
|
|
51
|
+
## Development and publishing
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
bun install
|
|
55
|
+
bun run typecheck
|
|
56
|
+
bun run test
|
|
57
|
+
bun run publish:check
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The package exports TypeScript and TSX source. Your app's bundler must
|
|
61
|
+
process those files and its stylesheet through Tailwind CSS 4.
|
|
62
|
+
|
|
63
|
+
The GitHub Actions `publish.yml` workflow publishes from `main` using
|
|
64
|
+
npm's trusted publisher connection and the `npm-publish` environment.
|
|
65
|
+
It installs and validates with Bun, packs with Bun, then publishes the
|
|
66
|
+
archive with npm's OIDC support. It needs no stored npm token.
|
|
67
|
+
|
|
68
|
+
For a manual release, login to npm with an account that can publish
|
|
69
|
+
under `@passui`, then run `bun publish`. The package configuration
|
|
70
|
+
selects the public npm registry and public access. Keep credentials in
|
|
71
|
+
your user npm configuration.
|
|
72
|
+
|
|
73
|
+
## Principles
|
|
74
|
+
|
|
75
|
+
- Ask what Apple would do, then add our own touch.
|
|
76
|
+
- Name things as SwiftUI does: `Toggle`, `Picker`, `Sheet`, `footnote`.
|
|
77
|
+
- Use named tokens, never one-off colors, sizes or shadows.
|
|
78
|
+
- Every string comes from the app, so every app can translate.
|
|
79
|
+
- Respect the system: light and dark, text size, Reduce Motion and each
|
|
80
|
+
platform's look.
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
[MIT](./LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,97 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@passui/react",
|
|
3
|
+
"version": "0.1.14",
|
|
4
|
+
"description": "Passui: native React controls, design tokens, presentation and appearance.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/phe-rus/passui.git",
|
|
9
|
+
"directory": "packages/ui"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://passui.pherus.org",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"registry": "https://registry.npmjs.org",
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
"./table": "./src/components/table/table.tsx",
|
|
24
|
+
"./search-list": "./src/components/search-list/search-list.tsx",
|
|
25
|
+
"./profile-image": "./src/components/profile-image/profile-image.tsx",
|
|
26
|
+
"./popover": "./src/components/popover/popover.tsx",
|
|
27
|
+
"./sheet": "./src/components/sheet/sheet.tsx",
|
|
28
|
+
"./use-dismiss": "./src/hooks/use-dismiss.ts",
|
|
29
|
+
"./toast": "./src/components/toast/toast-store.ts",
|
|
30
|
+
"./toaster": "./src/components/toast/toaster.tsx",
|
|
31
|
+
"./tab-view": "./src/components/tab-view/tab-view.tsx",
|
|
32
|
+
"./sidebar": "./src/components/sidebar/sidebar.tsx",
|
|
33
|
+
"./icon-button": "./src/components/button/icon-button.tsx",
|
|
34
|
+
"./secure-field": "./src/components/secure-field/secure-field.tsx",
|
|
35
|
+
"./text-field": "./src/components/text-field/text-field.tsx",
|
|
36
|
+
"./text-editor": "./src/components/text-editor/text-editor.tsx",
|
|
37
|
+
"./button": "./src/components/button/button.tsx",
|
|
38
|
+
"./toggle": "./src/components/toggle/toggle.tsx",
|
|
39
|
+
"./cn": "./src/lib/class-names.ts",
|
|
40
|
+
".": "./src/index.ts",
|
|
41
|
+
"./base.css": "./src/styles/base.css",
|
|
42
|
+
"./utilities.css": "./src/styles/utilities.css",
|
|
43
|
+
"./theme.css": "./src/styles/theme.css",
|
|
44
|
+
"./tokens": "./src/tokens.ts",
|
|
45
|
+
"./date-picker": "./src/components/date-picker/date-picker.tsx",
|
|
46
|
+
"./compact-date-picker": "./src/components/compact-date-picker/compact-date-picker.tsx",
|
|
47
|
+
"./compact-time-picker": "./src/components/compact-time-picker/compact-time-picker.tsx",
|
|
48
|
+
"./view-controller": "./src/components/view-controller/index.ts",
|
|
49
|
+
"./content-view": "./src/components/content-view/index.ts",
|
|
50
|
+
"./ambient": "./src/components/ambient/index.ts",
|
|
51
|
+
"./stat-tile": "./src/components/stat-tile/index.ts",
|
|
52
|
+
"./conversation": "./src/components/conversation/index.ts",
|
|
53
|
+
"./locale-switcher": "./src/components/locale-switcher/index.ts",
|
|
54
|
+
"./date": "./src/lib/date.ts",
|
|
55
|
+
"./language": "./src/lib/language.ts",
|
|
56
|
+
"./shapes": "./src/lib/shapes.ts",
|
|
57
|
+
"./appearance": "./src/appearance/index.ts",
|
|
58
|
+
"./use-media-query": "./src/hooks/use-media-query.ts",
|
|
59
|
+
"./typeset.css": "./src/styles/typeset.css",
|
|
60
|
+
"./styles.css": "./src/styles/styles.css",
|
|
61
|
+
"./dialog": "./src/components/dialog/index.ts",
|
|
62
|
+
"./docs": "./src/docs/index.ts"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"generate": "bun run --cwd ../tokens generate",
|
|
66
|
+
"test": "vitest run",
|
|
67
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
68
|
+
"publish:check": "bun pm pack --dry-run",
|
|
69
|
+
"build": "bun run generate"
|
|
70
|
+
},
|
|
71
|
+
"packageManager": "bun@1.4.2",
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"react": "^19.3.0",
|
|
74
|
+
"react-dom": "^19.3.0",
|
|
75
|
+
"tailwindcss": "^4.3.3"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@types/react": "^19.3.0",
|
|
79
|
+
"@types/react-dom": "^19.3.0",
|
|
80
|
+
"react": "^19.3.0",
|
|
81
|
+
"react-dom": "^19.3.0",
|
|
82
|
+
"typescript": "^7.0.2",
|
|
83
|
+
"tailwindcss": "^4.3.3",
|
|
84
|
+
"@types/node": "^26.6.3",
|
|
85
|
+
"vitest": "5.0.5",
|
|
86
|
+
"vite": "8.3.5"
|
|
87
|
+
},
|
|
88
|
+
"dependencies": {
|
|
89
|
+
"@hugeicons/core-free-icons": "4.3.5",
|
|
90
|
+
"@hugeicons/react": "1.1.10",
|
|
91
|
+
"motion": "13.5.0",
|
|
92
|
+
"clsx": "^2.1.1",
|
|
93
|
+
"tailwind-merge": "^3.7.0",
|
|
94
|
+
"tw-animate-css": "^1.4.0",
|
|
95
|
+
"@passui/tokens": "^0.1.0"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useState,
|
|
6
|
+
type PropsWithChildren,
|
|
7
|
+
} from "react"
|
|
8
|
+
|
|
9
|
+
export type PlatformOS =
|
|
10
|
+
| "ios"
|
|
11
|
+
| "android"
|
|
12
|
+
| "macos"
|
|
13
|
+
| "windows"
|
|
14
|
+
| "linux"
|
|
15
|
+
| "unknown"
|
|
16
|
+
|
|
17
|
+
const PlatformContext = createContext<PlatformOS>("unknown")
|
|
18
|
+
|
|
19
|
+
export function detectPlatform(
|
|
20
|
+
userAgent: string,
|
|
21
|
+
platform: string,
|
|
22
|
+
maxTouchPoints: number
|
|
23
|
+
): PlatformOS {
|
|
24
|
+
return resolvePlatform(
|
|
25
|
+
null,
|
|
26
|
+
userAgent,
|
|
27
|
+
platform,
|
|
28
|
+
maxTouchPoints
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function resolvePlatform(
|
|
33
|
+
override: string | null,
|
|
34
|
+
userAgent: string,
|
|
35
|
+
platform: string,
|
|
36
|
+
maxTouchPoints: number
|
|
37
|
+
): PlatformOS {
|
|
38
|
+
if (
|
|
39
|
+
override === "ios" ||
|
|
40
|
+
override === "android" ||
|
|
41
|
+
override === "macos" ||
|
|
42
|
+
override === "windows" ||
|
|
43
|
+
override === "linux" ||
|
|
44
|
+
override === "unknown"
|
|
45
|
+
) {
|
|
46
|
+
return override
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (/android/i.test(userAgent)) return "android"
|
|
50
|
+
if (/iPhone|iPad|iPod/i.test(userAgent)) return "ios"
|
|
51
|
+
if (platform === "MacIntel" && maxTouchPoints > 1)
|
|
52
|
+
return "ios"
|
|
53
|
+
if (/Mac/i.test(platform)) return "macos"
|
|
54
|
+
if (/Win/i.test(platform)) return "windows"
|
|
55
|
+
if (/Linux/i.test(platform)) return "linux"
|
|
56
|
+
return "unknown"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function initializePlatform(
|
|
60
|
+
resolve: typeof resolvePlatform,
|
|
61
|
+
root: HTMLElement,
|
|
62
|
+
userAgent: string,
|
|
63
|
+
platform: string,
|
|
64
|
+
maxTouchPoints: number
|
|
65
|
+
) {
|
|
66
|
+
root.setAttribute(
|
|
67
|
+
"data-os",
|
|
68
|
+
resolve(
|
|
69
|
+
root.getAttribute("data-os"),
|
|
70
|
+
userAgent,
|
|
71
|
+
platform,
|
|
72
|
+
maxTouchPoints
|
|
73
|
+
)
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function PlatformScript({
|
|
78
|
+
nonce,
|
|
79
|
+
}: {
|
|
80
|
+
nonce?: string
|
|
81
|
+
}) {
|
|
82
|
+
return (
|
|
83
|
+
<script
|
|
84
|
+
// Run the library's platform bootstrap before first paint.
|
|
85
|
+
dangerouslySetInnerHTML={{
|
|
86
|
+
__html: `(${initializePlatform.toString()})(${resolvePlatform.toString()}, document.documentElement, navigator.userAgent, navigator.platform, navigator.maxTouchPoints)`,
|
|
87
|
+
}}
|
|
88
|
+
nonce={nonce}
|
|
89
|
+
suppressHydrationWarning
|
|
90
|
+
/>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function PlatformProvider({
|
|
95
|
+
children,
|
|
96
|
+
}: PropsWithChildren) {
|
|
97
|
+
const [platform, setPlatform] =
|
|
98
|
+
useState<PlatformOS>("unknown")
|
|
99
|
+
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
const resolved = resolvePlatform(
|
|
102
|
+
document.documentElement.getAttribute("data-os"),
|
|
103
|
+
navigator.userAgent,
|
|
104
|
+
navigator.platform,
|
|
105
|
+
navigator.maxTouchPoints
|
|
106
|
+
)
|
|
107
|
+
document.documentElement.setAttribute(
|
|
108
|
+
"data-os",
|
|
109
|
+
resolved
|
|
110
|
+
)
|
|
111
|
+
setPlatform(resolved)
|
|
112
|
+
}, [])
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<PlatformContext.Provider value={platform}>
|
|
116
|
+
{children}
|
|
117
|
+
</PlatformContext.Provider>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function usePlatform() {
|
|
122
|
+
return useContext(PlatformContext)
|
|
123
|
+
}
|