@mrpelz/uikit-ish 7.13.0 → 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 +7 -3
- 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 +96 -20
- 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 +61 -4
- 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,66 @@
|
|
|
1
|
+
import { type BackdropTone } from './backdrop.js';
|
|
2
|
+
/**
|
|
3
|
+
* A marker's value: a tone, a luminance (0 to 1), or a grid of luminances
|
|
4
|
+
* across the element's box (`gridSize` by `gridSize`, row by row; `null`, a
|
|
5
|
+
* cell unknown, e.g. transparent), see `backdropGridOf`.
|
|
6
|
+
*/
|
|
7
|
+
export type BackdropMarkerValue = BackdropTone | number | readonly (number | null)[];
|
|
8
|
+
/**
|
|
9
|
+
* Marks an element (`ref`'s) as a backdrop of the given tone or luminance
|
|
10
|
+
* (or a grid of them, see `backdropGridOf`), for glass over it to follow
|
|
11
|
+
* (`adaptive`, see `useBackdropTone`): e.g. a video, a canvas, a map, what
|
|
12
|
+
* the sampler can't read; what's in it too. `undefined`, unmarked: what's
|
|
13
|
+
* painted is read again.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useBackdropMarker: (ref: {
|
|
16
|
+
current: Element | null;
|
|
17
|
+
}, value: BackdropMarkerValue | undefined) => void;
|
|
18
|
+
/** A box: where something's drawn within another (px). */
|
|
19
|
+
type Box = {
|
|
20
|
+
height: number;
|
|
21
|
+
width: number;
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A grid of luminances (see `BackdropMarkerValue`) of an image as drawn
|
|
27
|
+
* across a box: `source` (anything a canvas draws: an image, a canvas, an
|
|
28
|
+
* `ImageBitmap`, e.g. an app's own preview of an image it can't read), at
|
|
29
|
+
* `box` within one `width` by `height` (all of it, without one). For
|
|
30
|
+
* `useBackdropMarker`; costly (it reads pixels): once per image and size.
|
|
31
|
+
*/
|
|
32
|
+
export declare const backdropGridOf: (source: CanvasImageSource, { box, height, width, }?: {
|
|
33
|
+
box?: Box;
|
|
34
|
+
height?: number;
|
|
35
|
+
width?: number;
|
|
36
|
+
}) => (number | null)[];
|
|
37
|
+
/** An area of an image's element: its box, in fractions (x, y, w, h). */
|
|
38
|
+
export type BackdropArea = readonly [
|
|
39
|
+
x: number,
|
|
40
|
+
y: number,
|
|
41
|
+
width: number,
|
|
42
|
+
height: number
|
|
43
|
+
];
|
|
44
|
+
/** `useImageBackdropMarker`'s options. */
|
|
45
|
+
export type ImageBackdropMarkerOptions<Area extends string> = {
|
|
46
|
+
/**
|
|
47
|
+
* Areas of it, each one's tone returned (e.g. where the app's text goes
|
|
48
|
+
* over it).
|
|
49
|
+
*/
|
|
50
|
+
areas?: Readonly<Record<Area, BackdropArea>>;
|
|
51
|
+
/** Its marker while it can't be read (loading, or not allowed). */
|
|
52
|
+
fallback?: BackdropTone | number;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Marks an image's element (`ref`'s: an `img`, or an element with a
|
|
56
|
+
* background image) as a backdrop by its pixels (see `useBackdropMarker`):
|
|
57
|
+
* a copy of the image loaded with CORS (the page's own, or another site's
|
|
58
|
+
* allowing it), sampled once, small; as drawn in the element (its
|
|
59
|
+
* `object-fit`, `background-size`), again as it resizes or its source
|
|
60
|
+
* changes. Unreadable, `fallback`. Returns its `areas`' tones.
|
|
61
|
+
*/
|
|
62
|
+
export declare const useImageBackdropMarker: <Area extends string = never>(ref: {
|
|
63
|
+
current: Element | null;
|
|
64
|
+
}, { areas, fallback }?: ImageBackdropMarkerOptions<Area>) => Partial<Record<Area, BackdropTone>>;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=marker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker.d.ts","sourceRoot":"","sources":["../../../src/components/glass/marker.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EAMlB,MAAM,eAAe,CAAC;AAQvB;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC7B,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;AAoBrD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK;IAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,EAChC,OAAO,mBAAmB,GAAG,SAAS,KACrC,IAQF,CAAC;AAQF,0DAA0D;AAC1D,KAAK,GAAG,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAkCnE;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,iBAAiB,EACzB,0BAIG;IAAE,GAAG,CAAC,EAAE,GAAG,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,KACrD,CAAC,MAAM,GAAG,IAAI,CAAC,EAyCjB,CAAC;AAwEF,yEAAyE;AACzE,MAAM,MAAM,YAAY,GAAG,SAAS;IAClC,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;CACf,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,0BAA0B,CAAC,IAAI,SAAS,MAAM,IAAI;IAC5D;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IAC7C,mEAAmE;IACnE,QAAQ,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;CAClC,CAAC;AA0BF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,IAAI,SAAS,MAAM,GAAG,KAAK,EAChE,KAAK;IAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,EAChC,sBAAqB,0BAA0B,CAAC,IAAI,CAAM,KACzD,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CA6EpC,CAAC"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { gridSize, luminanceOf, markerAttribute, onResample, toneOf, } from './backdrop.js';
|
|
3
|
+
// (A tone's luminance: well past its threshold, see backdrop.ts.)
|
|
4
|
+
const toneLuminances = { bright: 0.8, dim: 0.05 };
|
|
5
|
+
/** A marker's value as its attribute (see backdrop.ts). */
|
|
6
|
+
const encode = (value) => {
|
|
7
|
+
if (typeof value === 'string')
|
|
8
|
+
return String(toneLuminances[value]);
|
|
9
|
+
if (typeof value === 'number')
|
|
10
|
+
return String(value);
|
|
11
|
+
return `g${value
|
|
12
|
+
.map((luminance) => luminance === null
|
|
13
|
+
? '__'
|
|
14
|
+
: Math.round(Math.min(Math.max(luminance, 0), 1) * 254)
|
|
15
|
+
.toString(16)
|
|
16
|
+
.padStart(2, '0'))
|
|
17
|
+
.join('')}`;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Marks an element (`ref`'s) as a backdrop of the given tone or luminance
|
|
21
|
+
* (or a grid of them, see `backdropGridOf`), for glass over it to follow
|
|
22
|
+
* (`adaptive`, see `useBackdropTone`): e.g. a video, a canvas, a map, what
|
|
23
|
+
* the sampler can't read; what's in it too. `undefined`, unmarked: what's
|
|
24
|
+
* painted is read again.
|
|
25
|
+
*/
|
|
26
|
+
export const useBackdropMarker = (ref, value) => {
|
|
27
|
+
const encoded = value === undefined ? undefined : encode(value);
|
|
28
|
+
useLayoutEffect(() => {
|
|
29
|
+
const { current: element } = ref;
|
|
30
|
+
if (!element || encoded === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
element.setAttribute(markerAttribute, encoded);
|
|
33
|
+
return () => element.removeAttribute(markerAttribute);
|
|
34
|
+
}, [encoded, ref]);
|
|
35
|
+
};
|
|
36
|
+
/** A position's offset (`50%`, `12px`) in `room` px to spare. */
|
|
37
|
+
const offset = (token, room) => token.endsWith('%')
|
|
38
|
+
? (Number.parseFloat(token) / 100) * room
|
|
39
|
+
: Number.parseFloat(token) || 0;
|
|
40
|
+
/**
|
|
41
|
+
* Where an image (`width` by `height`) is drawn in a box `into` (its
|
|
42
|
+
* element's), by a fit (`object-fit`, or `background-size`'s `cover`,
|
|
43
|
+
* `contain`) and a position (`object-position`, `background-position`:
|
|
44
|
+
* percentages and px).
|
|
45
|
+
*/
|
|
46
|
+
const fitted = ({ height, width }, into, fit, position) => {
|
|
47
|
+
const cover = Math.max(into.width / width, into.height / height);
|
|
48
|
+
const contain = Math.min(into.width / width, into.height / height);
|
|
49
|
+
const scales = {
|
|
50
|
+
contain,
|
|
51
|
+
cover,
|
|
52
|
+
none: 1,
|
|
53
|
+
'scale-down': Math.min(1, contain),
|
|
54
|
+
};
|
|
55
|
+
const scale = scales[fit];
|
|
56
|
+
const drawnWidth = scale === undefined ? into.width : width * scale;
|
|
57
|
+
const drawnHeight = scale === undefined ? into.height : height * scale;
|
|
58
|
+
const [xToken = '50%', yToken = '50%'] = position.split(/\s+/u);
|
|
59
|
+
return {
|
|
60
|
+
height: drawnHeight,
|
|
61
|
+
width: drawnWidth,
|
|
62
|
+
x: offset(xToken, into.width - drawnWidth),
|
|
63
|
+
y: offset(yToken, into.height - drawnHeight),
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* A grid of luminances (see `BackdropMarkerValue`) of an image as drawn
|
|
68
|
+
* across a box: `source` (anything a canvas draws: an image, a canvas, an
|
|
69
|
+
* `ImageBitmap`, e.g. an app's own preview of an image it can't read), at
|
|
70
|
+
* `box` within one `width` by `height` (all of it, without one). For
|
|
71
|
+
* `useBackdropMarker`; costly (it reads pixels): once per image and size.
|
|
72
|
+
*/
|
|
73
|
+
export const backdropGridOf = (source, { box, height = 1, width = 1, } = {}) => {
|
|
74
|
+
const canvas = document.createElement('canvas');
|
|
75
|
+
canvas.width = gridSize;
|
|
76
|
+
canvas.height = gridSize;
|
|
77
|
+
const context = canvas.getContext('2d', { willReadFrequently: true });
|
|
78
|
+
if (!context)
|
|
79
|
+
return [];
|
|
80
|
+
context.imageSmoothingQuality = 'high';
|
|
81
|
+
const { x, y, width: boxWidth, height: boxHeight, } = box ?? {
|
|
82
|
+
height,
|
|
83
|
+
width,
|
|
84
|
+
x: 0,
|
|
85
|
+
y: 0,
|
|
86
|
+
};
|
|
87
|
+
context.drawImage(source, (x / width) * gridSize, (y / height) * gridSize, (boxWidth / width) * gridSize, (boxHeight / height) * gridSize);
|
|
88
|
+
const { data } = context.getImageData(0, 0, gridSize, gridSize);
|
|
89
|
+
const cells = [];
|
|
90
|
+
for (let index = 0; index < data.length; index += 4) {
|
|
91
|
+
const alpha = (data[index + 3] ?? 0) / 255;
|
|
92
|
+
cells.push(alpha < 0.3
|
|
93
|
+
? null
|
|
94
|
+
: luminanceOf([
|
|
95
|
+
data[index] ?? 0,
|
|
96
|
+
data[index + 1] ?? 0,
|
|
97
|
+
data[index + 2] ?? 0,
|
|
98
|
+
alpha,
|
|
99
|
+
]));
|
|
100
|
+
}
|
|
101
|
+
return cells;
|
|
102
|
+
};
|
|
103
|
+
/** How large a loaded image is kept (its longer side, px), see `load`. */
|
|
104
|
+
const keptSize = 64;
|
|
105
|
+
/** Loaded images, small (see `load`), by their URL. */
|
|
106
|
+
const loaded = new Map();
|
|
107
|
+
/**
|
|
108
|
+
* An image loaded for its pixels: a copy of its own, requested with CORS
|
|
109
|
+
* (the page's own, as is; another site's, only if it allows it), kept
|
|
110
|
+
* small; once per URL. Undefined, unreadable.
|
|
111
|
+
*/
|
|
112
|
+
const load = (url) => {
|
|
113
|
+
let pending = loaded.get(url);
|
|
114
|
+
if (!pending) {
|
|
115
|
+
pending = (async () => {
|
|
116
|
+
const image = new Image();
|
|
117
|
+
image.crossOrigin = 'anonymous';
|
|
118
|
+
image.src = url;
|
|
119
|
+
try {
|
|
120
|
+
await image.decode();
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
const scale = keptSize / Math.max(image.naturalWidth, image.naturalHeight);
|
|
126
|
+
const canvas = document.createElement('canvas');
|
|
127
|
+
canvas.width = Math.max(1, Math.round(image.naturalWidth * scale));
|
|
128
|
+
canvas.height = Math.max(1, Math.round(image.naturalHeight * scale));
|
|
129
|
+
const context = canvas.getContext('2d');
|
|
130
|
+
if (!context)
|
|
131
|
+
return undefined;
|
|
132
|
+
context.imageSmoothingQuality = 'high';
|
|
133
|
+
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
134
|
+
try {
|
|
135
|
+
// (Read once: a tainted copy (no CORS) throws, unreadable.)
|
|
136
|
+
context.getImageData(0, 0, 1, 1);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
return canvas;
|
|
142
|
+
})();
|
|
143
|
+
loaded.set(url, pending);
|
|
144
|
+
}
|
|
145
|
+
return pending;
|
|
146
|
+
};
|
|
147
|
+
const urlPattern = /url\(["']?(?<url>[^"')]+)["']?\)/u;
|
|
148
|
+
/** An element's image: an `img`'s source as shown, or its background's. */
|
|
149
|
+
const imageOf = (element) => {
|
|
150
|
+
if (element instanceof HTMLImageElement) {
|
|
151
|
+
return {
|
|
152
|
+
fit: getComputedStyle(element).objectFit,
|
|
153
|
+
position: getComputedStyle(element).objectPosition,
|
|
154
|
+
url: element.currentSrc || element.src,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const style = getComputedStyle(element);
|
|
158
|
+
const url = urlPattern.exec(style.backgroundImage)?.groups?.url;
|
|
159
|
+
const size = style.backgroundSize;
|
|
160
|
+
return {
|
|
161
|
+
// (Other sizes: across its box, roughly.)
|
|
162
|
+
fit: size === 'cover' || size === 'contain' ? size : 'fill',
|
|
163
|
+
position: style.backgroundPosition,
|
|
164
|
+
url,
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
/** The first grid cell from a fraction across it. */
|
|
168
|
+
const from = (fraction) => Math.min(Math.floor(fraction * gridSize), gridSize - 1);
|
|
169
|
+
/** The grid cell up to a fraction across it (past it). */
|
|
170
|
+
const to = (fraction) => Math.max(Math.ceil(fraction * gridSize), 1);
|
|
171
|
+
/** The average of a grid's cells in an area (see `BackdropArea`). */
|
|
172
|
+
const areaLuminance = (cells, [x, y, width, height]) => {
|
|
173
|
+
const values = [];
|
|
174
|
+
for (let row = from(y); row < to(y + height); row += 1) {
|
|
175
|
+
for (let column = from(x); column < to(x + width); column += 1) {
|
|
176
|
+
const value = cells[row * gridSize + column];
|
|
177
|
+
if (value !== null && value !== undefined)
|
|
178
|
+
values.push(value);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return values.length === 0
|
|
182
|
+
? undefined
|
|
183
|
+
: values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Marks an image's element (`ref`'s: an `img`, or an element with a
|
|
187
|
+
* background image) as a backdrop by its pixels (see `useBackdropMarker`):
|
|
188
|
+
* a copy of the image loaded with CORS (the page's own, or another site's
|
|
189
|
+
* allowing it), sampled once, small; as drawn in the element (its
|
|
190
|
+
* `object-fit`, `background-size`), again as it resizes or its source
|
|
191
|
+
* changes. Unreadable, `fallback`. Returns its `areas`' tones.
|
|
192
|
+
*/
|
|
193
|
+
export const useImageBackdropMarker = (ref, { areas, fallback } = {}) => {
|
|
194
|
+
const [cells, setCells] = useState(undefined);
|
|
195
|
+
useLayoutEffect(() => {
|
|
196
|
+
const { current: element } = ref;
|
|
197
|
+
if (!element)
|
|
198
|
+
return undefined;
|
|
199
|
+
let isCurrent = true;
|
|
200
|
+
let source;
|
|
201
|
+
let url;
|
|
202
|
+
// (Drawn as it's shown in its box, from its small copy.)
|
|
203
|
+
const draw = () => {
|
|
204
|
+
if (!source)
|
|
205
|
+
return;
|
|
206
|
+
const { height, width } = element.getBoundingClientRect();
|
|
207
|
+
if (width <= 0 || height <= 0)
|
|
208
|
+
return;
|
|
209
|
+
const { fit, position } = imageOf(element);
|
|
210
|
+
setCells(backdropGridOf(source, {
|
|
211
|
+
box: fitted(source, { height, width }, fit, position),
|
|
212
|
+
height,
|
|
213
|
+
width,
|
|
214
|
+
}));
|
|
215
|
+
};
|
|
216
|
+
const read = () => {
|
|
217
|
+
const { url: next } = imageOf(element);
|
|
218
|
+
if (next === url)
|
|
219
|
+
return;
|
|
220
|
+
url = next;
|
|
221
|
+
source = undefined;
|
|
222
|
+
setCells(undefined);
|
|
223
|
+
if (!next)
|
|
224
|
+
return;
|
|
225
|
+
load(next)
|
|
226
|
+
.then((canvas) => {
|
|
227
|
+
if (!isCurrent || url !== next)
|
|
228
|
+
return;
|
|
229
|
+
source = canvas;
|
|
230
|
+
draw();
|
|
231
|
+
})
|
|
232
|
+
.catch(() => undefined);
|
|
233
|
+
};
|
|
234
|
+
read();
|
|
235
|
+
const resizeObserver = new ResizeObserver(draw);
|
|
236
|
+
resizeObserver.observe(element);
|
|
237
|
+
// (Its source changed: an `img`'s `src`, `srcset` chosen anew as it
|
|
238
|
+
// loads, a background's.)
|
|
239
|
+
const mutationObserver = new MutationObserver(read);
|
|
240
|
+
mutationObserver.observe(element, {
|
|
241
|
+
attributeFilter: ['src', 'srcset', 'style', 'class'],
|
|
242
|
+
});
|
|
243
|
+
element.addEventListener('load', read);
|
|
244
|
+
// (Asked to (`resampleBackdrops`): its source read again, and drawn.)
|
|
245
|
+
const unsubscribe = onResample(() => {
|
|
246
|
+
read();
|
|
247
|
+
draw();
|
|
248
|
+
});
|
|
249
|
+
return () => {
|
|
250
|
+
isCurrent = false;
|
|
251
|
+
unsubscribe();
|
|
252
|
+
resizeObserver.disconnect();
|
|
253
|
+
mutationObserver.disconnect();
|
|
254
|
+
element.removeEventListener('load', read);
|
|
255
|
+
};
|
|
256
|
+
}, [ref]);
|
|
257
|
+
useBackdropMarker(ref, cells ?? fallback);
|
|
258
|
+
const tones = {};
|
|
259
|
+
if (cells && areas) {
|
|
260
|
+
for (const [name, area] of Object.entries(areas)) {
|
|
261
|
+
const luminance = areaLuminance(cells, area);
|
|
262
|
+
if (luminance !== undefined)
|
|
263
|
+
tones[name] = toneOf(luminance);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return tones;
|
|
267
|
+
};
|
|
268
|
+
//# sourceMappingURL=marker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker.js","sourceRoot":"","sources":["../../../src/components/glass/marker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAEL,QAAQ,EACR,WAAW,EACX,eAAe,EACf,UAAU,EACV,MAAM,GACP,MAAM,eAAe,CAAC;AAgBvB,kEAAkE;AAClE,MAAM,cAAc,GAAiC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AAEhF,2DAA2D;AAC3D,MAAM,MAAM,GAAG,CAAC,KAA0B,EAAU,EAAE;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,IA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AAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,KAAK,CAAC;YAClB,WAAW,EAAE,CAAC;YACd,cAAc,CAAC,UAAU,EAAE,CAAC;YAC5B,gBAAgB,CAAC,UAAU,EAAE,CAAC;YAC9B,OAAO,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5C,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEV,iBAAiB,CAAC,GAAG,EAAE,KAAK,IAAI,QAAQ,CAAC,CAAC;IAE1C,MAAM,KAAK,GAAwC,EAAE,CAAC;IACtD,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;QACnB,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAG5C,EAAE,CAAC;YACJ,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAC7C,IAAI,SAAS,KAAK,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* (`background-bright`, `background-dim`: floating over it).
|
|
2
|
+
* The tone of glass: for content behind it that's bright (light glass) or
|
|
3
|
+
* dim (dark glass).
|
|
5
4
|
*/
|
|
6
|
-
export type GlassContext = '
|
|
5
|
+
export type GlassContext = 'bright' | 'dim';
|
|
7
6
|
/**
|
|
8
|
-
* A glass context, or `adaptive`:
|
|
9
|
-
*
|
|
10
|
-
* resizes; small glass, see `useGlassContext`).
|
|
7
|
+
* A glass context, or `adaptive`: by the tone of what's behind the glass
|
|
8
|
+
* (sampled as it scrolls or resizes, see `useBackdropTone`).
|
|
11
9
|
*/
|
|
12
10
|
export type GlassContextValue = GlassContext | 'adaptive';
|
|
11
|
+
/** A glass surface's props (a sidebar's, a sheet's, a card's, a menu's). */
|
|
12
|
+
export type GlassSurfaceProps = {
|
|
13
|
+
/**
|
|
14
|
+
* How bright the content behind it is: bright, light glass; dim, dark
|
|
15
|
+
* glass (`adaptive`: by what's behind it, held a moment before it flips,
|
|
16
|
+
* see `useBackdropTone`). Its content follows, in the color scheme of its
|
|
17
|
+
* glass (light, dark), as do menus and popovers opened from it.
|
|
18
|
+
* @default the color scheme's
|
|
19
|
+
*/
|
|
20
|
+
context?: GlassContextValue;
|
|
21
|
+
};
|
|
13
22
|
export type GlassBackgroundProps = {
|
|
14
23
|
/**
|
|
15
24
|
* `bar` (e.g. a tab bar): backdrop blur. `button` (a glass button): a halo
|
|
@@ -19,4 +28,21 @@ export type GlassBackgroundProps = {
|
|
|
19
28
|
/** Tint layers instead of the fill (tinted glass). */
|
|
20
29
|
tinted?: boolean;
|
|
21
30
|
};
|
|
31
|
+
/** A scroll container's glass (see `GlassModeProps`). */
|
|
32
|
+
export type GlassMode = 'auto' | 'flat' | 'live';
|
|
33
|
+
/** A scroll container's `glass` prop (Page, content parts). */
|
|
34
|
+
export type GlassModeProps = {
|
|
35
|
+
/**
|
|
36
|
+
* The glass in it (e.g. glass buttons, text fields): `live`, blurring
|
|
37
|
+
* what's behind (backdrop filters, isolated, blended); `flat`, opaque,
|
|
38
|
+
* drawn over its background (`--uikit-glass-backdrop`) as the live glass
|
|
39
|
+
* would look, without backdrop filters, isolation or blend modes; `auto`,
|
|
40
|
+
* flat while it can scroll (its content larger than it, or bouncing
|
|
41
|
+
* anyway: `alwaysBounce`), else live. Flat for glass in content that
|
|
42
|
+
* scrolls: on iOS, live glass there ends the scroll's glides (see the
|
|
43
|
+
* docs' iOS Quirks). A live one within a flat one is live again.
|
|
44
|
+
* @default 'auto'
|
|
45
|
+
*/
|
|
46
|
+
glass?: GlassMode;
|
|
47
|
+
};
|
|
22
48
|
//# sourceMappingURL=props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/components/glass/props.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/components/glass/props.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE1D,4EAA4E;AAC5E,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACxB,sDAAsD;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,yDAAyD;AACzD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEjD,+DAA+D;AAC/D,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC"}
|