@mrpelz/uikit-ish 7.26.2 → 7.29.1
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 +0 -3
- package/dist/components/activity-view/style.css +17 -17
- package/dist/components/alert/style.css +12 -10
- package/dist/components/avatar/style.css +2 -2
- package/dist/components/badge/style.css +1 -1
- package/dist/components/button/style.css +12 -12
- package/dist/components/card/buttons.d.ts +35 -0
- package/dist/components/card/buttons.d.ts.map +1 -0
- package/dist/components/card/buttons.js +60 -0
- package/dist/components/card/buttons.js.map +1 -0
- package/dist/components/card/channels.d.ts +43 -0
- package/dist/components/card/channels.d.ts.map +1 -0
- package/dist/components/card/channels.js +321 -0
- package/dist/components/card/channels.js.map +1 -0
- package/dist/components/card/color.d.ts +21 -0
- package/dist/components/card/color.d.ts.map +1 -0
- package/dist/components/card/color.js +100 -0
- package/dist/components/card/color.js.map +1 -0
- package/dist/components/card/main.d.ts +67 -39
- package/dist/components/card/main.d.ts.map +1 -1
- package/dist/components/card/main.js +79 -274
- package/dist/components/card/main.js.map +1 -1
- package/dist/components/card/parts.css +769 -0
- package/dist/components/card/press.d.ts +25 -0
- package/dist/components/card/press.d.ts.map +1 -0
- package/dist/components/card/press.js +111 -0
- package/dist/components/card/press.js.map +1 -0
- package/dist/components/card/progress.d.ts +43 -0
- package/dist/components/card/progress.d.ts.map +1 -0
- package/dist/components/card/progress.js +122 -0
- package/dist/components/card/progress.js.map +1 -0
- package/dist/components/card/props.d.ts +324 -14
- package/dist/components/card/props.d.ts.map +1 -1
- package/dist/components/card/root.d.ts +100 -0
- package/dist/components/card/root.d.ts.map +1 -0
- package/dist/components/card/root.js +388 -0
- package/dist/components/card/root.js.map +1 -0
- package/dist/components/card/rows.d.ts +19 -0
- package/dist/components/card/rows.d.ts.map +1 -0
- package/dist/components/card/rows.js +185 -0
- package/dist/components/card/rows.js.map +1 -0
- package/dist/components/card/segmented.d.ts +61 -0
- package/dist/components/card/segmented.d.ts.map +1 -0
- package/dist/components/card/segmented.js +289 -0
- package/dist/components/card/segmented.js.map +1 -0
- package/dist/components/card/shared.d.ts +55 -0
- package/dist/components/card/shared.d.ts.map +1 -0
- package/dist/components/card/shared.js +80 -0
- package/dist/components/card/shared.js.map +1 -0
- package/dist/components/card/slider.d.ts +16 -0
- package/dist/components/card/slider.d.ts.map +1 -0
- package/dist/components/card/slider.js +48 -0
- package/dist/components/card/slider.js.map +1 -0
- package/dist/components/card/stages.d.ts +18 -0
- package/dist/components/card/stages.d.ts.map +1 -0
- package/dist/components/card/stages.js +37 -0
- package/dist/components/card/stages.js.map +1 -0
- package/dist/components/card/style.css +125 -66
- package/dist/components/checkbox/style.css +10 -5
- package/dist/components/collapsible/style.css +0 -3
- package/dist/components/color-picker/color.d.ts +2 -2
- package/dist/components/color-picker/color.d.ts.map +1 -1
- package/dist/components/color-picker/color.js +7 -7
- package/dist/components/color-picker/color.js.map +1 -1
- package/dist/components/color-picker/main.d.ts +11 -5
- package/dist/components/color-picker/main.d.ts.map +1 -1
- package/dist/components/color-picker/main.js +128 -57
- package/dist/components/color-picker/main.js.map +1 -1
- package/dist/components/color-picker/props.d.ts +216 -6
- package/dist/components/color-picker/props.d.ts.map +1 -1
- package/dist/components/color-picker/style.css +8 -8
- package/dist/components/control-cards/main.d.ts +6 -17
- package/dist/components/control-cards/main.d.ts.map +1 -1
- package/dist/components/control-cards/main.js +119 -758
- package/dist/components/control-cards/main.js.map +1 -1
- package/dist/components/control-cards/props.d.ts +79 -250
- package/dist/components/control-cards/props.d.ts.map +1 -1
- package/dist/components/control-cards/style.css +2 -492
- package/dist/components/date-picker/main.d.ts +8 -3
- package/dist/components/date-picker/main.d.ts.map +1 -1
- package/dist/components/date-picker/main.js +71 -29
- package/dist/components/date-picker/main.js.map +1 -1
- package/dist/components/date-picker/pager.d.ts.map +1 -1
- package/dist/components/date-picker/pager.js +9 -2
- package/dist/components/date-picker/pager.js.map +1 -1
- package/dist/components/date-picker/props.d.ts +81 -5
- package/dist/components/date-picker/props.d.ts.map +1 -1
- package/dist/components/date-picker/style.css +24 -16
- package/dist/components/edit-menu/style.css +2 -2
- package/dist/components/glass/style.css +38 -5
- package/dist/components/grid/main.d.ts +1 -1
- package/dist/components/grid/main.d.ts.map +1 -1
- package/dist/components/grid/main.js +104 -21
- package/dist/components/grid/main.js.map +1 -1
- package/dist/components/grid/props.d.ts +75 -5
- package/dist/components/grid/props.d.ts.map +1 -1
- package/dist/components/grid/style.css +68 -38
- package/dist/components/header/style.css +12 -6
- package/dist/components/index.d.ts +10 -8
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6 -4
- package/dist/components/index.js.map +1 -1
- package/dist/components/layout/style.css +0 -3
- package/dist/components/list/main.d.ts +5 -3
- package/dist/components/list/main.d.ts.map +1 -1
- package/dist/components/list/main.js +42 -5
- package/dist/components/list/main.js.map +1 -1
- package/dist/components/list/props.d.ts +5 -0
- package/dist/components/list/props.d.ts.map +1 -1
- package/dist/components/list/reorder.d.ts +34 -0
- package/dist/components/list/reorder.d.ts.map +1 -1
- package/dist/components/list/reorder.js +40 -17
- package/dist/components/list/reorder.js.map +1 -1
- package/dist/components/list/style.css +135 -72
- package/dist/components/menu/style.css +38 -30
- package/dist/components/navigation/main.d.ts.map +1 -1
- package/dist/components/navigation/main.js +35 -13
- package/dist/components/navigation/main.js.map +1 -1
- package/dist/components/navigation/style.css +7 -0
- package/dist/components/page-control/main.d.ts.map +1 -1
- package/dist/components/page-control/main.js +32 -15
- package/dist/components/page-control/main.js.map +1 -1
- package/dist/components/page-control/props.d.ts +6 -0
- package/dist/components/page-control/props.d.ts.map +1 -1
- package/dist/components/page-control/style.css +36 -0
- package/dist/components/pager/main.d.ts +12 -0
- package/dist/components/pager/main.d.ts.map +1 -0
- package/dist/components/pager/main.js +368 -0
- package/dist/components/pager/main.js.map +1 -0
- package/dist/components/pager/props.d.ts +36 -0
- package/dist/components/pager/props.d.ts.map +1 -0
- package/dist/components/pager/props.js +2 -0
- package/dist/components/pager/props.js.map +1 -0
- package/dist/components/pager/style.css +42 -0
- package/dist/components/progress/main.d.ts.map +1 -1
- package/dist/components/progress/main.js +3 -2
- package/dist/components/progress/main.js.map +1 -1
- package/dist/components/progress/style.css +4 -10
- package/dist/components/roll/style.css +2 -2
- package/dist/components/segmented/style.css +16 -7
- package/dist/components/settings/main.d.ts +35 -1
- package/dist/components/settings/main.d.ts.map +1 -1
- package/dist/components/settings/main.js +297 -68
- package/dist/components/settings/main.js.map +1 -1
- package/dist/components/settings/props.d.ts +45 -4
- package/dist/components/settings/props.d.ts.map +1 -1
- package/dist/components/settings/region.d.ts +3 -0
- package/dist/components/settings/region.d.ts.map +1 -0
- package/dist/components/settings/region.js +120 -0
- package/dist/components/settings/region.js.map +1 -0
- package/dist/components/settings/style.css +2 -2
- package/dist/components/sheet/snap.d.ts.map +1 -1
- package/dist/components/sheet/snap.js +13 -5
- package/dist/components/sheet/snap.js.map +1 -1
- package/dist/components/sheet/style.css +48 -3
- package/dist/components/slider/main.d.ts.map +1 -1
- package/dist/components/slider/main.js +5 -2
- package/dist/components/slider/main.js.map +1 -1
- package/dist/components/slider/style.css +6 -6
- package/dist/components/stack/main.d.ts +8 -0
- package/dist/components/stack/main.d.ts.map +1 -0
- package/dist/components/stack/main.js +25 -0
- package/dist/components/stack/main.js.map +1 -0
- package/dist/components/stack/props.d.ts +42 -0
- package/dist/components/stack/props.d.ts.map +1 -0
- package/dist/components/stack/props.js +2 -0
- package/dist/components/stack/props.js.map +1 -0
- package/dist/components/stack/style.css +68 -0
- package/dist/components/stepper/main.d.ts +3 -1
- package/dist/components/stepper/main.d.ts.map +1 -1
- package/dist/components/stepper/main.js +4 -0
- package/dist/components/stepper/main.js.map +1 -1
- package/dist/components/stepper/style.css +2 -2
- package/dist/components/switch/main.d.ts.map +1 -1
- package/dist/components/switch/main.js +5 -1
- package/dist/components/switch/main.js.map +1 -1
- package/dist/components/switch/props.d.ts +4 -1
- package/dist/components/switch/props.d.ts.map +1 -1
- package/dist/components/tab-bar/style.css +36 -13
- package/dist/components/text-field/style.css +28 -17
- package/dist/components/toolbar/main.d.ts +5 -2
- package/dist/components/toolbar/main.d.ts.map +1 -1
- package/dist/components/toolbar/main.js +18 -0
- package/dist/components/toolbar/main.js.map +1 -1
- package/dist/components/toolbar/props.d.ts +15 -0
- package/dist/components/toolbar/props.d.ts.map +1 -1
- package/dist/components/toolbar/style.css +126 -10
- package/dist/components/tooltip/style.css +2 -2
- package/dist/components/typography/main.d.ts +1 -0
- package/dist/components/typography/main.d.ts.map +1 -1
- package/dist/components/typography/main.js +1 -0
- package/dist/components/typography/main.js.map +1 -1
- package/dist/components/typography/sizes.css +456 -0
- package/dist/components/typography/style.css +24 -456
- package/dist/components/utils/main.d.ts +23 -6
- package/dist/components/utils/main.d.ts.map +1 -1
- package/dist/components/utils/main.js +60 -7
- package/dist/components/utils/main.js.map +1 -1
- package/dist/components/viewport/edge-effect.d.ts.map +1 -1
- package/dist/components/viewport/edge-effect.js +6 -2
- package/dist/components/viewport/edge-effect.js.map +1 -1
- package/dist/components/viewport/focus-scroll.d.ts.map +1 -1
- package/dist/components/viewport/focus-scroll.js +2 -1
- package/dist/components/viewport/focus-scroll.js.map +1 -1
- package/dist/components/viewport/main.d.ts.map +1 -1
- package/dist/components/viewport/main.js +34 -2
- package/dist/components/viewport/main.js.map +1 -1
- package/dist/components/viewport/style.css +7 -13
- package/dist/styles.css +287 -120
- package/package.json +1 -1
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Slider as BaseSlider } from '@base-ui/react/slider';
|
|
3
|
+
import { createContext, forwardRef, useCallback, useContext, useId, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
4
|
+
import { useLocale, useSettings } from '../settings/main.js';
|
|
5
|
+
import { cn, withStyle } from '../utils/main.js';
|
|
6
|
+
import { colorAt, colorAtLinear, cssOf, linearOf, textSchemeOn, } from './color.js';
|
|
7
|
+
import { pressProps } from './press.js';
|
|
8
|
+
import { formattedShare, percentFormat, shareOf, useControlled, } from './shared.js';
|
|
9
|
+
/** A card's channels' own, for each channel: where it reports its light. */
|
|
10
|
+
const ChannelsContext = createContext(undefined);
|
|
11
|
+
export const ChannelsHostContext = createContext(undefined);
|
|
12
|
+
/**
|
|
13
|
+
* What a light's channels make together: the amounts added up, tinted by
|
|
14
|
+
* the scales (multiplied: e.g. a brightness, by a color temperature), at
|
|
15
|
+
* full strength (its strongest channel full: its color, not how bright,
|
|
16
|
+
* see its value); none giving any, none.
|
|
17
|
+
*/
|
|
18
|
+
const lightColorOf = (lights) => {
|
|
19
|
+
const amounts = lights.filter(({ kind }) => kind === 'amount');
|
|
20
|
+
let rgb = amounts.length === 0 ? [1, 1, 1] : [0, 0, 0];
|
|
21
|
+
for (const { rgb: [red, green, blue], } of amounts) {
|
|
22
|
+
rgb = [rgb[0] + red, rgb[1] + green, rgb[2] + blue];
|
|
23
|
+
}
|
|
24
|
+
for (const { kind, rgb: [red, green, blue], } of lights) {
|
|
25
|
+
if (kind === 'scale')
|
|
26
|
+
rgb = [rgb[0] * red, rgb[1] * green, rgb[2] * blue];
|
|
27
|
+
}
|
|
28
|
+
const strongest = Math.max(...rgb);
|
|
29
|
+
return strongest <= 0
|
|
30
|
+
? undefined
|
|
31
|
+
: cssOf([rgb[0] / strongest, rgb[1] / strongest, rgb[2] / strongest]);
|
|
32
|
+
};
|
|
33
|
+
/** Its well's measures (px): its thumb's inset, its size; its labels'. */
|
|
34
|
+
const channelInset = 4;
|
|
35
|
+
const channelThumb = 28;
|
|
36
|
+
const channelPadding = 12;
|
|
37
|
+
const channelGap = 6;
|
|
38
|
+
/** How far its thumb clears a label moved away before it moves back. */
|
|
39
|
+
const channelSlack = 8;
|
|
40
|
+
/**
|
|
41
|
+
* A channel's colors as computed (vars, `light-dark()` resolved where it's
|
|
42
|
+
* drawn: its probes', see `Channel`), read as they or the color scheme
|
|
43
|
+
* change; and in linear light.
|
|
44
|
+
*/
|
|
45
|
+
const useResolvedColors = (probes, colors) => {
|
|
46
|
+
const { colorScheme } = useSettings();
|
|
47
|
+
const colorKey = colors.join('|');
|
|
48
|
+
const [resolved, setResolved] = useState([]);
|
|
49
|
+
useLayoutEffect(() => {
|
|
50
|
+
const { current: element } = probes;
|
|
51
|
+
if (!element)
|
|
52
|
+
return;
|
|
53
|
+
const read = () => {
|
|
54
|
+
const next = [...element.children].map((probe) => getComputedStyle(probe).color);
|
|
55
|
+
setResolved((last) => (last.join('|') === next.join('|') ? last : next));
|
|
56
|
+
};
|
|
57
|
+
read();
|
|
58
|
+
}, [colorKey, colorScheme, probes]);
|
|
59
|
+
const linear = useMemo(() => resolved
|
|
60
|
+
.map((color) => linearOf(color))
|
|
61
|
+
.filter((rgb) => rgb !== undefined), [resolved]);
|
|
62
|
+
return { linear, resolved };
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The light a channel gives, told its channels (see `Channels`): an
|
|
66
|
+
* amount's tint by its share, a scale's color at it; gone, none.
|
|
67
|
+
*/
|
|
68
|
+
const useChannelReport = (linear, isScale, share) => {
|
|
69
|
+
const report = useContext(ChannelsContext);
|
|
70
|
+
const id = useId();
|
|
71
|
+
useLayoutEffect(() => {
|
|
72
|
+
if (!report)
|
|
73
|
+
return;
|
|
74
|
+
const [own] = linear;
|
|
75
|
+
const rgb = isScale
|
|
76
|
+
? colorAtLinear(linear, share)
|
|
77
|
+
: own && [own[0] * share, own[1] * share, own[2] * share];
|
|
78
|
+
report(id, rgb && { kind: isScale ? 'scale' : 'amount', rgb, share });
|
|
79
|
+
}, [id, isScale, linear, report, share]);
|
|
80
|
+
useLayoutEffect(() => () => report?.(id, undefined), [id, report]);
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* A channel's own properties (see the CSS): the light at its thumb, a
|
|
84
|
+
* scale's colors along its well (their stops from its thumb's center at
|
|
85
|
+
* one end to it at the other), its share, its tint.
|
|
86
|
+
*/
|
|
87
|
+
const channelStyleOf = (scale, share, tint) => {
|
|
88
|
+
const middle = channelInset + channelThumb / 2;
|
|
89
|
+
return {
|
|
90
|
+
'--uikit-card-channel-light': scale
|
|
91
|
+
? colorAt(scale, share)
|
|
92
|
+
: `color-mix(in srgb-linear, var(--uikit-card-channel-tint) ${String(share * 100)}%, black)`,
|
|
93
|
+
'--uikit-card-channel-scale': scale
|
|
94
|
+
?.map((color, index) => `${color} calc(${String(middle)}px + (100% - ${String(2 * middle)}px) * ${String(index / (scale.length - 1))})`)
|
|
95
|
+
.join(', '),
|
|
96
|
+
'--uikit-card-channel-share': String(share),
|
|
97
|
+
'--uikit-card-channel-tint': tint,
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
/** An amount's fill's edge (px, from its start; see `placeChannelLabels`). */
|
|
101
|
+
const fillEdgeOf = (width, share) => {
|
|
102
|
+
if (share <= 0)
|
|
103
|
+
return 0;
|
|
104
|
+
if (share >= 1)
|
|
105
|
+
return width;
|
|
106
|
+
const middle = channelInset + channelThumb / 2;
|
|
107
|
+
return middle + (width - 2 * middle) * share;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* A channel's labels placed (see `Channel`): its name at its start, its
|
|
111
|
+
* value at its end, the one its thumb would cover beside the other (back
|
|
112
|
+
* once the thumb's clear of it by `channelSlack`); covered there too, in
|
|
113
|
+
* its place, each in the color scheme
|
|
114
|
+
* of what's under its center (an amount's fill, by its tint, see
|
|
115
|
+
* `textSchemeOn`; or its well; a scale's color there). Which were moved,
|
|
116
|
+
* for the next time.
|
|
117
|
+
*/
|
|
118
|
+
const placeChannelLabels = ({ element, linear, moved, named, scale, share, tint, valued, }) => {
|
|
119
|
+
const width = element.clientWidth;
|
|
120
|
+
const nameWidth = named.offsetWidth;
|
|
121
|
+
const valueWidth = valued.offsetWidth;
|
|
122
|
+
// (Its thumb, from its start: as Base UI insets it, see `Channel`.)
|
|
123
|
+
const thumbStart = channelInset + (width - 2 * channelInset - channelThumb) * share;
|
|
124
|
+
const thumbEnd = thumbStart + channelThumb;
|
|
125
|
+
const nameAt = [channelPadding, channelPadding + nameWidth];
|
|
126
|
+
const valueAt = [
|
|
127
|
+
width - channelPadding - valueWidth,
|
|
128
|
+
width - channelPadding,
|
|
129
|
+
];
|
|
130
|
+
const isOver = ([from, to], wasMoved) => {
|
|
131
|
+
const slack = wasMoved ? channelSlack : 0;
|
|
132
|
+
return thumbEnd > from - slack && thumbStart < to + slack;
|
|
133
|
+
};
|
|
134
|
+
// (Where each would go: beside the other, at the other end.)
|
|
135
|
+
const nameAside = [
|
|
136
|
+
valueAt[0] - channelGap - nameWidth,
|
|
137
|
+
valueAt[0] - channelGap,
|
|
138
|
+
];
|
|
139
|
+
const valueAside = [
|
|
140
|
+
nameAt[1] + channelGap,
|
|
141
|
+
nameAt[1] + channelGap + valueWidth,
|
|
142
|
+
];
|
|
143
|
+
// (Moved only to where the thumb isn't: covered at both ends, it stays.)
|
|
144
|
+
const nameMoved = isOver(nameAt, moved.name) && !isOver(nameAside, false);
|
|
145
|
+
const valueMoved = !nameMoved && isOver(valueAt, moved.value) && !isOver(valueAside, false);
|
|
146
|
+
const nameX = nameMoved ? nameAside[0] : nameAt[0];
|
|
147
|
+
const valueX = valueMoved ? valueAside[0] : valueAt[0];
|
|
148
|
+
const sign = getComputedStyle(element).direction === 'rtl' ? -1 : 1;
|
|
149
|
+
// (An amount's fill's edge, from its start: its thumb's center, its ends
|
|
150
|
+
// all the way, see the CSS.)
|
|
151
|
+
const edge = fillEdgeOf(width, share);
|
|
152
|
+
const schemeAt = (center) => {
|
|
153
|
+
if (scale) {
|
|
154
|
+
const rgb = colorAtLinear(linear, center / width);
|
|
155
|
+
return rgb && textSchemeOn(cssOf(rgb));
|
|
156
|
+
}
|
|
157
|
+
return center < edge && tint ? textSchemeOn(tint) : undefined;
|
|
158
|
+
};
|
|
159
|
+
for (const [label, x, labelWidth] of [
|
|
160
|
+
[named, nameX, nameWidth],
|
|
161
|
+
[valued, valueX, valueWidth],
|
|
162
|
+
]) {
|
|
163
|
+
label.style.translate = `${String(sign * x)}px 0`;
|
|
164
|
+
const scheme = schemeAt(x + labelWidth / 2);
|
|
165
|
+
label.style.colorScheme = scheme ?? '';
|
|
166
|
+
if (scheme)
|
|
167
|
+
label.dataset.colorScheme = scheme;
|
|
168
|
+
else
|
|
169
|
+
delete label.dataset.colorScheme;
|
|
170
|
+
}
|
|
171
|
+
// (Placed where it starts without sliding there; from then on, sliding,
|
|
172
|
+
// see the CSS.)
|
|
173
|
+
if (element.dataset.placed === undefined) {
|
|
174
|
+
requestAnimationFrame(() => {
|
|
175
|
+
element.dataset.placed = '';
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return { name: nameMoved, value: valueMoved };
|
|
179
|
+
};
|
|
180
|
+
/** The light its channels make together (see `CardLight`). */
|
|
181
|
+
const lightOf = (lights) => {
|
|
182
|
+
const amounts = lights.filter(({ kind }) => kind === 'amount');
|
|
183
|
+
return {
|
|
184
|
+
brightness: amounts.length === 0 ? 1 : Math.max(...amounts.map(({ share }) => share)),
|
|
185
|
+
color: lightColorOf(lights),
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* A card's channels (e.g. a light's red, green and blue): its sliders
|
|
190
|
+
* (`Channel`s, its children), each in a well of its own, stacked at its
|
|
191
|
+
* bottom, whatever its width. The light they make together told as it
|
|
192
|
+
* changes (`onLightChange`: their color, their brightness). In a
|
|
193
|
+
* ready-made light card, shown only while it's large (mounted all the
|
|
194
|
+
* same, unseen, telling it the light they give).
|
|
195
|
+
*/
|
|
196
|
+
export const Channels = forwardRef(({ children, className, hidden, onLightChange, ...props }, ref) => {
|
|
197
|
+
const host = useContext(ChannelsHostContext);
|
|
198
|
+
const [lights, setLights] = useState({});
|
|
199
|
+
const report = useCallback((id, light) => setLights((last) => {
|
|
200
|
+
const before = last[id];
|
|
201
|
+
if (before?.kind === light?.kind &&
|
|
202
|
+
before?.share === light?.share &&
|
|
203
|
+
before?.rgb.join(',') === light?.rgb.join(',')) {
|
|
204
|
+
return last;
|
|
205
|
+
}
|
|
206
|
+
const next = { ...last };
|
|
207
|
+
if (light)
|
|
208
|
+
next[id] = light;
|
|
209
|
+
else
|
|
210
|
+
delete next[id];
|
|
211
|
+
return next;
|
|
212
|
+
}), []);
|
|
213
|
+
const light = useMemo(() => lightOf(Object.values(lights)), [lights]);
|
|
214
|
+
const latest = useRef({ host, onLightChange });
|
|
215
|
+
useLayoutEffect(() => {
|
|
216
|
+
latest.current = { host, onLightChange };
|
|
217
|
+
});
|
|
218
|
+
// (Told as it changes, before it's painted: a ready-made card's
|
|
219
|
+
// symbol in its color at once.)
|
|
220
|
+
useLayoutEffect(() => {
|
|
221
|
+
latest.current.onLightChange?.(light);
|
|
222
|
+
latest.current.host?.onLightChange(light);
|
|
223
|
+
}, [light]);
|
|
224
|
+
return (_jsx("div", { ref: ref, ...props, className: cn('uikit-card-channels', className), "data-card-own-press": "", "data-card-part": "channels", hidden: hidden ?? (host ? !host.isShown : undefined), children: _jsx(ChannelsContext.Provider, { value: report, children: children }) }));
|
|
225
|
+
});
|
|
226
|
+
/**
|
|
227
|
+
* A channel: Base UI's slider in a well of its own, its thumb round, kept
|
|
228
|
+
* inside it (`thumbAlignment: 'edge'`), filled with the light it gives. An
|
|
229
|
+
* amount (`tint`): filled from its start in its tint as far as its thumb's
|
|
230
|
+
* center (all the way at its ends, sliding there), its thumb its tint mixed
|
|
231
|
+
* on black by its share (in linear light, as light adds up: none, black).
|
|
232
|
+
* A scale (`colors`): its colors along its well, its thumb the color at its
|
|
233
|
+
* value. Its label at its start, its value at its end; the one its thumb
|
|
234
|
+
* would cover sliding to the other end, beside the other, and back once
|
|
235
|
+
* the thumb's clear of it again (covered there too, in its place). Each
|
|
236
|
+
* label's color scheme by one sample
|
|
237
|
+
* under its center (the fill's, by its tint, see `textSchemeOn`; the
|
|
238
|
+
* well's; a scale's color there), its colors read as they or the color
|
|
239
|
+
* scheme change. A press held back until it's a drag along it (a touch
|
|
240
|
+
* across it the page's scroll); then its touch held from the page.
|
|
241
|
+
*/
|
|
242
|
+
export const Channel = forwardRef(({ children, className, colors, defaultValue, format = percentFormat, getAriaValueText, label, locale: ownLocale, max = 100, min = 0, onValueChange, step, style, tint, value, ...props }, ref) => {
|
|
243
|
+
const locale = useLocale(ownLocale);
|
|
244
|
+
const [current, setCurrent] = useControlled(value, defaultValue ?? min);
|
|
245
|
+
const share = shareOf(current, min, max);
|
|
246
|
+
const scale = colors && colors.length >= 2 ? colors : undefined;
|
|
247
|
+
const formattedValue = formattedShare(current, share, { format, locale });
|
|
248
|
+
const text = children ? children(formattedValue, current) : formattedValue;
|
|
249
|
+
// (Its colors resolved, see `useResolvedColors`; the light it gives
|
|
250
|
+
// told its channels, see `useChannelReport`.)
|
|
251
|
+
const probes = useRef(null);
|
|
252
|
+
const probed = scale ?? [tint ?? 'var(--color-ui-primary)'];
|
|
253
|
+
const { linear, resolved } = useResolvedColors(probes, probed);
|
|
254
|
+
useChannelReport(linear, scale !== undefined, share);
|
|
255
|
+
// (Its labels placed (see above), each in its color scheme: written as
|
|
256
|
+
// its value or its labels' sizes change, not rendered.)
|
|
257
|
+
const well = useRef(null);
|
|
258
|
+
const nameLabel = useRef(null);
|
|
259
|
+
const valueLabel = useRef(null);
|
|
260
|
+
const moved = useRef({ name: false, value: false });
|
|
261
|
+
const place = useRef(() => undefined);
|
|
262
|
+
useLayoutEffect(() => {
|
|
263
|
+
place.current = () => {
|
|
264
|
+
const { current: element } = well;
|
|
265
|
+
const { current: named } = nameLabel;
|
|
266
|
+
const { current: valued } = valueLabel;
|
|
267
|
+
if (!element || !named || !valued)
|
|
268
|
+
return;
|
|
269
|
+
moved.current = placeChannelLabels({
|
|
270
|
+
element,
|
|
271
|
+
linear,
|
|
272
|
+
moved: moved.current,
|
|
273
|
+
named,
|
|
274
|
+
scale: scale !== undefined,
|
|
275
|
+
share,
|
|
276
|
+
tint: resolved[0],
|
|
277
|
+
valued,
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
place.current();
|
|
281
|
+
});
|
|
282
|
+
useLayoutEffect(() => {
|
|
283
|
+
const observer = new ResizeObserver(() => place.current());
|
|
284
|
+
for (const element of [
|
|
285
|
+
well.current,
|
|
286
|
+
nameLabel.current,
|
|
287
|
+
valueLabel.current,
|
|
288
|
+
]) {
|
|
289
|
+
if (element)
|
|
290
|
+
observer.observe(element);
|
|
291
|
+
}
|
|
292
|
+
return () => observer.disconnect();
|
|
293
|
+
}, []);
|
|
294
|
+
// (Dragged (handed on to it, see `pressProps`): its touch's moves not
|
|
295
|
+
// the page's; not passive, as React's listeners are.)
|
|
296
|
+
useLayoutEffect(() => {
|
|
297
|
+
const { current: element } = well;
|
|
298
|
+
if (!element)
|
|
299
|
+
return undefined;
|
|
300
|
+
const hold = (move) => {
|
|
301
|
+
if (element.closest('[data-dragging]') && move.cancelable) {
|
|
302
|
+
move.preventDefault();
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
element.addEventListener('touchmove', hold, { passive: false });
|
|
306
|
+
return () => element.removeEventListener('touchmove', hold);
|
|
307
|
+
}, []);
|
|
308
|
+
// (At an end, its fill all the way, see the CSS.)
|
|
309
|
+
let edge;
|
|
310
|
+
if (share <= 0)
|
|
311
|
+
edge = 'min';
|
|
312
|
+
if (share >= 1)
|
|
313
|
+
edge = 'max';
|
|
314
|
+
return (_jsx(BaseSlider.Root, { ref: ref, ...props, className: cn('uikit-card-channel', className), "data-card-part": "channel", "data-scale": scale ? '' : undefined, format: format, locale: locale, max: max, min: min, step: step ?? (max - min) / 100, style: withStyle(channelStyleOf(scale, share, tint), style), thumbAlignment: "edge", value: current, onValueChange: (next) => {
|
|
315
|
+
setCurrent(next);
|
|
316
|
+
onValueChange?.(next);
|
|
317
|
+
}, ...pressProps(undefined, 'horizontal'), children: _jsxs("div", { ref: well, className: "uikit-card-channel-well", children: [scale ? null : (_jsx("span", { "aria-hidden": "true", className: "uikit-card-channel-fill", "data-edge": edge })), _jsx("span", { ref: probes, hidden: true, "aria-hidden": "true", children: probed.map((color, index) => (_jsx("span", { style: { color } }, index))) }), _jsx("span", { ref: nameLabel, "aria-hidden": "true", className: "uikit-card-channel-label", children: label }), _jsx("span", { ref: valueLabel, "aria-hidden": "true", className: "uikit-card-channel-value", children: text }), _jsx(BaseSlider.Control, { className: "uikit-card-channel-control", children: _jsx(BaseSlider.Track, { className: "uikit-card-channel-track", children: _jsx(BaseSlider.Thumb, { "aria-label": label, className: "uikit-card-channel-thumb", getAriaValueText: getAriaValueText
|
|
318
|
+
? (formattedThumb, thumbValue) => getAriaValueText(formattedThumb, thumbValue)
|
|
319
|
+
: undefined }) }) })] }) }));
|
|
320
|
+
});
|
|
321
|
+
//# sourceMappingURL=channels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels.js","sourceRoot":"","sources":["../../../src/components/card/channels.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,UAAU,EACV,WAAW,EACX,UAAU,EACV,KAAK,EACL,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,OAAO,EACP,aAAa,EACb,KAAK,EACL,QAAQ,EAER,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAMxC,OAAO,EACL,cAAc,EACd,aAAa,EACb,OAAO,EACP,aAAa,GACd,MAAM,aAAa,CAAC;AAmBrB,4EAA4E;AAC5E,MAAM,eAAe,GAAG,aAAa,CAA4B,SAAS,CAAC,CAA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AC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAC5B,eAEE,KAAK,EAAE,EAAE,KAAK,EAAE,IADX,KAAK,CAEV,CACH,CAAC,GACG,EACP,eACE,GAAG,EAAE,SAAS,iBACF,MAAM,EAClB,SAAS,EAAC,0BAA0B,YAEnC,KAAK,GACD,EACP,eACE,GAAG,EAAE,UAAU,iBACH,MAAM,EAClB,SAAS,EAAC,0BAA0B,YAEnC,IAAI,GACA,EACP,KAAC,UAAU,CAAC,OAAO,IAAC,SAAS,EAAC,4BAA4B,YACxD,KAAC,UAAU,CAAC,KAAK,IAAC,SAAS,EAAC,0BAA0B,YACpD,KAAC,UAAU,CAAC,KAAK,kBACH,KAAK,EACjB,SAAS,EAAC,0BAA0B,EACpC,gBAAgB,EACd,gBAAgB;gCACd,CAAC,CAAC,CAAC,cAAc,EAAE,UAAU,EAAE,EAAE,CAC7B,gBAAgB,CAAC,cAAc,EAAE,UAAU,CAAC;gCAChD,CAAC,CAAC,SAAS,GAEf,GACe,GACA,IACjB,GACU,CACnB,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The color scheme of what's drawn on a color (e.g. a fill): dark text (a
|
|
3
|
+
* light scheme) or light text (a dark one), whichever contrasts more with
|
|
4
|
+
* it, by APCA (perceived contrast: e.g. a mid blue, light text, where
|
|
5
|
+
* WCAG's ratio picks dark); unreadable or nearly clear, none.
|
|
6
|
+
*/
|
|
7
|
+
export declare const textSchemeOn: (color: string) => "dark" | "light" | undefined;
|
|
8
|
+
/** A color's channels, linear light (0 to 1 each). */
|
|
9
|
+
export type LinearRgb = readonly [red: number, green: number, blue: number];
|
|
10
|
+
/** A computed color in linear light; unreadable, none. */
|
|
11
|
+
export declare const linearOf: (color: string) => LinearRgb | undefined;
|
|
12
|
+
/** Linear light as a CSS color (sRGB). */
|
|
13
|
+
export declare const cssOf: ([red, green, blue]: LinearRgb) => string;
|
|
14
|
+
/**
|
|
15
|
+
* A scale's color at a share (see `scaleSegment`): the two around it mixed
|
|
16
|
+
* in linear light, as CSS (its thumb's).
|
|
17
|
+
*/
|
|
18
|
+
export declare const colorAt: (colors: readonly string[], share: number) => string;
|
|
19
|
+
/** A scale's light at a share (see `colorAt`), from its colors' light. */
|
|
20
|
+
export declare const colorAtLinear: (colors: readonly LinearRgb[], share: number) => LinearRgb | undefined;
|
|
21
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/components/card/color.ts"],"names":[],"mappings":"AAkCA;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,MAAM,GAAG,OAAO,GAAG,SAQ/D,CAAC;AAEF,sDAAsD;AACtD,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAkB5E,0DAA0D;AAC1D,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,KAAG,SAAS,GAAG,SAQpD,CAAC;AAEF,0CAA0C;AAC1C,eAAO,MAAM,KAAK,GAAI,oBAAoB,SAAS,KAAG,MACkD,CAAC;AAYzG;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,QAAQ,SAAS,MAAM,EAAE,EAAE,OAAO,MAAM,KAAG,MAGlE,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,aAAa,GACxB,QAAQ,SAAS,SAAS,EAAE,EAC5B,OAAO,MAAM,KACZ,SAAS,GAAG,SAUd,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { parseCssColor } from '../color-picker/color.js';
|
|
2
|
+
// Colors for what cards draw on colored surfaces (a fill, a channel): the
|
|
3
|
+
// color scheme of text on a color (by APCA), and light added up in linear
|
|
4
|
+
// light (see the channels, channels.tsx).
|
|
5
|
+
/** APCA's luminance of an sRGB color (0 to 255 each), soft-clamped at black. */
|
|
6
|
+
const apcaLuminanceOf = (red, green, blue) => {
|
|
7
|
+
const luminance = 0.212_672_9 * (red / 255) ** 2.4 +
|
|
8
|
+
0.715_152_2 * (green / 255) ** 2.4 +
|
|
9
|
+
0.072_175 * (blue / 255) ** 2.4;
|
|
10
|
+
return luminance < 0.022
|
|
11
|
+
? luminance + (0.022 - luminance) ** 1.414
|
|
12
|
+
: luminance;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* APCA's contrast of text on a background (Lc's magnitude, 0 to about 108),
|
|
16
|
+
* by their luminances (see `apcaLuminanceOf`): dark text on light, or light
|
|
17
|
+
* text on dark, each by its own curve.
|
|
18
|
+
*/
|
|
19
|
+
const apcaContrastOf = (text, background) => {
|
|
20
|
+
if (background > text) {
|
|
21
|
+
const contrast = (background ** 0.56 - text ** 0.57) * 1.14;
|
|
22
|
+
return contrast < 0.1 ? 0 : (contrast - 0.027) * 100;
|
|
23
|
+
}
|
|
24
|
+
const contrast = (background ** 0.65 - text ** 0.62) * 1.14;
|
|
25
|
+
return contrast > -0.1 ? 0 : -(contrast + 0.027) * 100;
|
|
26
|
+
};
|
|
27
|
+
const darkText = apcaLuminanceOf(0, 0, 0);
|
|
28
|
+
const lightText = apcaLuminanceOf(255, 255, 255);
|
|
29
|
+
/**
|
|
30
|
+
* The color scheme of what's drawn on a color (e.g. a fill): dark text (a
|
|
31
|
+
* light scheme) or light text (a dark one), whichever contrasts more with
|
|
32
|
+
* it, by APCA (perceived contrast: e.g. a mid blue, light text, where
|
|
33
|
+
* WCAG's ratio picks dark); unreadable or nearly clear, none.
|
|
34
|
+
*/
|
|
35
|
+
export const textSchemeOn = (color) => {
|
|
36
|
+
const parsed = parseCssColor(color);
|
|
37
|
+
if (!parsed || parsed.a < 0.3)
|
|
38
|
+
return undefined;
|
|
39
|
+
const background = apcaLuminanceOf(parsed.r, parsed.g, parsed.b);
|
|
40
|
+
return apcaContrastOf(darkText, background) >=
|
|
41
|
+
apcaContrastOf(lightText, background)
|
|
42
|
+
? 'light'
|
|
43
|
+
: 'dark';
|
|
44
|
+
};
|
|
45
|
+
/** An sRGB channel (0 to 255), linear (0 to 1). */
|
|
46
|
+
const linearChannel = (channel) => {
|
|
47
|
+
const value = channel / 255;
|
|
48
|
+
return value <= 0.040_45 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
49
|
+
};
|
|
50
|
+
/** A linear channel (0 to 1), sRGB (0 to 255). */
|
|
51
|
+
const encodedChannel = (channel) => {
|
|
52
|
+
const value = Math.min(Math.max(channel, 0), 1);
|
|
53
|
+
return Math.round((value <= 0.003_130_8
|
|
54
|
+
? value * 12.92
|
|
55
|
+
: 1.055 * value ** (1 / 2.4) - 0.055) * 255);
|
|
56
|
+
};
|
|
57
|
+
/** A computed color in linear light; unreadable, none. */
|
|
58
|
+
export const linearOf = (color) => {
|
|
59
|
+
const parsed = parseCssColor(color);
|
|
60
|
+
if (!parsed)
|
|
61
|
+
return undefined;
|
|
62
|
+
return [
|
|
63
|
+
linearChannel(parsed.r),
|
|
64
|
+
linearChannel(parsed.g),
|
|
65
|
+
linearChannel(parsed.b),
|
|
66
|
+
];
|
|
67
|
+
};
|
|
68
|
+
/** Linear light as a CSS color (sRGB). */
|
|
69
|
+
export const cssOf = ([red, green, blue]) => `rgb(${String(encodedChannel(red))} ${String(encodedChannel(green))} ${String(encodedChannel(blue))})`;
|
|
70
|
+
/**
|
|
71
|
+
* Where a share (0 to 1) falls among a scale's colors (evenly spread): the
|
|
72
|
+
* color before it, and how far it is toward the next (0 to 1).
|
|
73
|
+
*/
|
|
74
|
+
const scaleSegment = (count, share) => {
|
|
75
|
+
const at = share * (count - 1);
|
|
76
|
+
const index = Math.min(Math.floor(at), count - 2);
|
|
77
|
+
return { index, part: at - index };
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* A scale's color at a share (see `scaleSegment`): the two around it mixed
|
|
81
|
+
* in linear light, as CSS (its thumb's).
|
|
82
|
+
*/
|
|
83
|
+
export const colorAt = (colors, share) => {
|
|
84
|
+
const { index, part } = scaleSegment(colors.length, share);
|
|
85
|
+
return `color-mix(in srgb-linear, ${colors[index + 1] ?? ''} ${String(part * 100)}%, ${colors[index] ?? ''})`;
|
|
86
|
+
};
|
|
87
|
+
/** A scale's light at a share (see `colorAt`), from its colors' light. */
|
|
88
|
+
export const colorAtLinear = (colors, share) => {
|
|
89
|
+
const { index, part } = scaleSegment(colors.length, share);
|
|
90
|
+
const from = colors[index];
|
|
91
|
+
const to = colors[index + 1];
|
|
92
|
+
if (!from || !to)
|
|
93
|
+
return undefined;
|
|
94
|
+
return [
|
|
95
|
+
from[0] + (to[0] - from[0]) * part,
|
|
96
|
+
from[1] + (to[1] - from[1]) * part,
|
|
97
|
+
from[2] + (to[2] - from[2]) * part,
|
|
98
|
+
];
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../../src/components/card/color.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,0EAA0E;AAC1E,0EAA0E;AAC1E,0CAA0C;AAE1C,gFAAgF;AAChF,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,IAAY,EAAE,EAAE;IACnE,MAAM,SAAS,GACb,WAAW,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,IAAI,GAAG;QAChC,WAAW,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,GAAG;QAClC,SAAS,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC;IAClC,OAAO,SAAS,GAAG,KAAK;QACtB,CAAC,CAAC,SAAS,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,IAAI,KAAK;QAC1C,CAAC,CAAC,SAAS,CAA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,OAAO,SAAS,CAAC;IACnC,OAAO;QACL,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;QAClC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;QAClC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;KACnC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -2,52 +2,80 @@ import '../glass/style.css';
|
|
|
2
2
|
import '../switch/style.css';
|
|
3
3
|
import '../slider/style.css';
|
|
4
4
|
import '../grid/style.css';
|
|
5
|
+
import '../list/style.css';
|
|
5
6
|
import './style.css';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
/** A card's copy layer and its setter (see `CardBlendScope`). */
|
|
10
|
-
type CardBlend = {
|
|
11
|
-
layer: HTMLElement | null;
|
|
12
|
-
setLayer: (layer: HTMLElement | null) => void;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* A layer over the card's content where its parts draw a copy of
|
|
16
|
-
* themselves (`Card.Symbol`, `Card.CornerButton`): e.g. inside a slider's
|
|
17
|
-
* fill filling the card, in the fill's color scheme, clipped by its edge
|
|
18
|
-
* (see ControlCards' `SliderFill`), registered by it (`setLayer`); the
|
|
19
|
-
* root marked `data-card-blend` while there is one (its originals under
|
|
20
|
-
* the fill, see style.css). None: no copies. Internal.
|
|
21
|
-
*/
|
|
22
|
-
export declare const CardBlendScope: import("preact").Context<CardBlend | undefined>;
|
|
23
|
-
/** The tile's shape (its item's effective size): wide, horizontal. */
|
|
24
|
-
export declare const useCardOrientation: () => CardOrientation;
|
|
25
|
-
/**
|
|
26
|
-
* The sizes the library's kinds of cards support, for their items'
|
|
27
|
-
* `supportedSizes`: a binary display or control (a state, a switch), a
|
|
28
|
-
* numerical display (a value) or control (a slider: never square, so it
|
|
29
|
-
* has a direction), a choice of a few (segments: across a row, taller,
|
|
30
|
-
* upright, or 1x1 opening to choose), a summary (rows: never 1x1).
|
|
31
|
-
*/
|
|
32
|
-
export declare const cardSizes: CardSizes;
|
|
7
|
+
import './parts.css';
|
|
8
|
+
export type { CardActions, CardChannelProps, CardChannelsProps, CardCloseButtonProps, CardCornerButtonProps, CardExpandButtonProps, CardFormat, CardLight, CardOpenButtonProps, CardOrientation, CardProgressBarProps, CardProgressDetailProps, CardProgressLabelProps, CardProgressProps, CardProgressValueProps, CardRootProps, CardRowProps, CardRowsProps, CardSegmentedItemProps, CardSegmentedProps, CardSizes, CardSliderProps, CardStageListProps, CardStageProps, CardSubtitleProps, CardSwitchProps, CardSymbolProps, CardTitleProps, CardTrendProps, CardValueProps, } from './props.js';
|
|
9
|
+
export { CardBlendScope, cardSizes, useCardOrientation } from './root.js';
|
|
33
10
|
export declare const Card: {
|
|
34
|
-
|
|
35
|
-
ref?: Ref<
|
|
11
|
+
Root: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardRootProps> & {
|
|
12
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
Symbol: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardSymbolProps> & {
|
|
15
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
Title: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardTitleProps> & {
|
|
18
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
Subtitle: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardSubtitleProps> & {
|
|
21
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
Value: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardValueProps> & {
|
|
24
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
Trend: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardTrendProps> & {
|
|
27
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
Switch: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardSwitchProps> & {
|
|
30
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
Slider: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardSliderProps> & {
|
|
33
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
Progress: ({ children, format, getAriaValueText, locale: ownLocale, max, min, value, }: import("./props.js").CardProgressProps) => import("preact").ComponentChild;
|
|
36
|
+
ProgressValue: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardProgressValueProps> & {
|
|
37
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
ProgressBar: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardProgressBarProps> & {
|
|
40
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
ProgressLabel: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardProgressLabelProps> & {
|
|
43
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
ProgressDetail: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardProgressDetailProps> & {
|
|
46
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
StageList: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardStageListProps> & {
|
|
49
|
+
ref?: import("preact").Ref<HTMLOListElement> | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
Stage: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardStageProps> & {
|
|
52
|
+
ref?: import("preact").Ref<HTMLLIElement> | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
Channels: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardChannelsProps> & {
|
|
55
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
56
|
+
}>;
|
|
57
|
+
Channel: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardChannelProps> & {
|
|
58
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
59
|
+
}>;
|
|
60
|
+
Segmented: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardSegmentedProps> & {
|
|
61
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
36
62
|
}>;
|
|
37
|
-
|
|
38
|
-
ref?: Ref<
|
|
63
|
+
SegmentedItem: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardSegmentedItemProps> & {
|
|
64
|
+
ref?: import("preact").Ref<HTMLElement> | undefined;
|
|
39
65
|
}>;
|
|
40
|
-
|
|
41
|
-
|
|
66
|
+
Rows: ({ children, className, getMoreLabel, lessLabel, ...props }: import("./props.js").CardRowsProps) => import("preact").ComponentChild;
|
|
67
|
+
Row: ({ children, icon, onClick, value, ...props }: import("./props.js").CardRowProps) => import("preact").ComponentChild;
|
|
68
|
+
CornerButton: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardCornerButtonProps> & {
|
|
69
|
+
ref?: import("preact").Ref<HTMLButtonElement> | undefined;
|
|
42
70
|
}>;
|
|
43
|
-
|
|
44
|
-
ref?: Ref<
|
|
71
|
+
ExpandButton: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardExpandButtonProps> & {
|
|
72
|
+
ref?: import("preact").Ref<HTMLButtonElement> | undefined;
|
|
45
73
|
}>;
|
|
46
|
-
|
|
47
|
-
ref?: Ref<
|
|
74
|
+
OpenButton: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardOpenButtonProps> & {
|
|
75
|
+
ref?: import("preact").Ref<HTMLButtonElement> | undefined;
|
|
48
76
|
}>;
|
|
49
|
-
|
|
50
|
-
ref?: Ref<
|
|
77
|
+
CloseButton: import("preact").FunctionalComponent<import("react-dom").PropsWithoutRef<import("./props.js").CardCloseButtonProps> & {
|
|
78
|
+
ref?: import("preact").Ref<HTMLButtonElement> | undefined;
|
|
51
79
|
}>;
|
|
52
80
|
};
|
|
53
81
|
//# sourceMappingURL=main.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","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,
|
|
1
|
+
{"version":3,"file":"main.d.ts","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,mBAAmB,CAAC;AAC3B,OAAO,aAAa,CAAC;AACrB,OAAO,aAAa,CAAC;AA0BrB,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,sBAAsB,EACtB,kBAAkB,EAClB,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAkD1E,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BhB,CAAC"}
|