@mrpelz/uikit-ish 0.0.0-stage → 7.8.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/dist/components/action-sheet/main.d.ts +39 -0
- package/dist/components/action-sheet/main.d.ts.map +1 -0
- package/dist/components/action-sheet/main.js +35 -0
- package/dist/components/action-sheet/main.js.map +1 -0
- package/dist/components/action-sheet/props.d.ts +10 -0
- package/dist/components/action-sheet/props.d.ts.map +1 -0
- package/dist/components/action-sheet/props.js +2 -0
- package/dist/components/action-sheet/props.js.map +1 -0
- package/dist/components/action-sheet/style.css +8 -0
- package/dist/components/activity-view/main.d.ts +45 -0
- package/dist/components/activity-view/main.d.ts.map +1 -0
- package/dist/components/activity-view/main.js +64 -0
- package/dist/components/activity-view/main.js.map +1 -0
- package/dist/components/activity-view/props.d.ts +12 -0
- package/dist/components/activity-view/props.d.ts.map +1 -0
- package/dist/components/activity-view/props.js +2 -0
- package/dist/components/activity-view/props.js.map +1 -0
- package/dist/components/activity-view/style.css +209 -0
- package/dist/components/alert/main.d.ts +53 -0
- package/dist/components/alert/main.d.ts.map +1 -0
- package/dist/components/alert/main.js +57 -0
- package/dist/components/alert/main.js.map +1 -0
- package/dist/components/alert/props.d.ts +18 -0
- package/dist/components/alert/props.d.ts.map +1 -0
- package/dist/components/alert/props.js +2 -0
- package/dist/components/alert/props.js.map +1 -0
- package/dist/components/alert/style.css +205 -0
- package/dist/components/avatar/main.d.ts +20 -0
- package/dist/components/avatar/main.d.ts.map +1 -0
- package/dist/components/avatar/main.js +42 -0
- package/dist/components/avatar/main.js.map +1 -0
- package/dist/components/avatar/props.d.ts +18 -0
- package/dist/components/avatar/props.d.ts.map +1 -0
- package/dist/components/avatar/props.js +2 -0
- package/dist/components/avatar/props.js.map +1 -0
- package/dist/components/avatar/style.css +83 -0
- package/dist/components/badge/main.d.ts +12 -0
- package/dist/components/badge/main.d.ts.map +1 -0
- package/dist/components/badge/main.js +33 -0
- package/dist/components/badge/main.js.map +1 -0
- package/dist/components/badge/props.d.ts +20 -0
- package/dist/components/badge/props.d.ts.map +1 -0
- package/dist/components/badge/props.js +2 -0
- package/dist/components/badge/props.js.map +1 -0
- package/dist/components/badge/style.css +71 -0
- package/dist/components/button/main.d.ts +16 -0
- package/dist/components/button/main.d.ts.map +1 -0
- package/dist/components/button/main.js +64 -0
- package/dist/components/button/main.js.map +1 -0
- package/dist/components/button/props.d.ts +45 -0
- package/dist/components/button/props.d.ts.map +1 -0
- package/dist/components/button/props.js +2 -0
- package/dist/components/button/props.js.map +1 -0
- package/dist/components/button/style.css +338 -0
- package/dist/components/checkbox/main.d.ts +23 -0
- package/dist/components/checkbox/main.d.ts.map +1 -0
- package/dist/components/checkbox/main.js +43 -0
- package/dist/components/checkbox/main.js.map +1 -0
- package/dist/components/checkbox/props.d.ts +14 -0
- package/dist/components/checkbox/props.d.ts.map +1 -0
- package/dist/components/checkbox/props.js +2 -0
- package/dist/components/checkbox/props.js.map +1 -0
- package/dist/components/checkbox/style.css +73 -0
- package/dist/components/color-picker/main.d.ts +31 -0
- package/dist/components/color-picker/main.d.ts.map +1 -0
- package/dist/components/color-picker/main.js +356 -0
- package/dist/components/color-picker/main.js.map +1 -0
- package/dist/components/color-picker/props.d.ts +61 -0
- package/dist/components/color-picker/props.d.ts.map +1 -0
- package/dist/components/color-picker/props.js +2 -0
- package/dist/components/color-picker/props.js.map +1 -0
- package/dist/components/color-picker/style.css +374 -0
- package/dist/components/contextual-menu/main.d.ts +84 -0
- package/dist/components/contextual-menu/main.d.ts.map +1 -0
- package/dist/components/contextual-menu/main.js +255 -0
- package/dist/components/contextual-menu/main.js.map +1 -0
- package/dist/components/contextual-menu/props.d.ts +44 -0
- package/dist/components/contextual-menu/props.d.ts.map +1 -0
- package/dist/components/contextual-menu/props.js +2 -0
- package/dist/components/contextual-menu/props.js.map +1 -0
- package/dist/components/contextual-menu/style.css +80 -0
- package/dist/components/date-picker/main.d.ts +57 -0
- package/dist/components/date-picker/main.d.ts.map +1 -0
- package/dist/components/date-picker/main.js +770 -0
- package/dist/components/date-picker/main.js.map +1 -0
- package/dist/components/date-picker/props.d.ts +220 -0
- package/dist/components/date-picker/props.d.ts.map +1 -0
- package/dist/components/date-picker/props.js +2 -0
- package/dist/components/date-picker/props.js.map +1 -0
- package/dist/components/date-picker/style.css +446 -0
- package/dist/components/edit-menu/main.d.ts +71 -0
- package/dist/components/edit-menu/main.d.ts.map +1 -0
- package/dist/components/edit-menu/main.js +317 -0
- package/dist/components/edit-menu/main.js.map +1 -0
- package/dist/components/edit-menu/props.d.ts +21 -0
- package/dist/components/edit-menu/props.d.ts.map +1 -0
- package/dist/components/edit-menu/props.js +2 -0
- package/dist/components/edit-menu/props.js.map +1 -0
- package/dist/components/edit-menu/style.css +189 -0
- package/dist/components/form/main.d.ts +21 -0
- package/dist/components/form/main.d.ts.map +1 -0
- package/dist/components/form/main.js +32 -0
- package/dist/components/form/main.js.map +1 -0
- package/dist/components/form/props.d.ts +4 -0
- package/dist/components/form/props.d.ts.map +1 -0
- package/dist/components/form/props.js +2 -0
- package/dist/components/form/props.js.map +1 -0
- package/dist/components/form/style.css +9 -0
- package/dist/components/glass/main.d.ts +34 -0
- package/dist/components/glass/main.d.ts.map +1 -0
- package/dist/components/glass/main.js +157 -0
- package/dist/components/glass/main.js.map +1 -0
- package/dist/components/glass/props.d.ts +22 -0
- package/dist/components/glass/props.d.ts.map +1 -0
- package/dist/components/glass/props.js +2 -0
- package/dist/components/glass/props.js.map +1 -0
- package/dist/components/glass/style.css +488 -0
- package/dist/components/header/main.d.ts +15 -0
- package/dist/components/header/main.d.ts.map +1 -0
- package/dist/components/header/main.js +78 -0
- package/dist/components/header/main.js.map +1 -0
- package/dist/components/header/props.d.ts +16 -0
- package/dist/components/header/props.d.ts.map +1 -0
- package/dist/components/header/props.js +2 -0
- package/dist/components/header/props.js.map +1 -0
- package/dist/components/header/style.css +119 -0
- package/dist/components/index.d.ts +38 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +45 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/layout/main.d.ts +15 -0
- package/dist/components/layout/main.d.ts.map +1 -0
- package/dist/components/layout/main.js +241 -0
- package/dist/components/layout/main.js.map +1 -0
- package/dist/components/layout/props.d.ts +52 -0
- package/dist/components/layout/props.d.ts.map +1 -0
- package/dist/components/layout/props.js +2 -0
- package/dist/components/layout/props.js.map +1 -0
- package/dist/components/layout/style.css +208 -0
- package/dist/components/list/main.d.ts +104 -0
- package/dist/components/list/main.d.ts.map +1 -0
- package/dist/components/list/main.js +1553 -0
- package/dist/components/list/main.js.map +1 -0
- package/dist/components/list/props.d.ts +178 -0
- package/dist/components/list/props.d.ts.map +1 -0
- package/dist/components/list/props.js +2 -0
- package/dist/components/list/props.js.map +1 -0
- package/dist/components/list/style.css +1689 -0
- package/dist/components/menu/main.d.ts +119 -0
- package/dist/components/menu/main.d.ts.map +1 -0
- package/dist/components/menu/main.js +487 -0
- package/dist/components/menu/main.js.map +1 -0
- package/dist/components/menu/props.d.ts +54 -0
- package/dist/components/menu/props.d.ts.map +1 -0
- package/dist/components/menu/props.js +2 -0
- package/dist/components/menu/props.js.map +1 -0
- package/dist/components/menu/style.css +446 -0
- package/dist/components/navigation/main.d.ts +9 -0
- package/dist/components/navigation/main.d.ts.map +1 -0
- package/dist/components/navigation/main.js +201 -0
- package/dist/components/navigation/main.js.map +1 -0
- package/dist/components/navigation/props.d.ts +16 -0
- package/dist/components/navigation/props.d.ts.map +1 -0
- package/dist/components/navigation/props.js +2 -0
- package/dist/components/navigation/props.js.map +1 -0
- package/dist/components/navigation/style.css +83 -0
- package/dist/components/page/main.d.ts +9 -0
- package/dist/components/page/main.d.ts.map +1 -0
- package/dist/components/page/main.js +20 -0
- package/dist/components/page/main.js.map +1 -0
- package/dist/components/page/props.d.ts +10 -0
- package/dist/components/page/props.d.ts.map +1 -0
- package/dist/components/page/props.js +2 -0
- package/dist/components/page/props.js.map +1 -0
- package/dist/components/page/style.css +19 -0
- package/dist/components/page-control/main.d.ts +13 -0
- package/dist/components/page-control/main.d.ts.map +1 -0
- package/dist/components/page-control/main.js +138 -0
- package/dist/components/page-control/main.js.map +1 -0
- package/dist/components/page-control/props.d.ts +36 -0
- package/dist/components/page-control/props.d.ts.map +1 -0
- package/dist/components/page-control/props.js +2 -0
- package/dist/components/page-control/props.js.map +1 -0
- package/dist/components/page-control/style.css +111 -0
- package/dist/components/popover/main.d.ts +34 -0
- package/dist/components/popover/main.d.ts.map +1 -0
- package/dist/components/popover/main.js +232 -0
- package/dist/components/popover/main.js.map +1 -0
- package/dist/components/popover/props.d.ts +23 -0
- package/dist/components/popover/props.d.ts.map +1 -0
- package/dist/components/popover/props.js +2 -0
- package/dist/components/popover/props.js.map +1 -0
- package/dist/components/popover/style.css +160 -0
- package/dist/components/progress/main.d.ts +31 -0
- package/dist/components/progress/main.d.ts.map +1 -0
- package/dist/components/progress/main.js +77 -0
- package/dist/components/progress/main.js.map +1 -0
- package/dist/components/progress/props.d.ts +56 -0
- package/dist/components/progress/props.d.ts.map +1 -0
- package/dist/components/progress/props.js +2 -0
- package/dist/components/progress/props.js.map +1 -0
- package/dist/components/progress/style.css +264 -0
- package/dist/components/roll/main.d.ts +18 -0
- package/dist/components/roll/main.d.ts.map +1 -0
- package/dist/components/roll/main.js +463 -0
- package/dist/components/roll/main.js.map +1 -0
- package/dist/components/roll/props.d.ts +58 -0
- package/dist/components/roll/props.d.ts.map +1 -0
- package/dist/components/roll/props.js +2 -0
- package/dist/components/roll/props.js.map +1 -0
- package/dist/components/roll/style.css +173 -0
- package/dist/components/segmented/main.d.ts +17 -0
- package/dist/components/segmented/main.d.ts.map +1 -0
- package/dist/components/segmented/main.js +151 -0
- package/dist/components/segmented/main.js.map +1 -0
- package/dist/components/segmented/props.d.ts +16 -0
- package/dist/components/segmented/props.d.ts.map +1 -0
- package/dist/components/segmented/props.js +2 -0
- package/dist/components/segmented/props.js.map +1 -0
- package/dist/components/segmented/style.css +428 -0
- package/dist/components/sheet/main.d.ts +32 -0
- package/dist/components/sheet/main.d.ts.map +1 -0
- package/dist/components/sheet/main.js +101 -0
- package/dist/components/sheet/main.js.map +1 -0
- package/dist/components/sheet/props.d.ts +11 -0
- package/dist/components/sheet/props.d.ts.map +1 -0
- package/dist/components/sheet/props.js +2 -0
- package/dist/components/sheet/props.js.map +1 -0
- package/dist/components/sheet/style.css +125 -0
- package/dist/components/sidebar/main.d.ts +15 -0
- package/dist/components/sidebar/main.d.ts.map +1 -0
- package/dist/components/sidebar/main.js +42 -0
- package/dist/components/sidebar/main.js.map +1 -0
- package/dist/components/sidebar/props.d.ts +5 -0
- package/dist/components/sidebar/props.d.ts.map +1 -0
- package/dist/components/sidebar/props.js +2 -0
- package/dist/components/sidebar/props.js.map +1 -0
- package/dist/components/sidebar/style.css +94 -0
- package/dist/components/slider/main.d.ts +35 -0
- package/dist/components/slider/main.d.ts.map +1 -0
- package/dist/components/slider/main.js +153 -0
- package/dist/components/slider/main.js.map +1 -0
- package/dist/components/slider/props.d.ts +56 -0
- package/dist/components/slider/props.d.ts.map +1 -0
- package/dist/components/slider/props.js +2 -0
- package/dist/components/slider/props.js.map +1 -0
- package/dist/components/slider/style.css +345 -0
- package/dist/components/stepper/main.d.ts +22 -0
- package/dist/components/stepper/main.d.ts.map +1 -0
- package/dist/components/stepper/main.js +56 -0
- package/dist/components/stepper/main.js.map +1 -0
- package/dist/components/stepper/props.d.ts +10 -0
- package/dist/components/stepper/props.d.ts.map +1 -0
- package/dist/components/stepper/props.js +2 -0
- package/dist/components/stepper/props.js.map +1 -0
- package/dist/components/stepper/style.css +115 -0
- package/dist/components/switch/main.d.ts +14 -0
- package/dist/components/switch/main.d.ts.map +1 -0
- package/dist/components/switch/main.js +143 -0
- package/dist/components/switch/main.js.map +1 -0
- package/dist/components/switch/props.d.ts +34 -0
- package/dist/components/switch/props.d.ts.map +1 -0
- package/dist/components/switch/props.js +2 -0
- package/dist/components/switch/props.js.map +1 -0
- package/dist/components/switch/style.css +168 -0
- package/dist/components/symbol/main.d.ts +8 -0
- package/dist/components/symbol/main.d.ts.map +1 -0
- package/dist/components/symbol/main.js +32 -0
- package/dist/components/symbol/main.js.map +1 -0
- package/dist/components/symbol/props.d.ts +10 -0
- package/dist/components/symbol/props.d.ts.map +1 -0
- package/dist/components/symbol/props.js +2 -0
- package/dist/components/symbol/props.js.map +1 -0
- package/dist/components/symbol/style.css +26 -0
- package/dist/components/tab-bar/main.d.ts +39 -0
- package/dist/components/tab-bar/main.d.ts.map +1 -0
- package/dist/components/tab-bar/main.js +1133 -0
- package/dist/components/tab-bar/main.js.map +1 -0
- package/dist/components/tab-bar/props.d.ts +152 -0
- package/dist/components/tab-bar/props.d.ts.map +1 -0
- package/dist/components/tab-bar/props.js +2 -0
- package/dist/components/tab-bar/props.js.map +1 -0
- package/dist/components/tab-bar/style.css +936 -0
- package/dist/components/text-field/main.d.ts +28 -0
- package/dist/components/text-field/main.d.ts.map +1 -0
- package/dist/components/text-field/main.js +105 -0
- package/dist/components/text-field/main.js.map +1 -0
- package/dist/components/text-field/props.d.ts +3 -0
- package/dist/components/text-field/props.d.ts.map +1 -0
- package/dist/components/text-field/props.js +2 -0
- package/dist/components/text-field/props.js.map +1 -0
- package/dist/components/text-field/style.css +230 -0
- package/dist/components/toolbar/main.d.ts +37 -0
- package/dist/components/toolbar/main.d.ts.map +1 -0
- package/dist/components/toolbar/main.js +142 -0
- package/dist/components/toolbar/main.js.map +1 -0
- package/dist/components/toolbar/props.d.ts +46 -0
- package/dist/components/toolbar/props.d.ts.map +1 -0
- package/dist/components/toolbar/props.js +2 -0
- package/dist/components/toolbar/props.js.map +1 -0
- package/dist/components/toolbar/style.css +210 -0
- package/dist/components/tooltip/main.d.ts +29 -0
- package/dist/components/tooltip/main.d.ts.map +1 -0
- package/dist/components/tooltip/main.js +37 -0
- package/dist/components/tooltip/main.js.map +1 -0
- package/dist/components/tooltip/props.d.ts +11 -0
- package/dist/components/tooltip/props.d.ts.map +1 -0
- package/dist/components/tooltip/props.js +2 -0
- package/dist/components/tooltip/props.js.map +1 -0
- package/dist/components/tooltip/style.css +29 -0
- package/dist/components/typography/main.d.ts +8 -0
- package/dist/components/typography/main.d.ts.map +1 -0
- package/dist/components/typography/main.js +21 -0
- package/dist/components/typography/main.js.map +1 -0
- package/dist/components/typography/props.d.ts +35 -0
- package/dist/components/typography/props.d.ts.map +1 -0
- package/dist/components/typography/props.js +2 -0
- package/dist/components/typography/props.js.map +1 -0
- package/dist/components/typography/style.css +719 -0
- package/dist/components/utils/main.d.ts +114 -0
- package/dist/components/utils/main.d.ts.map +1 -0
- package/dist/components/utils/main.js +431 -0
- package/dist/components/utils/main.js.map +1 -0
- package/dist/components/utils/props.d.ts +52 -0
- package/dist/components/utils/props.d.ts.map +1 -0
- package/dist/components/utils/props.js +2 -0
- package/dist/components/utils/props.js.map +1 -0
- package/dist/components/utils/style.css +77 -0
- package/dist/components/viewport/main.d.ts +32 -0
- package/dist/components/viewport/main.d.ts.map +1 -0
- package/dist/components/viewport/main.js +197 -0
- package/dist/components/viewport/main.js.map +1 -0
- package/dist/components/viewport/props.d.ts +71 -0
- package/dist/components/viewport/props.d.ts.map +1 -0
- package/dist/components/viewport/props.js +2 -0
- package/dist/components/viewport/props.js.map +1 -0
- package/dist/components/viewport/style.css +112 -0
- package/dist/main.d.ts +4 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -0
- package/dist/styles.css +567 -0
- package/dist/styles.d.ts +25 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +39 -0
- package/dist/styles.js.map +1 -0
- package/package.json +55 -4
- package/README.md +0 -3
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import '../glass/style.css';
|
|
3
|
+
import './style.css';
|
|
4
|
+
import { Switch as BaseSwitch } from '@base-ui/react/switch';
|
|
5
|
+
import { forwardRef, useCallback, useLayoutEffect, useRef, } from 'react';
|
|
6
|
+
import { cn, usePointerDrag, withStyle } from '../utils/main.js';
|
|
7
|
+
// Source: Apple iOS 26 Figma (“Toggle - Switch”, light and dark appearance),
|
|
8
|
+
// with Figma colors mapped to UIKit semantic colors: on `systemGreen` (or
|
|
9
|
+
// `tint`, UIKit `onTintColor`), off `systemFill`; the knob (`#fff`) has no
|
|
10
|
+
// semantic equivalent.
|
|
11
|
+
// The pressed glass effect and everything Figma does not specify come from
|
|
12
|
+
// Framework7 `components/toggle/toggle.less`, `toggle-ios.less` (iOS values,
|
|
13
|
+
// `.toggle-active-state`): transitions, pressed scales, glow, glass shadow.
|
|
14
|
+
//
|
|
15
|
+
// Deviations:
|
|
16
|
+
// - The track's end cap (Framework7 `.toggle::after`) is omitted, as it shows
|
|
17
|
+
// as a separate circle while the pressed track shrinks.
|
|
18
|
+
// - Track size (64×28) is a minimum, not a fixed size; the knob is positioned
|
|
19
|
+
// with `inset-inline-start` instead of a fixed translation, so it adapts to
|
|
20
|
+
// the actual width and to right-to-left layouts.
|
|
21
|
+
// - The pressed state is driven by `:active` and custom properties inherited
|
|
22
|
+
// by the thumb, instead of Framework7's JS-driven `.toggle-active-state`.
|
|
23
|
+
// - Dragging (Framework7 `toggle-class.js`) moves the knob with the pointer,
|
|
24
|
+
// like the tab bar's lens, instead of only flipping the state after a third
|
|
25
|
+
// of the width: the state flips whenever the knob's center crosses the
|
|
26
|
+
// middle, and the knob settles on release. Releases within 300ms that did
|
|
27
|
+
// not flip the state act as a tap (toggling), unless they flick towards the
|
|
28
|
+
// current side (Framework7: swipes within 300ms toggle).
|
|
29
|
+
// - The browser's default focus ring is kept.
|
|
30
|
+
// - Indeterminate (as a checkbox, which the platform's switches are; UIKit:
|
|
31
|
+
// none): the knob in the middle, on the off color.
|
|
32
|
+
//
|
|
33
|
+
// On/off labels (UIKit's accessibility setting “On/Off Labels”, measured on
|
|
34
|
+
// Apple's illustration): a 9px “I” bar (white) and a 9px “O” ring (tertiary
|
|
35
|
+
// label), 1px strokes, each centered in the track beside the knob on its
|
|
36
|
+
// side; the knob covers the other (both hidden while indeterminate, and
|
|
37
|
+
// while pressed, as the knob is a lens).
|
|
38
|
+
// Base UI's root, the props that only style it as attributes and properties.
|
|
39
|
+
const BaseRoot = forwardRef(({ indeterminate, style, tint, ...props }, ref) => (_jsx(BaseSwitch.Root, { ref: ref, "data-indeterminate": indeterminate ? '' : undefined, style: withStyle({ '--uikit-switch-on-color': tint }, style), ...props })));
|
|
40
|
+
// The pressed state is set here too, as `:active` is lost when the state
|
|
41
|
+
// flips during a drag.
|
|
42
|
+
const dragProperties = [
|
|
43
|
+
'--uikit-switch-knob-move-duration',
|
|
44
|
+
'--uikit-switch-knob-start',
|
|
45
|
+
'--uikit-switch-pressed',
|
|
46
|
+
];
|
|
47
|
+
const isChecked = (root) => Object.hasOwn(root.dataset, 'checked');
|
|
48
|
+
const Root = forwardRef(({ className, onClickCapture, onLostPointerCapture, onPointerCancel, onPointerDown, onPointerMove, onPointerUp, children, indeterminate = false, inputRef, onOffLabels = false, ...props }, ref) => {
|
|
49
|
+
const suppressClickRef = useRef(false);
|
|
50
|
+
// The hidden input is indeterminate, too (as a checkbox's).
|
|
51
|
+
const ownInputRef = useRef(null);
|
|
52
|
+
const handleInputRef = useCallback((element) => {
|
|
53
|
+
ownInputRef.current = element;
|
|
54
|
+
if (typeof inputRef === 'function') {
|
|
55
|
+
inputRef(element);
|
|
56
|
+
}
|
|
57
|
+
else if (inputRef) {
|
|
58
|
+
inputRef.current = element;
|
|
59
|
+
}
|
|
60
|
+
}, [inputRef]);
|
|
61
|
+
useLayoutEffect(() => {
|
|
62
|
+
const { current: input } = ownInputRef;
|
|
63
|
+
if (input)
|
|
64
|
+
input.indeterminate = indeterminate;
|
|
65
|
+
});
|
|
66
|
+
const handlers = usePointerDrag({
|
|
67
|
+
end: (root, drag, cancelled) => {
|
|
68
|
+
for (const property of dragProperties) {
|
|
69
|
+
root.style.removeProperty(property);
|
|
70
|
+
}
|
|
71
|
+
if (cancelled)
|
|
72
|
+
return;
|
|
73
|
+
const quick = performance.now() - drag.startTime < 300;
|
|
74
|
+
const towardsCurrent = drag.checked ? drag.moved > 0 : drag.moved < 0;
|
|
75
|
+
// The native click following this release toggles; suppress it
|
|
76
|
+
// unless the release acts as a tap.
|
|
77
|
+
suppressClickRef.current = drag.flipped || !quick || towardsCurrent;
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
suppressClickRef.current = false;
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
move: (root, drag, event) => {
|
|
83
|
+
drag.moved = (event.clientX - drag.startX) * drag.direction;
|
|
84
|
+
const start = Math.max(drag.min, Math.min(drag.start + drag.moved, drag.max));
|
|
85
|
+
root.style.setProperty('--uikit-switch-knob-move-duration', '0s');
|
|
86
|
+
root.style.setProperty('--uikit-switch-knob-start', `${start}px`);
|
|
87
|
+
const checked = (start - drag.min) / (drag.max - drag.min) > 0.5;
|
|
88
|
+
if (checked === isChecked(root))
|
|
89
|
+
return;
|
|
90
|
+
drag.flipped = true;
|
|
91
|
+
root.click();
|
|
92
|
+
},
|
|
93
|
+
start: (root, event) => {
|
|
94
|
+
const { firstElementChild: thumb } = root;
|
|
95
|
+
if (!(thumb instanceof HTMLElement))
|
|
96
|
+
return undefined;
|
|
97
|
+
if (Object.hasOwn(root.dataset, 'disabled') ||
|
|
98
|
+
Object.hasOwn(root.dataset, 'readonly')) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
const rootRect = root.getBoundingClientRect();
|
|
102
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
103
|
+
const direction = getComputedStyle(root).direction === 'rtl' ? -1 : 1;
|
|
104
|
+
const min = Number.parseFloat(getComputedStyle(thumb).top);
|
|
105
|
+
root.style.setProperty('--uikit-switch-pressed', '1');
|
|
106
|
+
return {
|
|
107
|
+
checked: isChecked(root),
|
|
108
|
+
direction,
|
|
109
|
+
flipped: false,
|
|
110
|
+
max: rootRect.width - thumbRect.width - min,
|
|
111
|
+
min,
|
|
112
|
+
moved: 0,
|
|
113
|
+
start: direction === 1
|
|
114
|
+
? thumbRect.left - rootRect.left
|
|
115
|
+
: rootRect.right - thumbRect.right,
|
|
116
|
+
startTime: performance.now(),
|
|
117
|
+
startX: event.clientX,
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
}, {
|
|
121
|
+
onLostPointerCapture,
|
|
122
|
+
onPointerCancel,
|
|
123
|
+
onPointerDown,
|
|
124
|
+
onPointerMove,
|
|
125
|
+
onPointerUp,
|
|
126
|
+
});
|
|
127
|
+
const handleClickCapture = useCallback((event) => {
|
|
128
|
+
onClickCapture?.(event);
|
|
129
|
+
if (!suppressClickRef.current)
|
|
130
|
+
return;
|
|
131
|
+
suppressClickRef.current = false;
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
event.stopImmediatePropagation();
|
|
134
|
+
}, [onClickCapture]);
|
|
135
|
+
return (_jsxs(BaseRoot, { ref: ref, indeterminate: indeterminate, inputRef: handleInputRef, ...props, ...handlers, className: cn('uikit-switch-root', className), "data-switch-part": "root", onClickCapture: handleClickCapture, children: [children, onOffLabels ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", className: "uikit-switch-on-label", "data-switch-part": "label" }), _jsx("span", { "aria-hidden": "true", className: "uikit-switch-off-label", "data-switch-part": "label" })] })) : null] }));
|
|
136
|
+
});
|
|
137
|
+
const Thumb = forwardRef(({ className, ...props }, ref) => (_jsx(BaseSwitch.Thumb, { ref: ref, className: cn('uikit-switch-thumb', className), "data-switch-part": "thumb", ...props })));
|
|
138
|
+
export const Switch = {
|
|
139
|
+
...BaseSwitch,
|
|
140
|
+
Root,
|
|
141
|
+
Thumb,
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src/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,OAAO,KACpB,KAAK,GACT,CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,GAAG,UAAU;IACb,IAAI;IACJ,KAAK;CACN,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Switch as BaseSwitch } from '@base-ui/react/switch';
|
|
2
|
+
import type { Properties } from 'csstype';
|
|
3
|
+
export type SwitchRootProps = BaseSwitch.Root.Props & {
|
|
4
|
+
/**
|
|
5
|
+
* The cursor (where the pointer hovers).
|
|
6
|
+
* @default 'pointer' (disabled: 'not-allowed')
|
|
7
|
+
*/
|
|
8
|
+
cursor?: Properties['cursor'];
|
|
9
|
+
/**
|
|
10
|
+
* Neither on nor off (as a checkbox's `indeterminate`, also of the hidden
|
|
11
|
+
* input): the knob in the middle. Toggling still flips `checked`.
|
|
12
|
+
*/
|
|
13
|
+
indeterminate?: boolean;
|
|
14
|
+
/** Shows “I” and “O” on the track (UIKit's “On/Off Labels”). */
|
|
15
|
+
onOffLabels?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The track's color while on, and the pressed knob's glow (UIKit
|
|
18
|
+
* `onTintColor`).
|
|
19
|
+
* @default `systemGreen`
|
|
20
|
+
*/
|
|
21
|
+
tint?: string;
|
|
22
|
+
};
|
|
23
|
+
export type Drag = {
|
|
24
|
+
checked: boolean;
|
|
25
|
+
direction: 1 | -1;
|
|
26
|
+
flipped: boolean;
|
|
27
|
+
max: number;
|
|
28
|
+
min: number;
|
|
29
|
+
moved: number;
|
|
30
|
+
start: number;
|
|
31
|
+
startTime: number;
|
|
32
|
+
startX: number;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/components/switch/props.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG;IACpD;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gEAAgE;IAChE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/components/switch/props.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/* Switch (see main.tsx). */
|
|
2
|
+
@layer uikit-ish {
|
|
3
|
+
.uikit-switch-on-label {
|
|
4
|
+
position: absolute;
|
|
5
|
+
display: grid;
|
|
6
|
+
width: calc(100% - var(--uikit-switch-knob-width) - 2px);
|
|
7
|
+
inset-block: 0;
|
|
8
|
+
inset-inline-start: 0;
|
|
9
|
+
opacity: calc(1 - var(--uikit-switch-pressed));
|
|
10
|
+
place-items: center;
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
transition: opacity var(--glass-ios-lens-duration);
|
|
13
|
+
|
|
14
|
+
&::before {
|
|
15
|
+
width: 1px;
|
|
16
|
+
height: 9px;
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
border-radius: 1px;
|
|
19
|
+
background-color: #fff;
|
|
20
|
+
content: '';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.uikit-switch-off-label {
|
|
25
|
+
position: absolute;
|
|
26
|
+
display: grid;
|
|
27
|
+
width: calc(100% - var(--uikit-switch-knob-width) - 2px);
|
|
28
|
+
inset-block: 0;
|
|
29
|
+
inset-inline-end: 0;
|
|
30
|
+
opacity: calc(1 - var(--uikit-switch-pressed));
|
|
31
|
+
place-items: center;
|
|
32
|
+
pointer-events: none;
|
|
33
|
+
transition: opacity var(--glass-ios-lens-duration);
|
|
34
|
+
|
|
35
|
+
&::before {
|
|
36
|
+
width: 9px;
|
|
37
|
+
height: 9px;
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
border: 1px solid var(--color-ios-tertiary-label);
|
|
40
|
+
border-radius: 50%;
|
|
41
|
+
content: '';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.uikit-switch-root {
|
|
46
|
+
--uikit-utils-cursor: attr(cursor type(<custom-ident>), pointer);
|
|
47
|
+
--uikit-switch-min-width: 64px;
|
|
48
|
+
--uikit-switch-min-height: 28px;
|
|
49
|
+
--uikit-switch-knob-width: 39px;
|
|
50
|
+
--uikit-switch-knob-start: 2px;
|
|
51
|
+
--uikit-switch-pressed: 0;
|
|
52
|
+
--uikit-switch-on-color: var(--color-ios-system-green);
|
|
53
|
+
--uikit-switch-off-color: var(--color-ios-system-fill);
|
|
54
|
+
|
|
55
|
+
position: relative;
|
|
56
|
+
display: inline-block;
|
|
57
|
+
min-width: var(--uikit-switch-min-width);
|
|
58
|
+
min-height: var(--uikit-switch-min-height);
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
align-self: center;
|
|
61
|
+
border-radius: 100px;
|
|
62
|
+
touch-action: pan-y;
|
|
63
|
+
user-select: none;
|
|
64
|
+
vertical-align: middle;
|
|
65
|
+
|
|
66
|
+
@media (hover: hover) {
|
|
67
|
+
cursor: var(--uikit-utils-cursor);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&::before {
|
|
71
|
+
position: absolute;
|
|
72
|
+
z-index: 0;
|
|
73
|
+
border-radius: inherit;
|
|
74
|
+
background-color: var(--uikit-switch-off-color);
|
|
75
|
+
content: '';
|
|
76
|
+
inset: 0;
|
|
77
|
+
transform: scale(calc(1 - 0.25 * var(--uikit-switch-pressed)));
|
|
78
|
+
transition-duration: var(--glass-ios-lens-duration);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&[data-checked] {
|
|
82
|
+
--uikit-switch-knob-start: calc(
|
|
83
|
+
100% - var(--uikit-switch-knob-width) - 2px
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
&::before {
|
|
87
|
+
background-color: var(--uikit-switch-on-color);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&:active {
|
|
92
|
+
--uikit-switch-pressed: 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&[data-disabled],
|
|
96
|
+
&[data-readonly] {
|
|
97
|
+
--uikit-switch-pressed: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&[data-disabled] {
|
|
101
|
+
--uikit-utils-cursor: attr(cursor type(<custom-ident>), not-allowed);
|
|
102
|
+
|
|
103
|
+
opacity: 0.55;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Mixed: the knob centered, the track off (over checked, see above). */
|
|
107
|
+
&[data-indeterminate] {
|
|
108
|
+
--uikit-switch-knob-start: calc(50% - var(--uikit-switch-knob-width) / 2);
|
|
109
|
+
|
|
110
|
+
&::before {
|
|
111
|
+
background-color: var(--uikit-switch-off-color);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
& > [data-switch-part='label'] {
|
|
115
|
+
opacity: 0;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.uikit-switch-thumb {
|
|
121
|
+
position: absolute;
|
|
122
|
+
z-index: 1;
|
|
123
|
+
top: 2px;
|
|
124
|
+
bottom: 2px;
|
|
125
|
+
display: block;
|
|
126
|
+
width: var(--uikit-switch-knob-width);
|
|
127
|
+
box-sizing: border-box;
|
|
128
|
+
border-radius: 100px;
|
|
129
|
+
background-color: color-mix(
|
|
130
|
+
in srgb,
|
|
131
|
+
#fff calc((1 - var(--uikit-switch-pressed)) * 100%),
|
|
132
|
+
transparent
|
|
133
|
+
);
|
|
134
|
+
inset-inline-start: var(--uikit-switch-knob-start);
|
|
135
|
+
transform: scale(
|
|
136
|
+
calc(1 + (var(--glass-ios-lens-scale) - 1) * var(--uikit-switch-pressed))
|
|
137
|
+
);
|
|
138
|
+
transform-origin: center;
|
|
139
|
+
transition-duration:
|
|
140
|
+
var(--uikit-switch-knob-move-duration, var(--glass-ios-lens-duration)),
|
|
141
|
+
var(--glass-ios-lens-duration), var(--glass-ios-lens-duration);
|
|
142
|
+
transition-property: inset-inline-start, background-color, transform;
|
|
143
|
+
|
|
144
|
+
&::before {
|
|
145
|
+
position: absolute;
|
|
146
|
+
top: 50%;
|
|
147
|
+
left: 50%;
|
|
148
|
+
width: 1px;
|
|
149
|
+
height: 1px;
|
|
150
|
+
margin: -0.5px 0 0 -0.5px;
|
|
151
|
+
box-shadow: 0 0 40px 15px
|
|
152
|
+
color-mix(in srgb, var(--uikit-switch-on-color) 75%, transparent);
|
|
153
|
+
content: '';
|
|
154
|
+
opacity: var(--uikit-switch-pressed);
|
|
155
|
+
transition-duration: var(--glass-ios-lens-duration);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&::after {
|
|
159
|
+
position: absolute;
|
|
160
|
+
border-radius: inherit;
|
|
161
|
+
box-shadow: var(--glass-ios-lens-shadow);
|
|
162
|
+
content: '';
|
|
163
|
+
inset: 0;
|
|
164
|
+
opacity: var(--uikit-switch-pressed);
|
|
165
|
+
transition-duration: var(--glass-ios-lens-duration);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './style.css';
|
|
2
|
+
import type { SymbolProps } from './props.js';
|
|
3
|
+
export type { SymbolProps } from './props.js';
|
|
4
|
+
/** An SF Symbol (from `@bradleyhodges/sfsymbols`), with e.g. a `Badge`. */
|
|
5
|
+
export declare const Symbol: import("preact").FunctionalComponent<import("react").PropsWithoutRef<SymbolProps> & {
|
|
6
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/components/symbol/main.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAKrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAoB9C,2EAA2E;AAC3E,eAAO,MAAM,MAAM;;EAgFlB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './style.css';
|
|
3
|
+
import { forwardRef, useId } from 'react';
|
|
4
|
+
import { cn } from '../utils/main.js';
|
|
5
|
+
// An SF Symbol, sized like the SF Pro glyph at the current font size, so it
|
|
6
|
+
// can stand in for one (e.g. `` in Figma). Its weight follows the font
|
|
7
|
+
// weight its host sets (see `fontWeight`): heavier than regular, stroked;
|
|
8
|
+
// lighter, masked by its own outline stroked as much
|
|
9
|
+
// (`--uikit-symbol-thinning`, in its units), which takes as much off its
|
|
10
|
+
// edges.
|
|
11
|
+
//
|
|
12
|
+
// Its children (e.g. a `Badge`) sit on it: the glyph alone is blended and
|
|
13
|
+
// scaled by its host (`--uikit-symbol-blend`, `--uikit-symbol-scale`,
|
|
14
|
+
// e.g. a glass button's vibrant content), so they stay solid.
|
|
15
|
+
// The catalogue's paths are SF Pro glyphs at 20pt (e.g. `circle` is 19.92
|
|
16
|
+
// wide, the glyph's ink box 0.996em).
|
|
17
|
+
const unitsPerEm = 20;
|
|
18
|
+
// Room for strokes beyond the view box (in its units, see `fontWeight`).
|
|
19
|
+
const bleed = 2;
|
|
20
|
+
/** An SF Symbol (from `@bradleyhodges/sfsymbols`), with e.g. a `Badge`. */
|
|
21
|
+
export const Symbol = forwardRef(({ children, className, icon, ...props }, ref) => {
|
|
22
|
+
const mask = `uikit-symbol-${useId().replaceAll(/[^\w-]/gu, '')}`;
|
|
23
|
+
const [width = 0, height = 0] = icon.viewBox
|
|
24
|
+
.split(' ')
|
|
25
|
+
.slice(2)
|
|
26
|
+
.map(Number);
|
|
27
|
+
const paths = icon.svgPathData.map(({ d }) => d);
|
|
28
|
+
return (_jsxs("span", { ref: ref, "data-symbol": icon.sourceName, ...props, className: cn('uikit-symbol', className), children: [_jsx("span", { className: "uikit-symbol-glyph", "data-symbol-part": "glyph", children: _jsxs("svg", { "aria-hidden": "true", fill: "currentcolor", height: `${String(height / unitsPerEm)}em`, viewBox: icon.viewBox, width: `${String(width / unitsPerEm)}em`, children: [_jsxs("mask", { height: height + 2 * bleed, id: mask, maskUnits: "userSpaceOnUse", style: { maskType: 'luminance' }, width: width + 2 * bleed, x: -bleed, y: -bleed, children: [paths.map((d, index) => (_jsx("path", { d: d, fill: "#fff", stroke: "#fff" }, index))), _jsx("g", { style: { strokeWidth: 0 }, children: paths.map((d, index) => (_jsx("path", { d: d, fill: "none", stroke: "#000", style: {
|
|
29
|
+
strokeWidth: 'var(--uikit-symbol-thinning, 0px)',
|
|
30
|
+
} }, index))) })] }), _jsx("rect", { fill: "currentcolor", height: height + 2 * bleed, mask: `url(#${mask})`, width: width + 2 * bleed, x: -bleed, y: -bleed })] }) }), children] }));
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
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,10 @@
|
|
|
1
|
+
import type { IconDefinition } from '@bradleyhodges/sfsymbols-types';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
export type SymbolProps = ComponentProps<'span'> & {
|
|
4
|
+
/**
|
|
5
|
+
* The SF Symbol (from `@bradleyhodges/sfsymbols`, e.g. `sfBell`; a peer
|
|
6
|
+
* dependency, mind Apple's terms for SF Symbols).
|
|
7
|
+
*/
|
|
8
|
+
icon: IconDefinition;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/components/symbol/props.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG;IACjD;;;OAGG;IACH,IAAI,EAAE,cAAc,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/components/symbol/props.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* Symbol (see main.tsx). */
|
|
2
|
+
@layer uikit-ish {
|
|
3
|
+
/* The glyph's box (with its side bearings): what its children (e.g. a
|
|
4
|
+
`Badge`) are placed on. */
|
|
5
|
+
.uikit-symbol {
|
|
6
|
+
position: relative;
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
flex: none;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* Blended and scaled as its host's content (see main.tsx). Strokes (see
|
|
12
|
+
`fontWeight`) extend beyond the view box; the margin is the glyph's side
|
|
13
|
+
bearing (SF Pro: `circle` 0.087em, `magnifyingglass` 0.112em,
|
|
14
|
+
`star.fill` 0.096em). */
|
|
15
|
+
.uikit-symbol-glyph {
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
mix-blend-mode: var(--uikit-symbol-blend, normal);
|
|
18
|
+
scale: var(--uikit-symbol-scale, none);
|
|
19
|
+
transition: scale var(--glass-ios-lens-duration, 0s);
|
|
20
|
+
|
|
21
|
+
& > svg {
|
|
22
|
+
overflow: visible;
|
|
23
|
+
margin-inline: 0.1em;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import '../glass/style.css';
|
|
2
|
+
import './style.css';
|
|
3
|
+
import type { CollapsedGroupSelection, TabBarAccessoryProps, TabBarGroupProps, TabBarListProps, TabBarRootProps, TabBarTabProps } from './props.js';
|
|
4
|
+
export type { AccessoryVisibility, CollapsedContent, CollapsedGroupSelection, CollapsedPosition, TabBarAccessoryProps, TabBarGroupProps, TabBarListProps, TabBarRootProps, TabBarTabProps, } from './props.js';
|
|
5
|
+
/**
|
|
6
|
+
* A choice of what remains while collapsed (for `visibleWhenCollapsed`), as
|
|
7
|
+
* iOS's: the active tab (by its value, among the groups' tab values) and its
|
|
8
|
+
* group; without one, the first group's first tab. Every group's `tab` is
|
|
9
|
+
* its active tab, or its first (for groups the app keeps, too).
|
|
10
|
+
*/
|
|
11
|
+
export declare const collapsedSelection: <Value>(groups: readonly (readonly Value[])[], value: Value | undefined) => CollapsedGroupSelection[];
|
|
12
|
+
export declare const TabBar: {
|
|
13
|
+
Accessory: import("preact").FunctionalComponent<import("react").PropsWithoutRef<TabBarAccessoryProps> & {
|
|
14
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
Root: import("preact").FunctionalComponent<import("react").PropsWithoutRef<TabBarRootProps> & {
|
|
17
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
List: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<TabBarListProps, "ref">> & {
|
|
20
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
Group: import("preact").FunctionalComponent<import("react").PropsWithoutRef<TabBarGroupProps> & {
|
|
23
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
Indicator: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<Omit<import("@base-ui/react/tabs").TabsIndicatorProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>, "ref">> & {
|
|
26
|
+
ref?: import("preact").Ref<HTMLElement> | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
Tab: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<TabBarTabProps, "ref">> & {
|
|
29
|
+
ref?: import("preact").Ref<HTMLElement> | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
Icon: import("preact").FunctionalComponent<import("react").PropsWithoutRef<import("preact").HTMLAttributes<HTMLSpanElement>> & {
|
|
32
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
Label: import("preact").FunctionalComponent<import("react").PropsWithoutRef<import("preact").HTMLAttributes<HTMLSpanElement>> & {
|
|
35
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
Panel: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/tabs").TabsPanelProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/components/tab-bar/main.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,aAAa,CAAC;AA2BrB,OAAO,KAAK,EAGV,uBAAuB,EAKvB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AAyOpB;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,EACtC,QAAQ,SAAS,CAAC,SAAS,KAAK,EAAE,CAAC,EAAE,EACrC,OAAO,KAAK,GAAG,SAAS,KACvB,uBAAuB,EAQzB,CAAC;AA40CF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;CAUlB,CAAC"}
|