@mrpelz/uikit-ish 7.13.1 → 7.26.2
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/accordion/style.css +1 -1
- package/dist/components/action-sheet/main.d.ts.map +1 -1
- package/dist/components/action-sheet/main.js +9 -6
- package/dist/components/action-sheet/main.js.map +1 -1
- package/dist/components/action-sheet/props.d.ts +2 -1
- package/dist/components/action-sheet/props.d.ts.map +1 -1
- package/dist/components/alert/main.d.ts.map +1 -1
- package/dist/components/alert/main.js +12 -4
- package/dist/components/alert/main.js.map +1 -1
- package/dist/components/alert/props.d.ts +2 -1
- package/dist/components/alert/props.d.ts.map +1 -1
- package/dist/components/alert/style.css +27 -5
- package/dist/components/button/main.js +1 -1
- package/dist/components/button/main.js.map +1 -1
- package/dist/components/button/props.d.ts +3 -2
- package/dist/components/button/props.d.ts.map +1 -1
- package/dist/components/button/style.css +6 -17
- package/dist/components/card/main.d.ts +53 -0
- package/dist/components/card/main.d.ts.map +1 -0
- package/dist/components/card/main.js +286 -0
- package/dist/components/card/main.js.map +1 -0
- package/dist/components/card/props.d.ts +83 -0
- package/dist/components/card/props.d.ts.map +1 -0
- package/dist/components/card/props.js +2 -0
- package/dist/components/card/props.js.map +1 -0
- package/dist/components/card/style.css +900 -0
- package/dist/components/collapsible/style.css +1 -1
- package/dist/components/color-picker/main.d.ts.map +1 -1
- package/dist/components/color-picker/main.js +20 -33
- package/dist/components/color-picker/main.js.map +1 -1
- package/dist/components/color-picker/style.css +4 -23
- package/dist/components/contextual-menu/main.d.ts +6 -2
- package/dist/components/contextual-menu/main.d.ts.map +1 -1
- package/dist/components/contextual-menu/main.js +67 -43
- package/dist/components/contextual-menu/main.js.map +1 -1
- package/dist/components/contextual-menu/props.d.ts +2 -1
- package/dist/components/contextual-menu/props.d.ts.map +1 -1
- package/dist/components/contextual-menu/style.css +64 -2
- package/dist/components/control-cards/main.d.ts +49 -0
- package/dist/components/control-cards/main.d.ts.map +1 -0
- package/dist/components/control-cards/main.js +835 -0
- package/dist/components/control-cards/main.js.map +1 -0
- package/dist/components/control-cards/props.d.ts +409 -0
- package/dist/components/control-cards/props.d.ts.map +1 -0
- package/dist/components/control-cards/props.js +2 -0
- package/dist/components/control-cards/props.js.map +1 -0
- package/dist/components/control-cards/style.css +492 -0
- package/dist/components/date-picker/main.d.ts.map +1 -1
- package/dist/components/date-picker/main.js +3 -2
- package/dist/components/date-picker/main.js.map +1 -1
- package/dist/components/date-picker/style.css +1 -1
- package/dist/components/drawer/style.css +6 -0
- package/dist/components/edit-menu/main.d.ts +2 -1
- package/dist/components/edit-menu/main.d.ts.map +1 -1
- package/dist/components/edit-menu/main.js +8 -4
- package/dist/components/edit-menu/main.js.map +1 -1
- package/dist/components/glass/backdrop.d.ts +75 -0
- package/dist/components/glass/backdrop.d.ts.map +1 -0
- package/dist/components/glass/backdrop.js +608 -0
- package/dist/components/glass/backdrop.js.map +1 -0
- package/dist/components/glass/gradient.d.ts +17 -0
- package/dist/components/glass/gradient.d.ts.map +1 -0
- package/dist/components/glass/gradient.js +233 -0
- package/dist/components/glass/gradient.js.map +1 -0
- package/dist/components/glass/main.d.ts +60 -6
- package/dist/components/glass/main.d.ts.map +1 -1
- package/dist/components/glass/main.js +100 -122
- package/dist/components/glass/main.js.map +1 -1
- package/dist/components/glass/marker.d.ts +66 -0
- package/dist/components/glass/marker.d.ts.map +1 -0
- package/dist/components/glass/marker.js +268 -0
- package/dist/components/glass/marker.js.map +1 -0
- package/dist/components/glass/props.d.ts +33 -7
- package/dist/components/glass/props.d.ts.map +1 -1
- package/dist/components/glass/style.css +139 -75
- package/dist/components/grid/dashes.d.ts +15 -0
- package/dist/components/grid/dashes.d.ts.map +1 -0
- package/dist/components/grid/dashes.js +37 -0
- package/dist/components/grid/dashes.js.map +1 -0
- package/dist/components/grid/edit.d.ts +11 -0
- package/dist/components/grid/edit.d.ts.map +1 -0
- package/dist/components/grid/edit.js +1066 -0
- package/dist/components/grid/edit.js.map +1 -0
- package/dist/components/grid/handle.d.ts +123 -0
- package/dist/components/grid/handle.d.ts.map +1 -0
- package/dist/components/grid/handle.js +194 -0
- package/dist/components/grid/handle.js.map +1 -0
- package/dist/components/grid/icons.d.ts +40 -0
- package/dist/components/grid/icons.d.ts.map +1 -0
- package/dist/components/grid/icons.js +140 -0
- package/dist/components/grid/icons.js.map +1 -0
- package/dist/components/grid/layout.d.ts +111 -0
- package/dist/components/grid/layout.d.ts.map +1 -0
- package/dist/components/grid/layout.js +1257 -0
- package/dist/components/grid/layout.js.map +1 -0
- package/dist/components/grid/main.d.ts +63 -0
- package/dist/components/grid/main.d.ts.map +1 -0
- package/dist/components/grid/main.js +1894 -0
- package/dist/components/grid/main.js.map +1 -0
- package/dist/components/grid/overlay.d.ts +24 -0
- package/dist/components/grid/overlay.d.ts.map +1 -0
- package/dist/components/grid/overlay.js +312 -0
- package/dist/components/grid/overlay.js.map +1 -0
- package/dist/components/grid/plan.d.ts +78 -0
- package/dist/components/grid/plan.d.ts.map +1 -0
- package/dist/components/grid/plan.js +249 -0
- package/dist/components/grid/plan.js.map +1 -0
- package/dist/components/grid/props.d.ts +509 -0
- package/dist/components/grid/props.d.ts.map +1 -0
- package/dist/components/grid/props.js +2 -0
- package/dist/components/grid/props.js.map +1 -0
- package/dist/components/grid/reshape.d.ts +60 -0
- package/dist/components/grid/reshape.d.ts.map +1 -0
- package/dist/components/grid/reshape.js +214 -0
- package/dist/components/grid/reshape.js.map +1 -0
- package/dist/components/grid/style.css +1293 -0
- package/dist/components/header/main.d.ts.map +1 -1
- package/dist/components/header/main.js +97 -10
- package/dist/components/header/main.js.map +1 -1
- package/dist/components/header/props.d.ts +2 -2
- package/dist/components/header/props.d.ts.map +1 -1
- package/dist/components/header/style.css +28 -43
- package/dist/components/index.d.ts +10 -6
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/island/main.d.ts +2 -2
- package/dist/components/island/main.d.ts.map +1 -1
- package/dist/components/island/main.js +193 -41
- package/dist/components/island/main.js.map +1 -1
- package/dist/components/island/props.d.ts +4 -2
- package/dist/components/island/props.d.ts.map +1 -1
- package/dist/components/island/style.css +50 -3
- package/dist/components/layout/main.d.ts +3 -6
- package/dist/components/layout/main.d.ts.map +1 -1
- package/dist/components/layout/main.js +225 -56
- package/dist/components/layout/main.js.map +1 -1
- package/dist/components/layout/props.d.ts +43 -2
- package/dist/components/layout/props.d.ts.map +1 -1
- package/dist/components/layout/style.css +84 -23
- package/dist/components/list/main.d.ts +3 -3
- package/dist/components/list/main.d.ts.map +1 -1
- package/dist/components/list/main.js +90 -19
- package/dist/components/list/main.js.map +1 -1
- package/dist/components/list/props.d.ts +20 -0
- package/dist/components/list/props.d.ts.map +1 -1
- package/dist/components/list/reorder.d.ts +16 -2
- package/dist/components/list/reorder.d.ts.map +1 -1
- package/dist/components/list/reorder.js.map +1 -1
- package/dist/components/list/style.css +60 -3
- package/dist/components/menu/main.d.ts +9 -5
- package/dist/components/menu/main.d.ts.map +1 -1
- package/dist/components/menu/main.js +87 -9
- package/dist/components/menu/main.js.map +1 -1
- package/dist/components/menu/props.d.ts +14 -0
- package/dist/components/menu/props.d.ts.map +1 -1
- package/dist/components/menu/style.css +3 -1
- package/dist/components/page/main.d.ts.map +1 -1
- package/dist/components/page/main.js +6 -3
- package/dist/components/page/main.js.map +1 -1
- package/dist/components/page/props.d.ts +3 -2
- package/dist/components/page/props.d.ts.map +1 -1
- package/dist/components/page/style.css +8 -4
- package/dist/components/page-control/props.d.ts +3 -3
- package/dist/components/popover/main.d.ts +10 -4
- package/dist/components/popover/main.d.ts.map +1 -1
- package/dist/components/popover/main.js +30 -19
- package/dist/components/popover/main.js.map +1 -1
- package/dist/components/popover/props.d.ts +2 -0
- package/dist/components/popover/props.d.ts.map +1 -1
- package/dist/components/popover/style.css +6 -2
- package/dist/components/progress/style.css +2 -2
- package/dist/components/roll/main.d.ts.map +1 -1
- package/dist/components/roll/main.js +5 -3
- package/dist/components/roll/main.js.map +1 -1
- package/dist/components/segmented/main.d.ts.map +1 -1
- package/dist/components/segmented/main.js +4 -4
- package/dist/components/segmented/main.js.map +1 -1
- package/dist/components/segmented/props.d.ts +5 -2
- package/dist/components/segmented/props.d.ts.map +1 -1
- package/dist/components/segmented/style.css +1 -1
- package/dist/components/settings/main.d.ts +13 -0
- package/dist/components/settings/main.d.ts.map +1 -1
- package/dist/components/settings/main.js +16 -0
- package/dist/components/settings/main.js.map +1 -1
- package/dist/components/settings/props.d.ts +1 -0
- package/dist/components/settings/props.d.ts.map +1 -1
- package/dist/components/sheet/main.d.ts.map +1 -1
- package/dist/components/sheet/main.js +156 -45
- package/dist/components/sheet/main.js.map +1 -1
- package/dist/components/sheet/props.d.ts +4 -2
- package/dist/components/sheet/props.d.ts.map +1 -1
- package/dist/components/sheet/snap.d.ts +54 -0
- package/dist/components/sheet/snap.d.ts.map +1 -1
- package/dist/components/sheet/snap.js +253 -23
- package/dist/components/sheet/snap.js.map +1 -1
- package/dist/components/sheet/style.css +126 -20
- package/dist/components/sidebar/main.d.ts +2 -1
- package/dist/components/sidebar/main.d.ts.map +1 -1
- package/dist/components/sidebar/main.js +18 -6
- package/dist/components/sidebar/main.js.map +1 -1
- package/dist/components/sidebar/props.d.ts +2 -1
- package/dist/components/sidebar/props.d.ts.map +1 -1
- package/dist/components/sidebar/style.css +78 -0
- package/dist/components/slider/main.d.ts.map +1 -1
- package/dist/components/slider/main.js +51 -9
- package/dist/components/slider/main.js.map +1 -1
- package/dist/components/slider/props.d.ts +1 -0
- package/dist/components/slider/props.d.ts.map +1 -1
- package/dist/components/slider/style.css +9 -0
- package/dist/components/switch/main.d.ts.map +1 -1
- package/dist/components/switch/main.js +4 -2
- package/dist/components/switch/main.js.map +1 -1
- package/dist/components/symbol/main.d.ts.map +1 -1
- package/dist/components/symbol/main.js +5 -1
- package/dist/components/symbol/main.js.map +1 -1
- package/dist/components/symbol/props.d.ts +10 -0
- package/dist/components/symbol/props.d.ts.map +1 -1
- package/dist/components/symbol/style.css +21 -3
- package/dist/components/tab-bar/main.d.ts.map +1 -1
- package/dist/components/tab-bar/main.js +8 -5
- package/dist/components/tab-bar/main.js.map +1 -1
- package/dist/components/tab-bar/props.d.ts +16 -12
- package/dist/components/tab-bar/props.d.ts.map +1 -1
- package/dist/components/tab-bar/style.css +3 -9
- package/dist/components/text-field/main.d.ts.map +1 -1
- package/dist/components/text-field/main.js +6 -3
- package/dist/components/text-field/main.js.map +1 -1
- package/dist/components/text-field/style.css +1 -1
- package/dist/components/toolbar/main.js +1 -1
- package/dist/components/toolbar/main.js.map +1 -1
- package/dist/components/toolbar/props.d.ts +3 -3
- package/dist/components/toolbar/style.css +1 -1
- package/dist/components/tooltip/main.d.ts +6 -1
- package/dist/components/tooltip/main.d.ts.map +1 -1
- package/dist/components/tooltip/main.js +13 -7
- package/dist/components/tooltip/main.js.map +1 -1
- package/dist/components/utils/main.d.ts +31 -2
- package/dist/components/utils/main.d.ts.map +1 -1
- package/dist/components/utils/main.js +60 -3
- package/dist/components/utils/main.js.map +1 -1
- package/dist/components/viewport/current.d.ts +15 -0
- package/dist/components/viewport/current.d.ts.map +1 -0
- package/dist/components/viewport/current.js +74 -0
- package/dist/components/viewport/current.js.map +1 -0
- package/dist/components/viewport/edge-effect.d.ts.map +1 -1
- package/dist/components/viewport/edge-effect.js +52 -24
- package/dist/components/viewport/edge-effect.js.map +1 -1
- package/dist/components/viewport/edge.d.ts +7 -4
- package/dist/components/viewport/edge.d.ts.map +1 -1
- package/dist/components/viewport/edge.js +21 -7
- package/dist/components/viewport/edge.js.map +1 -1
- package/dist/components/viewport/focus-scroll.d.ts +21 -0
- package/dist/components/viewport/focus-scroll.d.ts.map +1 -0
- package/dist/components/viewport/focus-scroll.js +272 -0
- package/dist/components/viewport/focus-scroll.js.map +1 -0
- package/dist/components/viewport/input.d.ts +39 -1
- package/dist/components/viewport/input.d.ts.map +1 -1
- package/dist/components/viewport/input.js +122 -13
- package/dist/components/viewport/input.js.map +1 -1
- package/dist/components/viewport/main.d.ts +16 -1
- package/dist/components/viewport/main.d.ts.map +1 -1
- package/dist/components/viewport/main.js +243 -49
- package/dist/components/viewport/main.js.map +1 -1
- package/dist/components/viewport/padding.d.ts +1 -1
- package/dist/components/viewport/padding.d.ts.map +1 -1
- package/dist/components/viewport/padding.js +2 -2
- package/dist/components/viewport/props.d.ts +12 -2
- package/dist/components/viewport/props.d.ts.map +1 -1
- package/dist/components/viewport/status-bar.d.ts +9 -0
- package/dist/components/viewport/status-bar.d.ts.map +1 -0
- package/dist/components/viewport/status-bar.js +131 -0
- package/dist/components/viewport/status-bar.js.map +1 -0
- package/dist/components/viewport/style.css +62 -5
- package/dist/styles.css +123 -198
- package/package.json +5 -4
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import '../glass/style.css';
|
|
3
|
+
import '../switch/style.css';
|
|
4
|
+
import '../slider/style.css';
|
|
5
|
+
import '../grid/style.css';
|
|
6
|
+
import './style.css';
|
|
7
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
8
|
+
import { createContext, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
9
|
+
import { createPortal } from 'react-dom';
|
|
10
|
+
import { colorSchemeStyle, useGlassScheme } from '../glass/main.js';
|
|
11
|
+
import { Grid, startWithFrame, useGridItem, useGridItemLayout, } from '../grid/main.js';
|
|
12
|
+
import { ColorSchemeScope } from '../settings/main.js';
|
|
13
|
+
import { Switch } from '../switch/main.js';
|
|
14
|
+
import { cn, useForwardedRef, withStyle } from '../utils/main.js';
|
|
15
|
+
/**
|
|
16
|
+
* A layer over the card's content where its parts draw a copy of
|
|
17
|
+
* themselves (`Card.Symbol`, `Card.CornerButton`): e.g. inside a slider's
|
|
18
|
+
* fill filling the card, in the fill's color scheme, clipped by its edge
|
|
19
|
+
* (see ControlCards' `SliderFill`), registered by it (`setLayer`); the
|
|
20
|
+
* root marked `data-card-blend` while there is one (its originals under
|
|
21
|
+
* the fill, see style.css). None: no copies. Internal.
|
|
22
|
+
*/
|
|
23
|
+
export const CardBlendScope = createContext(undefined);
|
|
24
|
+
/** The tile's shape (its item's effective size): wide, horizontal. */
|
|
25
|
+
export const useCardOrientation = () => {
|
|
26
|
+
const item = useGridItem();
|
|
27
|
+
if (!item)
|
|
28
|
+
return 'horizontal';
|
|
29
|
+
const [columns = '1', rows = '1'] = item.size.split('x');
|
|
30
|
+
return columns === '*' || Number(columns) >= Number(rows)
|
|
31
|
+
? 'horizontal'
|
|
32
|
+
: 'vertical';
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The sizes the library's kinds of cards support, for their items'
|
|
36
|
+
* `supportedSizes`: a binary display or control (a state, a switch), a
|
|
37
|
+
* numerical display (a value) or control (a slider: never square, so it
|
|
38
|
+
* has a direction), a choice of a few (segments: across a row, taller,
|
|
39
|
+
* upright, or 1x1 opening to choose), a summary (rows: never 1x1).
|
|
40
|
+
*/
|
|
41
|
+
export const cardSizes = {
|
|
42
|
+
binaryControl: ['1x1', '2x1'],
|
|
43
|
+
binaryDisplay: ['1x1', '2x1'],
|
|
44
|
+
choiceControl: [
|
|
45
|
+
'1x1',
|
|
46
|
+
'2x1',
|
|
47
|
+
'3x1',
|
|
48
|
+
'4x1',
|
|
49
|
+
'1x2',
|
|
50
|
+
'2x2',
|
|
51
|
+
'3x2',
|
|
52
|
+
'4x2',
|
|
53
|
+
'1x3',
|
|
54
|
+
'2x3',
|
|
55
|
+
'1x4',
|
|
56
|
+
'2x4',
|
|
57
|
+
],
|
|
58
|
+
numericalControl: ['2x1', '3x1', '4x1', '1x2', '1x3'],
|
|
59
|
+
numericalDisplay: ['1x1', '2x1', '2x2'],
|
|
60
|
+
summaryDisplay: ['2x1', '2x2', '3x2', '4x1', '4x2', '3x3', '4x3', '4x4'],
|
|
61
|
+
};
|
|
62
|
+
/** Its corner buttons' animations' id (see `useCornersFollowing`). */
|
|
63
|
+
const cornerId = 'uikit-card-corner';
|
|
64
|
+
/**
|
|
65
|
+
* Its corner buttons following its corners as its tile gets to a new box
|
|
66
|
+
* (see the top): laid out in its frame, at the size it's getting to, each
|
|
67
|
+
* at its trailing or bottom edge moved by as much as its glass's edge is
|
|
68
|
+
* off it, by its tile's timing (a translate added to any of its own).
|
|
69
|
+
*/
|
|
70
|
+
const useCornersFollowing = (rootRef) => {
|
|
71
|
+
useGridItemLayout({
|
|
72
|
+
onAfterChange: ({ duration, easing, from, to }) => {
|
|
73
|
+
const root = rootRef.current;
|
|
74
|
+
if (!root)
|
|
75
|
+
return;
|
|
76
|
+
const isRtl = getComputedStyle(root).direction === 'rtl';
|
|
77
|
+
const across = isRtl ? to.width - from.width : from.width - to.width;
|
|
78
|
+
const down = from.height - to.height;
|
|
79
|
+
for (const button of root.querySelectorAll(
|
|
80
|
+
// (Its copies too, over a slider's fill: on its glass, in the fill.)
|
|
81
|
+
':scope > .uikit-card-frame .uikit-card-corner-button')) {
|
|
82
|
+
for (const animation of button.getAnimations()) {
|
|
83
|
+
if (animation.id === cornerId)
|
|
84
|
+
animation.cancel();
|
|
85
|
+
}
|
|
86
|
+
// (Which edge it's at: by where it's laid out, in its frame.)
|
|
87
|
+
const center = button.offsetLeft + button.offsetWidth / 2;
|
|
88
|
+
const isAtEnd = center > to.width / 2 !== isRtl;
|
|
89
|
+
const isAtBottom = button.offsetTop + button.offsetHeight / 2 > to.height / 2;
|
|
90
|
+
const x = isAtEnd ? across : 0;
|
|
91
|
+
const y = isAtBottom ? down : 0;
|
|
92
|
+
if (x === 0 && y === 0)
|
|
93
|
+
continue;
|
|
94
|
+
// (With its tile: from the next frame, see Grid's reshape.ts.)
|
|
95
|
+
startWithFrame(button.animate([
|
|
96
|
+
{ translate: `${String(x)}px ${String(y)}px` },
|
|
97
|
+
{ translate: '0 0' },
|
|
98
|
+
], { composite: 'add', duration, easing, id: cornerId }));
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* How long a flashed card stays lit, and how long it fades back (see
|
|
105
|
+
* style.css).
|
|
106
|
+
*/
|
|
107
|
+
const flashTime = 150;
|
|
108
|
+
const fadeTime = 500;
|
|
109
|
+
/**
|
|
110
|
+
* The state of a switch in it (its layout's, see style.css): on, off, or
|
|
111
|
+
* none (no switch), as it changes (its `data-checked`, Switch's), before it
|
|
112
|
+
* paints.
|
|
113
|
+
*/
|
|
114
|
+
const useSwitchState = (rootRef) => {
|
|
115
|
+
const [state, setState] = useState(undefined);
|
|
116
|
+
useLayoutEffect(() => {
|
|
117
|
+
const { current: root } = rootRef;
|
|
118
|
+
if (!root)
|
|
119
|
+
return undefined;
|
|
120
|
+
const read = () => {
|
|
121
|
+
const control = root.querySelector(':scope > .uikit-card-frame > .uikit-card-layout > .uikit-switch-root');
|
|
122
|
+
setState(control ? Object.hasOwn(control.dataset, 'checked') : undefined);
|
|
123
|
+
};
|
|
124
|
+
read();
|
|
125
|
+
const observer = new MutationObserver(read);
|
|
126
|
+
observer.observe(root, {
|
|
127
|
+
attributeFilter: ['data-checked'],
|
|
128
|
+
childList: true,
|
|
129
|
+
subtree: true,
|
|
130
|
+
});
|
|
131
|
+
return () => observer.disconnect();
|
|
132
|
+
}, [rootRef]);
|
|
133
|
+
return state;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* A card flashed (by a press on a momentary one, or its `actionsRef`'s
|
|
137
|
+
* `flash`): lit as if active (`data-flashing`) for a moment, then fading
|
|
138
|
+
* back (`data-fading`, see style.css); flashed again meanwhile, lit as long
|
|
139
|
+
* again.
|
|
140
|
+
*/
|
|
141
|
+
const useFlash = (rootRef, actionsRef) => {
|
|
142
|
+
const timers = useRef([0, 0]);
|
|
143
|
+
const flash = useCallback(() => {
|
|
144
|
+
const root = rootRef.current;
|
|
145
|
+
if (!root)
|
|
146
|
+
return;
|
|
147
|
+
for (const timer of timers.current)
|
|
148
|
+
clearTimeout(timer);
|
|
149
|
+
delete root.dataset.fading;
|
|
150
|
+
root.dataset.flashing = '';
|
|
151
|
+
timers.current[0] = window.setTimeout(() => {
|
|
152
|
+
delete root.dataset.flashing;
|
|
153
|
+
root.dataset.fading = '';
|
|
154
|
+
timers.current[1] = window.setTimeout(() => {
|
|
155
|
+
delete root.dataset.fading;
|
|
156
|
+
}, fadeTime);
|
|
157
|
+
}, flashTime);
|
|
158
|
+
}, [rootRef]);
|
|
159
|
+
useImperativeHandle(
|
|
160
|
+
// (None given: nothing set; typed as one for Preact's types.)
|
|
161
|
+
actionsRef, () => ({ flash }), [flash]);
|
|
162
|
+
useEffect(() => () => {
|
|
163
|
+
for (const timer of timers.current)
|
|
164
|
+
clearTimeout(timer);
|
|
165
|
+
}, []);
|
|
166
|
+
return flash;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* The card: its glass, its parts on it; bright while `active` (or a switch
|
|
170
|
+
* in it is on); pressable as a whole with an `onClick` (its feedback, see
|
|
171
|
+
* style.css); in a grid's tile (its item's), inert and veiled while
|
|
172
|
+
* editing (see the top).
|
|
173
|
+
*/
|
|
174
|
+
const Root = forwardRef(({ actionsRef, active, children, className, context, momentary = false, onClick, render, style, ...props }, forwardedRef) => {
|
|
175
|
+
const item = useGridItem();
|
|
176
|
+
const isEditing = item?.editing === true;
|
|
177
|
+
const ref = useForwardedRef(forwardedRef);
|
|
178
|
+
useCornersFollowing(ref);
|
|
179
|
+
const flash = useFlash(ref, actionsRef);
|
|
180
|
+
// Switchable (`active` given, or a switch in it): on, lit; off, dark
|
|
181
|
+
// glass (in both schemes: its luminance telling which); else its
|
|
182
|
+
// glass's tone's (see Glass); none while editing (its veil, and its
|
|
183
|
+
// grid's controls on it, the page's, see style.css).
|
|
184
|
+
const switchState = useSwitchState(ref);
|
|
185
|
+
const state = active ?? switchState;
|
|
186
|
+
const toned = useGlassScheme(ref, context);
|
|
187
|
+
const schemeOfState = state ? 'light' : 'dark';
|
|
188
|
+
const stated = state === undefined ? toned : schemeOfState;
|
|
189
|
+
const scheme = isEditing ? undefined : stated;
|
|
190
|
+
// (A layer its parts draw their copies in, registered by what fills
|
|
191
|
+
// it, see `CardBlendScope`.)
|
|
192
|
+
const [blendLayer, setBlendLayer] = useState(null);
|
|
193
|
+
const blend = useMemo(() => ({ layer: blendLayer, setLayer: setBlendLayer }), [blendLayer]);
|
|
194
|
+
return useRender({
|
|
195
|
+
defaultTagName: 'div',
|
|
196
|
+
props: {
|
|
197
|
+
...props,
|
|
198
|
+
// (Its parts on a layout of its own, in a frame: what its size
|
|
199
|
+
// queries ask, see style.css.)
|
|
200
|
+
children: (_jsx(ColorSchemeScope, { colorScheme: scheme, children: _jsx(CardBlendScope.Provider, { value: blend, children: _jsx("div", { className: "uikit-card-frame", children: _jsx("div", { className: "uikit-card-layout", children: children }) }) }) })),
|
|
201
|
+
className: cn('uikit-card-root uikit-glass-medium uikit-glass-panel', className),
|
|
202
|
+
'data-active': state === true ? '' : undefined,
|
|
203
|
+
// (Its `active` given: its state, whatever a switch in it says
|
|
204
|
+
// (e.g. a dimmer's, never lit), see style.css.)
|
|
205
|
+
'data-active-given': active === undefined ? undefined : '',
|
|
206
|
+
'data-card-blend': blendLayer ? '' : undefined,
|
|
207
|
+
'data-card-part': 'root',
|
|
208
|
+
'data-color-scheme': scheme,
|
|
209
|
+
'data-momentary': momentary ? '' : undefined,
|
|
210
|
+
// (Pressed as a whole: its feedback, see style.css.)
|
|
211
|
+
'data-pressable': onClick ? '' : undefined,
|
|
212
|
+
'data-editing': isEditing ? '' : undefined,
|
|
213
|
+
inert: isEditing || undefined,
|
|
214
|
+
onClick: momentary && onClick
|
|
215
|
+
? (event) => {
|
|
216
|
+
flash();
|
|
217
|
+
onClick(event);
|
|
218
|
+
}
|
|
219
|
+
: onClick,
|
|
220
|
+
style: withStyle(colorSchemeStyle(scheme), style),
|
|
221
|
+
},
|
|
222
|
+
ref,
|
|
223
|
+
render,
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
/**
|
|
227
|
+
* Its symbol (e.g. a `Symbol`), at its top leading corner: on (its card lit,
|
|
228
|
+
* or its own `active`), in its tint, its `Symbol`'s emphasized icon (e.g.
|
|
229
|
+
* filled) shown; else its icon (e.g. outlined). Over a slider's fill (see
|
|
230
|
+
* `CardBlendScope`): in its text's color, drawn again in the
|
|
231
|
+
* fill, its emphasis on both.
|
|
232
|
+
*/
|
|
233
|
+
const CardSymbol = forwardRef(({ active = false, children, className, style, tint, ...props }, ref) => {
|
|
234
|
+
const blendLayer = useContext(CardBlendScope)?.layer ?? null;
|
|
235
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: ref, ...props, className: cn('uikit-card-symbol', className), "data-active": active ? '' : undefined, "data-card-part": "symbol", style: withStyle({ '--uikit-card-symbol-tint': tint }, style), children: children }), blendLayer
|
|
236
|
+
? createPortal(_jsx("span", { className: cn('uikit-card-symbol', className), "data-active": active ? '' : undefined, "data-card-copy": "", children: children }), blendLayer)
|
|
237
|
+
: null] }));
|
|
238
|
+
});
|
|
239
|
+
/**
|
|
240
|
+
* Its switch (a `Switch.Root` with its thumb): its top trailing corner, the
|
|
241
|
+
* card's state (on, lit), on in the card's tint (`tint`; see style.css: on
|
|
242
|
+
* a slider's fill, or in a card never lit, a darker shade of it). A part of
|
|
243
|
+
* the card's (moved with its other parts as its tile changes, see
|
|
244
|
+
* `useGridItemLayout`).
|
|
245
|
+
*/
|
|
246
|
+
const CardSwitch = forwardRef(({ className, style, tint, ...props }, ref) => (_jsx(Switch.Root, { ref: ref, ...props, className: cn('uikit-card-switch', className), "data-card-part": "switch", style: withStyle({ '--uikit-card-switch-tint': tint }, style), children: _jsx(Switch.Thumb, {}) })));
|
|
247
|
+
/** What it is (e.g. a device's name), above its value. */
|
|
248
|
+
const Title = forwardRef(({ className, ...props }, ref) => (_jsx("span", { ref: ref, ...props, className: cn('uikit-card-title', className), "data-card-part": "title" })));
|
|
249
|
+
/** The document's language, if it says (none: the runtime's default). */
|
|
250
|
+
const documentLocale = () => typeof document === 'undefined'
|
|
251
|
+
? undefined
|
|
252
|
+
: document.documentElement.lang || undefined;
|
|
253
|
+
/**
|
|
254
|
+
* Its value: a number formatted as the app says (`format`, `locale`:
|
|
255
|
+
* `Intl.NumberFormat`'s), or what's given instead (e.g. a state).
|
|
256
|
+
*/
|
|
257
|
+
const Value = forwardRef(({ children, className, format, locale, value, ...props }, ref) => (_jsx("span", { ref: ref, ...props, className: cn('uikit-card-value', className), "data-card-part": "value", children: value === undefined
|
|
258
|
+
? children
|
|
259
|
+
: new Intl.NumberFormat(locale ?? documentLocale(), format).format(value) })));
|
|
260
|
+
/**
|
|
261
|
+
* A button in its corner (see `Grid.CornerButton`): shown while its grid
|
|
262
|
+
* isn't editing (faded out, inert, while it is; and as `visible` says). A
|
|
263
|
+
* press on it is its own, not the card's (e.g. not toggling a switch in
|
|
264
|
+
* it, see `forwardClick`).
|
|
265
|
+
*/
|
|
266
|
+
const CornerButton = forwardRef(({ className, corner, icon, mirrored, onClick, visible = true, ...props }, ref) => {
|
|
267
|
+
const isEditing = useGridItem()?.editing === true;
|
|
268
|
+
const isShown = visible && !isEditing;
|
|
269
|
+
// (Over a slider's fill (see `CardBlendScope`): pressed, but
|
|
270
|
+
// drawn by its copies, one on its glass, under the fill, one in it.)
|
|
271
|
+
const blendLayer = useContext(CardBlendScope)?.layer ?? null;
|
|
272
|
+
const copy = (_jsx(Grid.CornerButton, { "aria-hidden": true, inert: true, className: cn('uikit-card-corner-button', className), corner: corner, "data-card-copy": "", icon: icon, mirrored: mirrored, render: _jsx("span", {}), visible: isShown }));
|
|
273
|
+
return (_jsxs(_Fragment, { children: [_jsx(Grid.CornerButton, { ref: ref, className: cn('uikit-card-corner-button', className), corner: corner, "data-card-part": "corner-button", icon: icon, mirrored: mirrored, visible: isShown, ...props, onClick: (event) => {
|
|
274
|
+
event.stopPropagation();
|
|
275
|
+
onClick?.(event);
|
|
276
|
+
} }), blendLayer ? copy : null, blendLayer ? createPortal(copy, blendLayer) : null] }));
|
|
277
|
+
});
|
|
278
|
+
export const Card = {
|
|
279
|
+
CornerButton,
|
|
280
|
+
Root,
|
|
281
|
+
Switch: CardSwitch,
|
|
282
|
+
Symbol: CardSymbol,
|
|
283
|
+
Title,
|
|
284
|
+
Value,
|
|
285
|
+
};
|
|
286
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src/components/card/main.tsx"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EACL,aAAa,EACb,UAAU,EAIV,WAAW,EACX,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EACL,IAAI,EAEJ,cAAc,EACd,WAAW,EACX,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,EAAE,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAwElE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAwB,SAAS,CAAC,CAAC;AAE9E,sEAAsE;AACtE,MAAM,CAAC,M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IAClB,YAAY;IACZ,IAAI;IACJ,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,UAAU;IAClB,KAAK;IACL,KAAK;CACN,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { useRender } from '@base-ui/react/use-render';
|
|
2
|
+
import type { ComponentProps, ReactNode, RefObject } from 'react';
|
|
3
|
+
import type { GlassSurfaceProps } from '../glass/main.js';
|
|
4
|
+
import type { GridCornerButtonProps, GridSize } from '../grid/main.js';
|
|
5
|
+
import type { SwitchRootProps } from '../switch/props.js';
|
|
6
|
+
/** A card's corner button: a `Grid.CornerButton` (see `Card.CornerButton`). */
|
|
7
|
+
export type CardCornerButtonProps = GridCornerButtonProps;
|
|
8
|
+
/** A card's actions (see `CardRootProps.actionsRef`). */
|
|
9
|
+
export type CardActions = {
|
|
10
|
+
/**
|
|
11
|
+
* Lights it up as `active` does, for a moment, and fades it back: for
|
|
12
|
+
* something that happened, for example a doorbell rung, told by the app's
|
|
13
|
+
* server.
|
|
14
|
+
*/
|
|
15
|
+
flash: () => void;
|
|
16
|
+
};
|
|
17
|
+
export type CardRootProps = useRender.ComponentProps<'div'> & GlassSurfaceProps & {
|
|
18
|
+
/** Its actions (`flash`), for the app to call from anywhere. */
|
|
19
|
+
actionsRef?: RefObject<CardActions | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Whether what it switches is on (`true`, lit) or off (`false`, dark
|
|
22
|
+
* glass, in both color schemes), so it can be told at a glance: e.g. a
|
|
23
|
+
* group of lights, at least one of them on. Left out, it isn't
|
|
24
|
+
* switchable (e.g. a sensor's): its glass by the color scheme (or its
|
|
25
|
+
* `context`). A switch in it makes it switchable, by its state.
|
|
26
|
+
* @default not switchable (or by its switch)
|
|
27
|
+
*/
|
|
28
|
+
active?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether it's a momentary button: a press flashes it (see `actionsRef`),
|
|
31
|
+
* for a press with no state of its own, for example a chime or “all
|
|
32
|
+
* lights off”. Needs an `onClick`.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
momentary?: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type CardSymbolProps = ComponentProps<'span'> & {
|
|
38
|
+
/**
|
|
39
|
+
* Whether it shows what it stands for as on, in its tint and its
|
|
40
|
+
* `Symbol`'s `emphasizedIcon` (e.g. filled): for a card that isn't lit
|
|
41
|
+
* while on, for example a dimmer's above its minimum (its fill telling how
|
|
42
|
+
* much). A lit card's symbol shows as on anyway; off, its `icon` (e.g.
|
|
43
|
+
* outlined).
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
active?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Its color while `active` (a CSS color).
|
|
49
|
+
* @default the switch's on color (`--uikit-switch-on-color`)
|
|
50
|
+
*/
|
|
51
|
+
tint?: string;
|
|
52
|
+
};
|
|
53
|
+
export type CardSwitchProps = Omit<SwitchRootProps, 'children' | 'ref' | 'tint'> & {
|
|
54
|
+
/**
|
|
55
|
+
* Its color while on (a CSS color): the card's tint, as its symbol's.
|
|
56
|
+
* Over a slider's fill, and in a card never lit (`active` given false,
|
|
57
|
+
* e.g. a dimmer's) at every size, a darker shade of it (it's the fill's
|
|
58
|
+
* color too, see `ControlCards`); off there, a darker shade of the fill's
|
|
59
|
+
* gray.
|
|
60
|
+
* @default the system green; over a slider's fill, the app's tint
|
|
61
|
+
*/
|
|
62
|
+
tint?: string;
|
|
63
|
+
};
|
|
64
|
+
export type CardTitleProps = ComponentProps<'span'>;
|
|
65
|
+
export type CardValueProps = Omit<ComponentProps<'span'>, 'children'> & {
|
|
66
|
+
/** What it shows instead of a number (e.g. a state: “Locked”). */
|
|
67
|
+
children?: ReactNode;
|
|
68
|
+
/**
|
|
69
|
+
* How its `value` is formatted: options for `Intl.NumberFormat` (e.g.
|
|
70
|
+
* `{ maximumFractionDigits: 1, style: 'unit', unit: 'celsius' }`), the
|
|
71
|
+
* app's to choose (its unit, its decimal places).
|
|
72
|
+
*/
|
|
73
|
+
format?: Intl.NumberFormatOptions;
|
|
74
|
+
/** The locale its `value` is formatted for (default: the document's). */
|
|
75
|
+
locale?: Intl.LocalesArgument;
|
|
76
|
+
/** A number, formatted (see `format`); else its children. */
|
|
77
|
+
value?: number;
|
|
78
|
+
};
|
|
79
|
+
/** A card's orientation (see `useCardOrientation`). */
|
|
80
|
+
export type CardOrientation = 'horizontal' | 'vertical';
|
|
81
|
+
/** The sizes each kind of card supports (see `cardSizes`). */
|
|
82
|
+
export type CardSizes = Readonly<Record<'binaryControl' | 'binaryDisplay' | 'choiceControl' | 'numericalControl' | 'numericalDisplay' | 'summaryDisplay', readonly GridSize[]>>;
|
|
83
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/components/card/props.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,+EAA+E;AAC/E,MAAM,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAE1D,yDAAyD;AACzD,MAAM,MAAM,WAAW,GAAG;IACxB;;;;OAIG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,GACzD,iBAAiB,GAAG;IAClB,gEAAgE;IAChE,UAAU,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC3C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