@passui/react 0.0.0-stage → 0.1.15
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 +130 -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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SecureFieldNewPassword } from "./examples/secure-field-new-password"
|
|
2
|
+
import { SecureFieldReveal } from "./examples/secure-field-reveal"
|
|
3
|
+
import type { ComponentProps } from "react"
|
|
4
|
+
import { useState } from "react"
|
|
5
|
+
import { defineDocs } from "../../docs/types"
|
|
6
|
+
import { SecureFieldShowcase } from "./examples/secure-field-showcase"
|
|
7
|
+
import { SecureFieldUsage } from "./examples/secure-field-usage"
|
|
8
|
+
import { SecureField } from "./secure-field"
|
|
9
|
+
|
|
10
|
+
type SecureFieldProps = ComponentProps<typeof SecureField>
|
|
11
|
+
type DemoProps = Pick<
|
|
12
|
+
SecureFieldProps,
|
|
13
|
+
"label" | "placeholder" | "disabled"
|
|
14
|
+
>
|
|
15
|
+
|
|
16
|
+
function SecureFieldDemo(props: DemoProps) {
|
|
17
|
+
const [value, setValue] = useState("")
|
|
18
|
+
return (
|
|
19
|
+
<div className="w-full max-w-xs">
|
|
20
|
+
<SecureField
|
|
21
|
+
{...props}
|
|
22
|
+
value={value}
|
|
23
|
+
revealLabels={{ show: "Show", hide: "Hide" }}
|
|
24
|
+
onChange={(event) =>
|
|
25
|
+
setValue(event.target.value)
|
|
26
|
+
}
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const secureFieldDocs = defineDocs<SecureFieldProps>()(
|
|
33
|
+
{
|
|
34
|
+
slug: "secure-field",
|
|
35
|
+
name: "SecureField",
|
|
36
|
+
importPath: "@passui/react/secure-field",
|
|
37
|
+
controls: {
|
|
38
|
+
label: {
|
|
39
|
+
kind: "text",
|
|
40
|
+
default: "Password",
|
|
41
|
+
required: true,
|
|
42
|
+
},
|
|
43
|
+
placeholder: {
|
|
44
|
+
kind: "text",
|
|
45
|
+
default: "At least 8 characters",
|
|
46
|
+
},
|
|
47
|
+
disabled: { kind: "boolean", default: false },
|
|
48
|
+
},
|
|
49
|
+
render: (values) => <SecureFieldDemo {...values} />,
|
|
50
|
+
childrenSnippet: () => ({
|
|
51
|
+
imports: ['import { useState } from "react"'],
|
|
52
|
+
setup: ['const [value, setValue] = useState("")'],
|
|
53
|
+
children: "",
|
|
54
|
+
expressionProps: {
|
|
55
|
+
value: "value",
|
|
56
|
+
revealLabels:
|
|
57
|
+
'{ show: "Show", hide: "Hide" }',
|
|
58
|
+
onChange:
|
|
59
|
+
"(event) => setValue(event.target.value)",
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
usage: SecureFieldUsage,
|
|
63
|
+
showcase: SecureFieldShowcase,
|
|
64
|
+
examples: [
|
|
65
|
+
{ id: "reveal", component: SecureFieldReveal },
|
|
66
|
+
{
|
|
67
|
+
id: "new-password",
|
|
68
|
+
component: SecureFieldNewPassword,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
}
|
|
72
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SegmentedControl } from "@passui/react"
|
|
2
|
+
import { useState } from "react"
|
|
3
|
+
|
|
4
|
+
export function SegmentedControlOverflow() {
|
|
5
|
+
const [sort, setSort] = useState("recent")
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<div className="w-full max-w-[16rem] resize-x overflow-hidden rounded-4xl bg-elevated p-4 shadow-sm ring-1 ring-separator/60">
|
|
9
|
+
<SegmentedControl
|
|
10
|
+
label="Sort by"
|
|
11
|
+
value={sort}
|
|
12
|
+
onChange={setSort}
|
|
13
|
+
options={[
|
|
14
|
+
{
|
|
15
|
+
value: "recent",
|
|
16
|
+
label: "Recently edited",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: "created",
|
|
20
|
+
label: "Date created",
|
|
21
|
+
},
|
|
22
|
+
{ value: "title", label: "Title" },
|
|
23
|
+
{ value: "size", label: "Size" },
|
|
24
|
+
]}
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { SegmentedControl } from "@passui/react"
|
|
2
|
+
import { useState } from "react"
|
|
3
|
+
|
|
4
|
+
const ranges = {
|
|
5
|
+
day: {
|
|
6
|
+
label: "Today",
|
|
7
|
+
steps: "8,204",
|
|
8
|
+
bars: [3, 5, 2, 6, 4, 7, 5],
|
|
9
|
+
},
|
|
10
|
+
week: {
|
|
11
|
+
label: "This week",
|
|
12
|
+
steps: "54,910",
|
|
13
|
+
bars: [6, 4, 7, 5, 8, 6, 9],
|
|
14
|
+
},
|
|
15
|
+
month: {
|
|
16
|
+
label: "This month",
|
|
17
|
+
steps: "231,447",
|
|
18
|
+
bars: [5, 7, 6, 8, 7, 9, 8],
|
|
19
|
+
},
|
|
20
|
+
} as const
|
|
21
|
+
|
|
22
|
+
type Range = keyof typeof ranges
|
|
23
|
+
|
|
24
|
+
export function SegmentedControlShowcase() {
|
|
25
|
+
const [range, setRange] = useState<Range>("week")
|
|
26
|
+
const data = ranges[range]
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<section className="flex w-full max-w-sm flex-col gap-5 rounded-4xl bg-elevated p-6 shadow-sm ring-1 ring-separator/60">
|
|
30
|
+
<SegmentedControl
|
|
31
|
+
label="Range"
|
|
32
|
+
value={range}
|
|
33
|
+
onChange={setRange}
|
|
34
|
+
options={[
|
|
35
|
+
{ value: "day", label: "Day" },
|
|
36
|
+
{ value: "week", label: "Week" },
|
|
37
|
+
{ value: "month", label: "Month" },
|
|
38
|
+
]}
|
|
39
|
+
/>
|
|
40
|
+
<div className="flex flex-col">
|
|
41
|
+
<span className="text-footnote text-label-secondary">
|
|
42
|
+
{data.label}
|
|
43
|
+
</span>
|
|
44
|
+
<span className="text-title font-bold tabular-nums text-label">
|
|
45
|
+
{data.steps} steps
|
|
46
|
+
</span>
|
|
47
|
+
</div>
|
|
48
|
+
<div className="flex h-28 items-end gap-2">
|
|
49
|
+
{data.bars.map((bar, index) => (
|
|
50
|
+
<span
|
|
51
|
+
key={index}
|
|
52
|
+
className="flex-1 rounded-t-lg bg-accent transition-[height] duration-500"
|
|
53
|
+
style={{ height: `${bar * 10}%` }}
|
|
54
|
+
/>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
</section>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SegmentedControl } from "@passui/react"
|
|
2
|
+
import { useState } from "react"
|
|
3
|
+
|
|
4
|
+
export function SegmentedControlUsage() {
|
|
5
|
+
const [theme, setTheme] = useState("auto")
|
|
6
|
+
return (
|
|
7
|
+
<div className="w-full max-w-xs">
|
|
8
|
+
<SegmentedControl
|
|
9
|
+
label="Appearance"
|
|
10
|
+
value={theme}
|
|
11
|
+
onChange={setTheme}
|
|
12
|
+
options={[
|
|
13
|
+
{ value: "light", label: "Light" },
|
|
14
|
+
{ value: "dark", label: "Dark" },
|
|
15
|
+
{ value: "auto", label: "Auto" },
|
|
16
|
+
]}
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SegmentedControl } from "@passui/react"
|
|
2
|
+
import { useState } from "react"
|
|
3
|
+
|
|
4
|
+
const counts = { day: 4, week: 23, month: 96 }
|
|
5
|
+
|
|
6
|
+
export function SegmentedControlViews() {
|
|
7
|
+
const [range, setRange] =
|
|
8
|
+
useState<keyof typeof counts>("week")
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div className="flex w-full max-w-sm flex-col gap-4 rounded-4xl bg-elevated p-5 shadow-sm ring-1 ring-separator/60">
|
|
12
|
+
<SegmentedControl
|
|
13
|
+
label="Range"
|
|
14
|
+
value={range}
|
|
15
|
+
onChange={setRange}
|
|
16
|
+
options={[
|
|
17
|
+
{ value: "day", label: "Day" },
|
|
18
|
+
{ value: "week", label: "Week" },
|
|
19
|
+
{ value: "month", label: "Month" },
|
|
20
|
+
]}
|
|
21
|
+
/>
|
|
22
|
+
<div className="flex flex-col items-center gap-1 py-2">
|
|
23
|
+
<span className="text-large-title font-bold text-label tabular-nums">
|
|
24
|
+
{counts[range]}
|
|
25
|
+
</span>
|
|
26
|
+
<span className="text-footnote text-label-secondary">
|
|
27
|
+
sign-ins this {range}
|
|
28
|
+
</span>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { SegmentedControlOverflow } from "./examples/segmented-control-overflow"
|
|
2
|
+
import { SegmentedControlViews } from "./examples/segmented-control-views"
|
|
3
|
+
import { useState } from "react"
|
|
4
|
+
import { defineDocs } from "../../docs/types"
|
|
5
|
+
import { SegmentedControlShowcase } from "./examples/segmented-control-showcase"
|
|
6
|
+
import { SegmentedControlUsage } from "./examples/segmented-control-usage"
|
|
7
|
+
import { SegmentedControl } from "./segmented-control"
|
|
8
|
+
|
|
9
|
+
type DemoProps = { label: string }
|
|
10
|
+
|
|
11
|
+
function SegmentedControlDemo({ label }: DemoProps) {
|
|
12
|
+
const [view, setView] = useState("week")
|
|
13
|
+
return (
|
|
14
|
+
<div className="w-full max-w-xs">
|
|
15
|
+
<SegmentedControl
|
|
16
|
+
label={label}
|
|
17
|
+
value={view}
|
|
18
|
+
onChange={setView}
|
|
19
|
+
options={[
|
|
20
|
+
{ value: "day", label: "Day" },
|
|
21
|
+
{ value: "week", label: "Week" },
|
|
22
|
+
{ value: "month", label: "Month" },
|
|
23
|
+
]}
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const segmentedControlDocs = defineDocs<DemoProps>()({
|
|
30
|
+
slug: "segmented-control",
|
|
31
|
+
name: "SegmentedControl",
|
|
32
|
+
importPath: "@passui/react",
|
|
33
|
+
controls: {
|
|
34
|
+
label: {
|
|
35
|
+
kind: "text",
|
|
36
|
+
default: "Calendar view",
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
render: (values) => <SegmentedControlDemo {...values} />,
|
|
41
|
+
childrenSnippet: () => ({
|
|
42
|
+
imports: ['import { useState } from "react"'],
|
|
43
|
+
setup: ['const [view, setView] = useState("week")'],
|
|
44
|
+
children: "",
|
|
45
|
+
expressionProps: {
|
|
46
|
+
value: "view",
|
|
47
|
+
onChange: "setView",
|
|
48
|
+
options:
|
|
49
|
+
'[{ value: "day", label: "Day" }, { value: "week", label: "Week" }, { value: "month", label: "Month" }]',
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
usage: SegmentedControlUsage,
|
|
53
|
+
showcase: SegmentedControlShowcase,
|
|
54
|
+
examples: [
|
|
55
|
+
{ id: "views", component: SegmentedControlViews },
|
|
56
|
+
{
|
|
57
|
+
id: "overflow",
|
|
58
|
+
component: SegmentedControlOverflow,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
})
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { motion } from "motion/react"
|
|
2
|
+
import {
|
|
3
|
+
useId,
|
|
4
|
+
useLayoutEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from "react"
|
|
8
|
+
import { cn } from "../../lib/class-names"
|
|
9
|
+
import { haptic } from "../../lib/haptics"
|
|
10
|
+
import { spring } from "../../motion/transitions"
|
|
11
|
+
import { Picker } from "../picker/picker"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Mutually exclusive choices with a sliding selection, as on Apple
|
|
15
|
+
* platforms. When the labels can't all fit the space it is given (a long
|
|
16
|
+
* translation, a narrow pane) it becomes a pop-up button instead of
|
|
17
|
+
* squeezing or spilling its text.
|
|
18
|
+
*/
|
|
19
|
+
export function SegmentedControl<T extends string>({
|
|
20
|
+
value,
|
|
21
|
+
options,
|
|
22
|
+
onChange,
|
|
23
|
+
label,
|
|
24
|
+
}: {
|
|
25
|
+
value: T
|
|
26
|
+
options: Array<{ value: T; label: string }>
|
|
27
|
+
onChange: (value: T) => void
|
|
28
|
+
label: string
|
|
29
|
+
}) {
|
|
30
|
+
const id = useId()
|
|
31
|
+
const frame = useRef<HTMLDivElement>(null)
|
|
32
|
+
const measure = useRef<HTMLDivElement>(null)
|
|
33
|
+
const [fits, setFits] = useState(true)
|
|
34
|
+
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
const box = frame.current
|
|
37
|
+
const natural = measure.current
|
|
38
|
+
if (!box || !natural) return
|
|
39
|
+
const check = () =>
|
|
40
|
+
setFits(
|
|
41
|
+
natural.offsetWidth <= box.clientWidth + 0.5
|
|
42
|
+
)
|
|
43
|
+
check()
|
|
44
|
+
const observer = new ResizeObserver(check)
|
|
45
|
+
observer.observe(box)
|
|
46
|
+
observer.observe(natural)
|
|
47
|
+
return () => observer.disconnect()
|
|
48
|
+
}, [])
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div ref={frame} className="relative w-full min-w-0">
|
|
52
|
+
{/* The control at its natural size, to know whether it fits. */}
|
|
53
|
+
<div
|
|
54
|
+
ref={measure}
|
|
55
|
+
aria-hidden="true"
|
|
56
|
+
className="pointer-events-none invisible absolute top-0 flex w-max p-[3px] text-footnote font-semibold"
|
|
57
|
+
>
|
|
58
|
+
{options.map((option) => (
|
|
59
|
+
<span
|
|
60
|
+
key={option.value}
|
|
61
|
+
className="min-w-[64px] px-3 py-1 whitespace-nowrap"
|
|
62
|
+
>
|
|
63
|
+
{option.label}
|
|
64
|
+
</span>
|
|
65
|
+
))}
|
|
66
|
+
</div>
|
|
67
|
+
{fits ? (
|
|
68
|
+
<fieldset className="flex w-full rounded-lg bg-fill p-[3px] shadow-[inset_0_1px_2px_rgb(40_30_0/0.06)]">
|
|
69
|
+
<legend className="sr-only">
|
|
70
|
+
{label}
|
|
71
|
+
</legend>
|
|
72
|
+
{options.map((option) => {
|
|
73
|
+
const selected =
|
|
74
|
+
option.value === value
|
|
75
|
+
return (
|
|
76
|
+
<label
|
|
77
|
+
key={option.value}
|
|
78
|
+
className={cn(
|
|
79
|
+
"relative isolate min-w-[64px] flex-1 cursor-pointer rounded-md px-3 py-1 text-center text-footnote whitespace-nowrap transition-colors has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-accent/60",
|
|
80
|
+
selected
|
|
81
|
+
? "font-semibold text-label"
|
|
82
|
+
: "font-medium text-label-secondary hover:text-label"
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
<input
|
|
86
|
+
type="radio"
|
|
87
|
+
name={id}
|
|
88
|
+
value={option.value}
|
|
89
|
+
checked={selected}
|
|
90
|
+
onChange={() => {
|
|
91
|
+
haptic("selection")
|
|
92
|
+
onChange(option.value)
|
|
93
|
+
}}
|
|
94
|
+
className="sr-only"
|
|
95
|
+
/>
|
|
96
|
+
{selected && (
|
|
97
|
+
<motion.span
|
|
98
|
+
layoutId={`segment-${id}`}
|
|
99
|
+
className="absolute inset-0 -z-10 rounded-md bg-elevated shadow-[0_0_0_0.5px_rgb(0_0_0/0.06),0_1px_2px_rgb(0_0_0/0.08),0_3px_8px_-2px_rgb(0_0_0/0.10)]"
|
|
100
|
+
transition={
|
|
101
|
+
spring.snappy
|
|
102
|
+
}
|
|
103
|
+
/>
|
|
104
|
+
)}
|
|
105
|
+
{option.label}
|
|
106
|
+
</label>
|
|
107
|
+
)
|
|
108
|
+
})}
|
|
109
|
+
</fieldset>
|
|
110
|
+
) : (
|
|
111
|
+
<Picker<T>
|
|
112
|
+
label={label}
|
|
113
|
+
value={value}
|
|
114
|
+
options={options}
|
|
115
|
+
onChange={onChange}
|
|
116
|
+
searchable={false}
|
|
117
|
+
className="rounded-lg py-1.5 text-footnote font-semibold"
|
|
118
|
+
/>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { LabeledContent, Section } from "@passui/react"
|
|
2
|
+
import { Button } from "@passui/react/button"
|
|
3
|
+
import { Sheet } from "@passui/react/sheet"
|
|
4
|
+
import { useState } from "react"
|
|
5
|
+
|
|
6
|
+
const languages = [
|
|
7
|
+
"English",
|
|
8
|
+
"Français",
|
|
9
|
+
"Deutsch",
|
|
10
|
+
"日本語",
|
|
11
|
+
"中文",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
export function SheetChoices() {
|
|
15
|
+
const [open, setOpen] = useState(false)
|
|
16
|
+
const [language, setLanguage] = useState("English")
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className="w-full max-w-sm">
|
|
20
|
+
<Section>
|
|
21
|
+
<LabeledContent label="Language">
|
|
22
|
+
<Button
|
|
23
|
+
variant="ghost"
|
|
24
|
+
size="sm"
|
|
25
|
+
onClick={() => setOpen(true)}
|
|
26
|
+
>
|
|
27
|
+
{language}
|
|
28
|
+
</Button>
|
|
29
|
+
</LabeledContent>
|
|
30
|
+
</Section>
|
|
31
|
+
<Sheet
|
|
32
|
+
open={open}
|
|
33
|
+
onClose={() => setOpen(false)}
|
|
34
|
+
label="Language"
|
|
35
|
+
>
|
|
36
|
+
<div className="flex flex-col gap-1 p-4">
|
|
37
|
+
{languages.map((item) => (
|
|
38
|
+
<button
|
|
39
|
+
key={item}
|
|
40
|
+
type="button"
|
|
41
|
+
aria-pressed={item === language}
|
|
42
|
+
onClick={() => {
|
|
43
|
+
setLanguage(item)
|
|
44
|
+
setOpen(false)
|
|
45
|
+
}}
|
|
46
|
+
className="flex items-center justify-between rounded-3xl px-4 py-3 text-start text-body text-label hover:bg-fill aria-pressed:text-accent-text"
|
|
47
|
+
>
|
|
48
|
+
{item}
|
|
49
|
+
{item === language && (
|
|
50
|
+
<span aria-hidden>✓</span>
|
|
51
|
+
)}
|
|
52
|
+
</button>
|
|
53
|
+
))}
|
|
54
|
+
</div>
|
|
55
|
+
</Sheet>
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { toast } from "@passui/react"
|
|
2
|
+
import { Button } from "@passui/react/button"
|
|
3
|
+
import { Sheet } from "@passui/react/sheet"
|
|
4
|
+
import { Toggle } from "@passui/react/toggle"
|
|
5
|
+
import { useState } from "react"
|
|
6
|
+
|
|
7
|
+
export function SheetShare() {
|
|
8
|
+
const [open, setOpen] = useState(false)
|
|
9
|
+
const [canEdit, setCanEdit] = useState(false)
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<>
|
|
13
|
+
<Button onClick={() => setOpen(true)}>
|
|
14
|
+
Share
|
|
15
|
+
</Button>
|
|
16
|
+
<Sheet
|
|
17
|
+
open={open}
|
|
18
|
+
onClose={() => setOpen(false)}
|
|
19
|
+
label="Share note"
|
|
20
|
+
>
|
|
21
|
+
<div className="flex flex-col gap-5 p-6">
|
|
22
|
+
<h2 className="text-title3 font-semibold text-label">
|
|
23
|
+
Share note
|
|
24
|
+
</h2>
|
|
25
|
+
<Toggle
|
|
26
|
+
label="People with the link can edit"
|
|
27
|
+
checked={canEdit}
|
|
28
|
+
onChange={setCanEdit}
|
|
29
|
+
/>
|
|
30
|
+
<div className="flex justify-end gap-2">
|
|
31
|
+
<Button
|
|
32
|
+
variant="secondary"
|
|
33
|
+
onClick={() => setOpen(false)}
|
|
34
|
+
>
|
|
35
|
+
Cancel
|
|
36
|
+
</Button>
|
|
37
|
+
<Button
|
|
38
|
+
variant="accent"
|
|
39
|
+
onClick={() => {
|
|
40
|
+
setOpen(false)
|
|
41
|
+
toast.success("Link copied")
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
Copy link
|
|
45
|
+
</Button>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</Sheet>
|
|
49
|
+
</>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LabeledContent,
|
|
3
|
+
Section,
|
|
4
|
+
SwatchPicker,
|
|
5
|
+
} from "@passui/react"
|
|
6
|
+
import { Button } from "@passui/react/button"
|
|
7
|
+
import { Sheet } from "@passui/react/sheet"
|
|
8
|
+
import { useState } from "react"
|
|
9
|
+
|
|
10
|
+
const accents = [
|
|
11
|
+
{
|
|
12
|
+
value: "blush",
|
|
13
|
+
label: "Blush",
|
|
14
|
+
color: "#f2d4d7",
|
|
15
|
+
ink: "#9e3b4f",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
value: "sage",
|
|
19
|
+
label: "Sage",
|
|
20
|
+
color: "#d6e6d3",
|
|
21
|
+
ink: "#3f6b45",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: "ocean",
|
|
25
|
+
label: "Ocean",
|
|
26
|
+
color: "#d3e3f2",
|
|
27
|
+
ink: "#2f5f8f",
|
|
28
|
+
},
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
export function SheetShowcase() {
|
|
32
|
+
const [open, setOpen] = useState(false)
|
|
33
|
+
const [accent, setAccent] = useState("blush")
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="w-full max-w-sm">
|
|
37
|
+
<Section title="Appearance">
|
|
38
|
+
<LabeledContent label="Accent color">
|
|
39
|
+
<Button
|
|
40
|
+
variant="ghost"
|
|
41
|
+
size="sm"
|
|
42
|
+
onClick={() => setOpen(true)}
|
|
43
|
+
>
|
|
44
|
+
{
|
|
45
|
+
accents.find(
|
|
46
|
+
(a) => a.value === accent
|
|
47
|
+
)?.label
|
|
48
|
+
}
|
|
49
|
+
</Button>
|
|
50
|
+
</LabeledContent>
|
|
51
|
+
</Section>
|
|
52
|
+
<Sheet
|
|
53
|
+
open={open}
|
|
54
|
+
onClose={() => setOpen(false)}
|
|
55
|
+
label="Accent color"
|
|
56
|
+
>
|
|
57
|
+
<div className="flex flex-col gap-5 p-6">
|
|
58
|
+
<h2 className="text-title3 font-semibold text-label">
|
|
59
|
+
Accent color
|
|
60
|
+
</h2>
|
|
61
|
+
<SwatchPicker
|
|
62
|
+
label="Accent color"
|
|
63
|
+
options={accents}
|
|
64
|
+
value={accent}
|
|
65
|
+
onChange={setAccent}
|
|
66
|
+
/>
|
|
67
|
+
<Button onClick={() => setOpen(false)}>
|
|
68
|
+
Done
|
|
69
|
+
</Button>
|
|
70
|
+
</div>
|
|
71
|
+
</Sheet>
|
|
72
|
+
</div>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Button } from "@passui/react/button"
|
|
2
|
+
import { Sheet } from "@passui/react/sheet"
|
|
3
|
+
import { useState } from "react"
|
|
4
|
+
|
|
5
|
+
export function SheetUsage() {
|
|
6
|
+
const [open, setOpen] = useState(false)
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<Button
|
|
11
|
+
variant="secondary"
|
|
12
|
+
onClick={() => setOpen(true)}
|
|
13
|
+
>
|
|
14
|
+
About this app
|
|
15
|
+
</Button>
|
|
16
|
+
<Sheet
|
|
17
|
+
open={open}
|
|
18
|
+
onClose={() => setOpen(false)}
|
|
19
|
+
label="About this app"
|
|
20
|
+
>
|
|
21
|
+
<div className="flex flex-col gap-2 p-6">
|
|
22
|
+
<h2 className="text-title3 font-semibold text-label">
|
|
23
|
+
Pass
|
|
24
|
+
</h2>
|
|
25
|
+
<p className="text-callout text-label-secondary">
|
|
26
|
+
Version 2.4. Made in Lisbon.
|
|
27
|
+
</p>
|
|
28
|
+
</div>
|
|
29
|
+
</Sheet>
|
|
30
|
+
</>
|
|
31
|
+
)
|
|
32
|
+
}
|