@rvx/ui 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/common/events.d.ts +72 -0
- package/dist/common/events.js +58 -0
- package/dist/common/events.js.map +1 -0
- package/dist/common/parsers.d.ts +88 -0
- package/dist/common/parsers.js +62 -0
- package/dist/common/parsers.js.map +1 -0
- package/dist/common/theme-test.d.ts +7 -0
- package/dist/common/theme-test.js +14 -0
- package/dist/common/theme-test.js.map +1 -0
- package/dist/common/theme.d.ts +144 -0
- package/dist/common/theme.js +2 -0
- package/dist/common/theme.js.map +1 -0
- package/dist/common/trim.d.ts +12 -0
- package/dist/common/trim.js +16 -0
- package/dist/common/trim.js.map +1 -0
- package/dist/common/types.d.ts +13 -0
- package/dist/common/types.js +10 -0
- package/dist/common/types.js.map +1 -0
- package/dist/common/writing-mode.d.ts +82 -0
- package/dist/common/writing-mode.js +61 -0
- package/dist/common/writing-mode.js.map +1 -0
- package/dist/components/button.d.ts +42 -0
- package/dist/components/button.js +26 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/checkbox.d.ts +9 -0
- package/dist/components/checkbox.js +32 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/collapse-test.d.ts +8 -0
- package/dist/components/collapse-test.js +15 -0
- package/dist/components/collapse-test.js.map +1 -0
- package/dist/components/collapse.d.ts +13 -0
- package/dist/components/collapse.js +44 -0
- package/dist/components/collapse.js.map +1 -0
- package/dist/components/column.d.ts +12 -0
- package/dist/components/column.js +12 -0
- package/dist/components/column.js.map +1 -0
- package/dist/components/control-group.d.ts +7 -0
- package/dist/components/control-group.js +11 -0
- package/dist/components/control-group.js.map +1 -0
- package/dist/components/dialog.d.ts +33 -0
- package/dist/components/dialog.js +67 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown-input.d.ts +27 -0
- package/dist/components/dropdown-input.js +31 -0
- package/dist/components/dropdown-input.js.map +1 -0
- package/dist/components/dropdown.d.ts +123 -0
- package/dist/components/dropdown.js +176 -0
- package/dist/components/dropdown.js.map +1 -0
- package/dist/components/flex-space.d.ts +4 -0
- package/dist/components/flex-space.js +10 -0
- package/dist/components/flex-space.js.map +1 -0
- package/dist/components/heading.d.ts +9 -0
- package/dist/components/heading.js +14 -0
- package/dist/components/heading.js.map +1 -0
- package/dist/components/label.d.ts +14 -0
- package/dist/components/label.js +15 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/layer.d.ts +81 -0
- package/dist/components/layer.js +164 -0
- package/dist/components/layer.js.map +1 -0
- package/dist/components/link.d.ts +57 -0
- package/dist/components/link.js +26 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/page.d.ts +9 -0
- package/dist/components/page.js +17 -0
- package/dist/components/page.js.map +1 -0
- package/dist/components/popout.d.ts +134 -0
- package/dist/components/popout.js +259 -0
- package/dist/components/popout.js.map +1 -0
- package/dist/components/popover.d.ts +139 -0
- package/dist/components/popover.js +101 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/radio-buttons.d.ts +17 -0
- package/dist/components/radio-buttons.js +26 -0
- package/dist/components/radio-buttons.js.map +1 -0
- package/dist/components/row.d.ts +10 -0
- package/dist/components/row.js +23 -0
- package/dist/components/row.js.map +1 -0
- package/dist/components/scroll-view.d.ts +6 -0
- package/dist/components/scroll-view.js +72 -0
- package/dist/components/scroll-view.js.map +1 -0
- package/dist/components/text-input.d.ts +53 -0
- package/dist/components/text-input.js +35 -0
- package/dist/components/text-input.js.map +1 -0
- package/dist/components/text.d.ts +7 -0
- package/dist/components/text.js +11 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/validation.d.ts +109 -0
- package/dist/components/validation.js +151 -0
- package/dist/components/validation.js.map +1 -0
- package/dist/components/value.d.ts +7 -0
- package/dist/components/value.js +11 -0
- package/dist/components/value.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.js +3 -0
- package/dist/test.js.map +1 -0
- package/dist/theme.module.css +679 -0
- package/dist/theme.module.css.map +1 -0
- package/package.json +29 -0
- package/src/common/events.tsx +130 -0
- package/src/common/parsers.tsx +167 -0
- package/src/common/theme-test.tsx +20 -0
- package/src/common/theme.tsx +165 -0
- package/src/common/trim.tsx +30 -0
- package/src/common/types.tsx +23 -0
- package/src/common/writing-mode.tsx +150 -0
- package/src/components/button.tsx +94 -0
- package/src/components/checkbox.tsx +64 -0
- package/src/components/collapse-test.tsx +23 -0
- package/src/components/collapse.tsx +75 -0
- package/src/components/column.tsx +28 -0
- package/src/components/control-group.tsx +22 -0
- package/src/components/dialog.tsx +137 -0
- package/src/components/dropdown-input.tsx +82 -0
- package/src/components/dropdown.tsx +352 -0
- package/src/components/flex-space.tsx +15 -0
- package/src/components/heading.tsx +23 -0
- package/src/components/label.tsx +37 -0
- package/src/components/layer.tsx +299 -0
- package/src/components/link.tsx +118 -0
- package/src/components/page.tsx +36 -0
- package/src/components/popout.tsx +461 -0
- package/src/components/popover.tsx +292 -0
- package/src/components/radio-buttons.tsx +81 -0
- package/src/components/row.tsx +37 -0
- package/src/components/scroll-view.tsx +97 -0
- package/src/components/text-input.tsx +117 -0
- package/src/components/text.tsx +22 -0
- package/src/components/validation.tsx +272 -0
- package/src/components/value.tsx +22 -0
- package/src/index.tsx +29 -0
- package/src/test.tsx +2 -0
- package/src/theme/base.scss +69 -0
- package/src/theme/common.scss +51 -0
- package/src/theme/components/button.scss +116 -0
- package/src/theme/components/checkbox.scss +25 -0
- package/src/theme/components/collapse.scss +64 -0
- package/src/theme/components/column.scss +28 -0
- package/src/theme/components/control-group.scss +14 -0
- package/src/theme/components/dialog.scss +44 -0
- package/src/theme/components/dropdown.scss +50 -0
- package/src/theme/components/flex-space.scss +6 -0
- package/src/theme/components/heading.scss +39 -0
- package/src/theme/components/label.scss +24 -0
- package/src/theme/components/link.scss +25 -0
- package/src/theme/components/page.scss +22 -0
- package/src/theme/components/popover.scss +58 -0
- package/src/theme/components/radio-buttons.scss +31 -0
- package/src/theme/components/row.scss +17 -0
- package/src/theme/components/scroll-view.scss +51 -0
- package/src/theme/components/text-input.scss +45 -0
- package/src/theme/components/text.scss +12 -0
- package/src/theme/components/validation.scss +15 -0
- package/src/theme/components/value.scss +4 -0
- package/src/theme/theme.scss +22 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export const UP = 0;
|
|
2
|
+
export const RIGHT = 1;
|
|
3
|
+
export const DOWN = 2;
|
|
4
|
+
export const LEFT = 3;
|
|
5
|
+
export const INSET = ["top", "right", "bottom", "left"];
|
|
6
|
+
export function flip(dir) {
|
|
7
|
+
return ((dir + 2) & 3);
|
|
8
|
+
}
|
|
9
|
+
export function axisEquals(a, b) {
|
|
10
|
+
return (a & 1) === (b & 1);
|
|
11
|
+
}
|
|
12
|
+
export function getWindowSize(dir) {
|
|
13
|
+
return (dir & 1) ? window.innerWidth : window.innerHeight;
|
|
14
|
+
}
|
|
15
|
+
export function getSize(rect, dir) {
|
|
16
|
+
return (dir & 1) ? rect.width : rect.height;
|
|
17
|
+
}
|
|
18
|
+
export function getXY(rect, dir) {
|
|
19
|
+
return (dir & 1) ? rect.x : rect.y;
|
|
20
|
+
}
|
|
21
|
+
export function getBlockStart(writingMode) {
|
|
22
|
+
switch (writingMode) {
|
|
23
|
+
case "horizontal-tb":
|
|
24
|
+
return UP;
|
|
25
|
+
case "vertical-rl":
|
|
26
|
+
case "sideways-rl":
|
|
27
|
+
return RIGHT;
|
|
28
|
+
case "vertical-lr":
|
|
29
|
+
case "sideways-lr":
|
|
30
|
+
return LEFT;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function getInlineStart(writingMode, scriptDir) {
|
|
34
|
+
let dir;
|
|
35
|
+
switch (writingMode) {
|
|
36
|
+
case "horizontal-tb":
|
|
37
|
+
dir = LEFT;
|
|
38
|
+
break;
|
|
39
|
+
case "vertical-rl":
|
|
40
|
+
case "vertical-lr":
|
|
41
|
+
case "sideways-rl":
|
|
42
|
+
dir = UP;
|
|
43
|
+
break;
|
|
44
|
+
case "sideways-lr":
|
|
45
|
+
dir = DOWN;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
if (scriptDir !== "ltr") {
|
|
49
|
+
dir = flip(dir);
|
|
50
|
+
}
|
|
51
|
+
return dir;
|
|
52
|
+
}
|
|
53
|
+
export function getWindowSpaceAround(rect, dir) {
|
|
54
|
+
switch (dir) {
|
|
55
|
+
case UP: return rect.y;
|
|
56
|
+
case RIGHT: return window.innerWidth - rect.right;
|
|
57
|
+
case DOWN: return window.innerHeight - rect.bottom;
|
|
58
|
+
case LEFT: return rect.x;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=writing-mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writing-mode.js","sourceRoot":"","sources":["../../src/common/writing-mode.tsx"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEpB,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC;AAEvB,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;AAEtB,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;AAUtB,MAAM,CAAC,MAAM,KAAK,GAA2D,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAKhH,MAAM,UAAU,IAAI,CAAC,GAAc;IAClC,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAc,CAAC;AACrC,CAAC;AAYD,MAAM,UAAU,UAAU,CAAC,CAAY,EAAE,CAAY;IACpD,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5B,CAAC;AAWD,MAAM,UAAU,aAAa,CAAC,GAAc;IAC3C,OAAO,CAAC,GAA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AU,oBAAoB,CAAC,IAAa,EAAE,GAAc;IACjE,QAAQ,GAAG,EAAE,CAAC;QACb,KAAK,EAAE,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;QACvB,KAAK,KAAK,CAAC,CAAC,OAAO,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC;QAClD,KAAK,IAAI,CAAC,CAAC,OAAO,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;QACnD,KAAK,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;IAC1B,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ClassValue, Expression, StyleValue } from "rvx";
|
|
2
|
+
import { Action } from "../common/events.js";
|
|
3
|
+
import { Validator } from "./validation.js";
|
|
4
|
+
export type ButtonType = "button" | "submit" | "reset" | "menu";
|
|
5
|
+
export type ButtonVariant = "default" | "primary" | "success" | "danger" | "warning" | "input";
|
|
6
|
+
export declare function Button(props: {
|
|
7
|
+
/**
|
|
8
|
+
* The button type.
|
|
9
|
+
*
|
|
10
|
+
* @default "button"
|
|
11
|
+
*/
|
|
12
|
+
type?: Expression<ButtonType | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* The theme variant.
|
|
15
|
+
*
|
|
16
|
+
* @default "default"
|
|
17
|
+
*/
|
|
18
|
+
variant?: Expression<ButtonVariant | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Set when the button is disabled.
|
|
21
|
+
*
|
|
22
|
+
* The button is automatically disabled when there are any pending tasks.
|
|
23
|
+
*/
|
|
24
|
+
disabled?: Expression<boolean | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* The action to run when the button is clicked.
|
|
27
|
+
*/
|
|
28
|
+
action?: Action;
|
|
29
|
+
class?: ClassValue;
|
|
30
|
+
style?: StyleValue;
|
|
31
|
+
id?: Expression<string | undefined>;
|
|
32
|
+
autofocus?: Expression<boolean | undefined>;
|
|
33
|
+
title?: Expression<string | undefined>;
|
|
34
|
+
role?: Expression<string | undefined>;
|
|
35
|
+
"aria-label"?: Expression<string | undefined>;
|
|
36
|
+
"aria-labelledby"?: Expression<string | undefined>;
|
|
37
|
+
"aria-expanded"?: Expression<boolean | undefined>;
|
|
38
|
+
"aria-haspopup"?: Expression<string | undefined>;
|
|
39
|
+
"aria-controls"?: Expression<string | undefined>;
|
|
40
|
+
validator?: Validator;
|
|
41
|
+
children?: unknown;
|
|
42
|
+
}): unknown;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "rvx/jsx-runtime";
|
|
2
|
+
import { extract, get, optionalString } from "rvx";
|
|
3
|
+
import { isPending } from "rvx/async";
|
|
4
|
+
import { handleActionEvent, keyFor } from "../common/events.js";
|
|
5
|
+
import { THEME } from "../common/theme.js";
|
|
6
|
+
export function Button(props) {
|
|
7
|
+
const theme = extract(THEME);
|
|
8
|
+
const disabled = () => isPending() || get(props.disabled);
|
|
9
|
+
function action(event) {
|
|
10
|
+
if (disabled() || !props.action) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
handleActionEvent(event, props.action);
|
|
14
|
+
}
|
|
15
|
+
return _jsx("button", { type: () => get(props.type) ?? "button", disabled: disabled, class: [
|
|
16
|
+
theme?.button,
|
|
17
|
+
() => theme?.[`button_${get(props.variant) ?? "default"}`],
|
|
18
|
+
props.class,
|
|
19
|
+
], style: props.style, id: props.id, title: props.title, role: props.role, "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], "aria-expanded": optionalString(props["aria-expanded"]), "aria-haspopup": props["aria-haspopup"], "aria-controls": props["aria-controls"], "aria-invalid": props.validator ? optionalString(props.validator.invalid) : undefined, "aria-errormessage": props.validator ? props.validator.errorMessageIds : undefined, autofocus: props.autofocus, "on:click": action, "on:keydown": event => {
|
|
20
|
+
const key = keyFor(event);
|
|
21
|
+
if (key === "enter" || key === "space") {
|
|
22
|
+
action(event);
|
|
23
|
+
}
|
|
24
|
+
}, children: props.children });
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/components/button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0B,OAAO,EAAE,GAAG,EAAE,cAAc,EAAc,MAAM,KAAK,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAU,iBAAiB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAM3C,MAAM,UAAU,MAAM,CAAC,KAyCtB;IACA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAE1D,SAAS,MAAM,CAAC,KAAY;QAC3B,IAAI,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACjC,OAAO;QACR,CAAC;QACD,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,iBACN,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,QAAQ,EACvC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE;YACN,KAAK,EAAE,MAAM;YACb,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,UAAU,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,SAAS,EAAE,CAAC;YAC1D,KAAK,CAAC,KAAK;SACX,EACD,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,IAAI,EAAE,KAAK,CAAC,IAAI,gBACJ,KAAK,CAAC,YAAY,CAAC,qBACd,KAAK,CAAC,iBAAiB,CAAC,mBAC1B,cAAc,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,mBACtC,KAAK,CAAC,eAAe,CAAC,mBACtB,KAAK,CAAC,eAAe,CAAC,kBACvB,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,uBAChE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,EAChF,SAAS,EAAE,KAAK,CAAC,SAAS,cAEhB,MAAM,gBACJ,KAAK,CAAC,EAAE;YACnB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;gBACxC,MAAM,CAAC,KAAK,CAAC,CAAC;YACf,CAAC;QACF,CAAC,YAEA,KAAK,CAAC,QAAQ,GACP,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ClassValue, Expression, StyleValue } from "rvx";
|
|
2
|
+
export declare function Checkbox(props: {
|
|
3
|
+
checked?: Expression<boolean | undefined>;
|
|
4
|
+
disabled?: Expression<boolean | undefined>;
|
|
5
|
+
class?: ClassValue;
|
|
6
|
+
style?: StyleValue;
|
|
7
|
+
autofocus?: Expression<boolean | undefined>;
|
|
8
|
+
children?: unknown;
|
|
9
|
+
}): unknown;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "rvx/jsx-runtime";
|
|
2
|
+
import { extract, get, optionalString, Signal, string, uniqueId, watch } from "rvx";
|
|
3
|
+
import { isPending } from "rvx/async";
|
|
4
|
+
import { THEME } from "../common/theme.js";
|
|
5
|
+
import { Text } from "./text.js";
|
|
6
|
+
import { validatorFor } from "./validation.js";
|
|
7
|
+
export function Checkbox(props) {
|
|
8
|
+
const id = uniqueId();
|
|
9
|
+
const theme = extract(THEME);
|
|
10
|
+
const disabled = props.checked instanceof Signal
|
|
11
|
+
? () => isPending() || get(props.disabled)
|
|
12
|
+
: () => true;
|
|
13
|
+
const validator = props.checked instanceof Signal ? validatorFor(props.checked) : undefined;
|
|
14
|
+
const input = _jsx("input", { id: id, type: "checkbox", class: theme?.checkbox_input, "on:input": () => {
|
|
15
|
+
if (props.checked instanceof Signal) {
|
|
16
|
+
props.checked.value = input.checked;
|
|
17
|
+
}
|
|
18
|
+
}, "aria-readonly": string(!(props.checked instanceof Signal)), "aria-invalid": validator ? optionalString(validator.invalid) : undefined, "aria-errormessage": validator ? validator.errorMessageIds : undefined, autofocus: props.autofocus, disabled: disabled });
|
|
19
|
+
watch(props.checked, checked => {
|
|
20
|
+
if (checked === undefined) {
|
|
21
|
+
input.indeterminate = true;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
input.checked = checked;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return _jsxs("label", { for: id, class: [
|
|
28
|
+
theme?.checkbox_label,
|
|
29
|
+
props.class,
|
|
30
|
+
], style: props.style, children: [input, _jsx(Text, { class: theme?.checkbox_content, children: props.children })] });
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../src/components/checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0B,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAc,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AACxH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,W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CAAC,aAAa,GAAG,IAAI,CAAC;QAC5B,CAAC;aAAM,CAAC;YACP,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,iBACN,GAAG,EAAE,EAAE,EACP,KAAK,EAAE;YACN,KAAK,EAAE,cAAc;YACrB,KAAK,CAAC,KAAK;SACX,EACD,KAAK,EAAE,KAAK,CAAC,KAAK,aAEjB,KAAK,EACN,KAAC,IAAI,IAAC,KAAK,EAAE,KAAK,EAAE,gBAAgB,YAClC,KAAK,CAAC,QAAQ,GACT,IACA,CAAC;AACV,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { themeClass } from "../test.js";
|
|
2
|
+
function assertCollapse(collapse) {
|
|
3
|
+
if (!collapse.matches(`.${themeClass("collapse")}`)) {
|
|
4
|
+
throw new Error("collapse must be a collapse root element.");
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export function getCollapseContent(collapse) {
|
|
8
|
+
assertCollapse(collapse);
|
|
9
|
+
return collapse.querySelector(`.${themeClass("collapse_content")}`);
|
|
10
|
+
}
|
|
11
|
+
export function isCollapseVisible(collapse) {
|
|
12
|
+
assertCollapse(collapse);
|
|
13
|
+
return !collapse.hasAttribute("inert");
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=collapse-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapse-test.js","sourceRoot":"","sources":["../../src/components/collapse-test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,SAAS,cAAc,CAAC,QAAiB;IACxC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC9D,CAAC;AACF,CAAC;AAKD,MAAM,UAAU,kBAAkB,CAAC,QAAiB;IACnD,cAAc,CAAC,QAAQ,CAAC,CAAC;IACzB,OAAO,QAAQ,CAAC,aAAa,CAAiB,IAAI,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAE,CAAC;AACtF,CAAC;AAKD,MAAM,UAAU,iBAAiB,CAAC,QAAiB;IAClD,cAAc,CAAC,QAAQ,CAAC,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ClassValue, Event, Expression, StyleValue } from "rvx";
|
|
2
|
+
import { AriaLive, AriaRelevant } from "../common/types.js";
|
|
3
|
+
export declare function Collapse(props: {
|
|
4
|
+
visible?: Expression<boolean | undefined>;
|
|
5
|
+
alert?: Event<[]>;
|
|
6
|
+
children?: unknown;
|
|
7
|
+
class?: ClassValue;
|
|
8
|
+
style?: StyleValue;
|
|
9
|
+
id?: Expression<string | undefined>;
|
|
10
|
+
"aria-live"?: Expression<AriaLive | undefined>;
|
|
11
|
+
"aria-relevant"?: Expression<AriaRelevant | undefined>;
|
|
12
|
+
"aria-atomic"?: Expression<boolean | undefined>;
|
|
13
|
+
}): unknown;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "rvx/jsx-runtime";
|
|
2
|
+
import { extract, get, map, optionalString, sig, teardown } from "rvx";
|
|
3
|
+
import { THEME } from "../common/theme.js";
|
|
4
|
+
export function Collapse(props) {
|
|
5
|
+
const theme = extract(THEME);
|
|
6
|
+
const visible = map(props.visible, v => v ?? false);
|
|
7
|
+
const alert = sig(false);
|
|
8
|
+
const size = sig(undefined);
|
|
9
|
+
const content = _jsx("div", { class: theme?.collapse_content, children: props.children });
|
|
10
|
+
const observer = new ResizeObserver(entries => {
|
|
11
|
+
const entry = entries[entries.length - 1];
|
|
12
|
+
const boxSize = entry?.borderBoxSize[entry.borderBoxSize.length - 1];
|
|
13
|
+
if (boxSize) {
|
|
14
|
+
size.value = boxSize.blockSize;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
observer.observe(content);
|
|
18
|
+
teardown(() => {
|
|
19
|
+
observer.disconnect();
|
|
20
|
+
});
|
|
21
|
+
props.alert?.(() => {
|
|
22
|
+
if (get(visible)) {
|
|
23
|
+
alert.value = false;
|
|
24
|
+
void root.offsetWidth;
|
|
25
|
+
alert.value = true;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const root = _jsx("div", { inert: map(visible, v => !v), class: [
|
|
29
|
+
theme?.collapse,
|
|
30
|
+
() => size.value === undefined ? undefined : theme?.collapse_sized,
|
|
31
|
+
() => alert.value ? theme?.collapse_alert : undefined,
|
|
32
|
+
map(visible, v => v ? theme?.collapse_visible : undefined),
|
|
33
|
+
props.class,
|
|
34
|
+
], style: [
|
|
35
|
+
{
|
|
36
|
+
"--collapse-size": () => size.value === undefined ? undefined : `${size.value}px`,
|
|
37
|
+
},
|
|
38
|
+
props.style,
|
|
39
|
+
], id: props.id, "aria-live": map(props["aria-live"], v => v ?? "polite"), "aria-relevant": props["aria-relevant"], "aria-atomic": optionalString(props["aria-atomic"]), children: theme?.collapse_view
|
|
40
|
+
? _jsx("div", { class: theme.collapse_view, children: content })
|
|
41
|
+
: content });
|
|
42
|
+
return root;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=collapse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapse.js","sourceRoot":"","sources":["../../src/components/collapse.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAiC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,EAAc,QAAQ,EAAE,MAAM,KAAK,CAAC;AAElH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C,MAAM,UAAU,QAAQ,CAAC,KAUxB;IACA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,MAA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AG,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,cAAc;YAClE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS;YACrD,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;YAC1D,KAAK,CAAC,KAAK;SACX,EACD,KAAK,EAAE;YACN;gBACC,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI;aACjF;YACD,KAAK,CAAC,KAAK;SACX,EACD,EAAE,EAAE,KAAK,CAAC,EAAE,eACD,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,QAAQ,CAAC,mBACvC,KAAK,CAAC,eAAe,CAAC,iBACxB,cAAc,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,YAEhD,KAAK,EAAE,aAAa;YACpB,CAAC,CAAC,cAAK,KAAK,EAAE,KAAK,CAAC,aAAa,YAC/B,OAAO,GACH;YACN,CAAC,CAAC,OAAO,GACa,CAAC;IACzB,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ClassValue, Expression, StyleValue } from "rvx";
|
|
2
|
+
import { SizeContext } from "../common/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A flex column with automatic spacing between it's children.
|
|
5
|
+
*/
|
|
6
|
+
export declare function Column(props: {
|
|
7
|
+
size?: Expression<SizeContext | undefined>;
|
|
8
|
+
class?: ClassValue;
|
|
9
|
+
style?: StyleValue;
|
|
10
|
+
id?: Expression<string | undefined>;
|
|
11
|
+
children?: unknown;
|
|
12
|
+
}): unknown;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "rvx/jsx-runtime";
|
|
2
|
+
import { extract, map } from "rvx";
|
|
3
|
+
import { THEME } from "../common/theme.js";
|
|
4
|
+
export function Column(props) {
|
|
5
|
+
const theme = extract(THEME);
|
|
6
|
+
return _jsx("div", { class: [
|
|
7
|
+
theme?.column,
|
|
8
|
+
map(props.size, size => theme?.[`column_${size ?? "content"}`]),
|
|
9
|
+
props.class,
|
|
10
|
+
], style: props.style, id: props.id, children: props.children });
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=column.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column.js","sourceRoot":"","sources":["../../src/components/column.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0B,OAAO,EAAE,GAAG,EAAc,MAAM,KAAK,CAAC;AAEvE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAM3C,MAAM,UAAU,MAAM,CAAC,KAMtB;IACA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,cACN,KAAK,EAAE;YACN,KAAK,EAAE,MAAM;YACb,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,UAAU,IAAI,IAAI,SAAS,EAAE,CAAC,CAAC;YAC/D,KAAK,CAAC,KAAK;SACX,EACD,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,EAAE,EAAE,KAAK,CAAC,EAAE,YAEX,KAAK,CAAC,QAAQ,GACV,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "rvx/jsx-runtime";
|
|
2
|
+
import { extract } from "rvx";
|
|
3
|
+
import { THEME } from "../common/theme.js";
|
|
4
|
+
export function ControlGroup(props) {
|
|
5
|
+
const theme = extract(THEME);
|
|
6
|
+
return _jsx("div", { class: [
|
|
7
|
+
theme?.control_group,
|
|
8
|
+
props.class,
|
|
9
|
+
], style: props.style, id: props.id, children: props.children });
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=control-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-group.js","sourceRoot":"","sources":["../../src/components/control-group.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0B,OAAO,EAAc,MAAM,KAAK,CAAC;AAElE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,UAAU,YAAY,CAAC,KAK5B;IACA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,cACN,KAAK,EAAE;YACN,KAAK,EAAE,aAAa;YACpB,KAAK,CAAC,KAAK;SACX,EACD,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,EAAE,EAAE,KAAK,CAAC,EAAE,YAEX,KAAK,CAAC,QAAQ,GACV,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ClassValue, Expression, StyleValue } from "rvx";
|
|
2
|
+
export declare class DialogAbortError extends Error {
|
|
3
|
+
}
|
|
4
|
+
export interface Dialog<T> {
|
|
5
|
+
resolve: (value: T) => void;
|
|
6
|
+
reject: (cause?: unknown) => void;
|
|
7
|
+
}
|
|
8
|
+
export type DialogInit<T> = (dialog: Dialog<T>) => unknown;
|
|
9
|
+
export interface DialogOptions {
|
|
10
|
+
cancellable?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function showDialog<T = void>(init: DialogInit<T>, options?: DialogOptions): Promise<T>;
|
|
13
|
+
export type DialogRole = "dialog" | "alertdialog";
|
|
14
|
+
export declare function DialogBody(props: {
|
|
15
|
+
class?: ClassValue;
|
|
16
|
+
style?: StyleValue;
|
|
17
|
+
children?: unknown;
|
|
18
|
+
role?: Expression<DialogRole | undefined>;
|
|
19
|
+
title?: unknown;
|
|
20
|
+
description?: unknown;
|
|
21
|
+
inlineSize?: Expression<string | undefined>;
|
|
22
|
+
maxInlineSize?: Expression<string | undefined>;
|
|
23
|
+
blockSize?: Expression<string | undefined>;
|
|
24
|
+
maxBlockSize?: Expression<string | undefined>;
|
|
25
|
+
"aria-labelledby"?: Expression<string | undefined>;
|
|
26
|
+
"aria-describedby"?: Expression<string | undefined>;
|
|
27
|
+
}): unknown;
|
|
28
|
+
export declare function DialogFooter(props: {
|
|
29
|
+
class?: ClassValue;
|
|
30
|
+
style?: StyleValue;
|
|
31
|
+
links?: unknown;
|
|
32
|
+
children?: unknown;
|
|
33
|
+
}): unknown;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "rvx/jsx-runtime";
|
|
2
|
+
import { captureSelf, extract, map, mount, uniqueId } from "rvx";
|
|
3
|
+
import { TASKS, Tasks } from "rvx/async";
|
|
4
|
+
import { FlexSpace, Heading, Row, Text, THEME } from "../index.js";
|
|
5
|
+
import { LAYER, Layer } from "./layer.js";
|
|
6
|
+
export class DialogAbortError extends Error {
|
|
7
|
+
}
|
|
8
|
+
export function showDialog(init, options) {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
captureSelf(dispose => {
|
|
11
|
+
mount(document.body, _jsx(Layer, { modal: true, children: ctx => {
|
|
12
|
+
ctx.set(TASKS, new Tasks());
|
|
13
|
+
const dialog = {
|
|
14
|
+
resolve(value) {
|
|
15
|
+
dispose();
|
|
16
|
+
resolve(value);
|
|
17
|
+
},
|
|
18
|
+
reject(reason) {
|
|
19
|
+
dispose();
|
|
20
|
+
reject(reason);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
if (options?.cancellable ?? true) {
|
|
24
|
+
extract(LAYER)?.useHotkey("escape", () => {
|
|
25
|
+
dialog.reject(new DialogAbortError());
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return init(dialog);
|
|
29
|
+
} }));
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function DialogBody(props) {
|
|
34
|
+
const theme = extract(THEME);
|
|
35
|
+
let titleId;
|
|
36
|
+
let descriptionId;
|
|
37
|
+
const head = [];
|
|
38
|
+
if (props.title !== undefined) {
|
|
39
|
+
titleId = uniqueId();
|
|
40
|
+
head.push(_jsx(Heading, { level: "2", id: titleId, children: props.title }));
|
|
41
|
+
}
|
|
42
|
+
if (props.description !== undefined) {
|
|
43
|
+
descriptionId = uniqueId();
|
|
44
|
+
head.push(_jsx(Text, { id: descriptionId, children: props.description }));
|
|
45
|
+
}
|
|
46
|
+
return _jsx("div", { class: [
|
|
47
|
+
theme?.dialog_container,
|
|
48
|
+
props.class,
|
|
49
|
+
], style: props.style, role: map(props.role, v => v ?? "dialog"), "aria-labelledby": map(props["aria-labelledby"], v => v ?? titleId), "aria-describedby": map(props["aria-describedby"], v => v ?? descriptionId), children: _jsxs("div", { class: [
|
|
50
|
+
theme?.column,
|
|
51
|
+
theme?.column_content,
|
|
52
|
+
theme?.dialog_body,
|
|
53
|
+
], style: {
|
|
54
|
+
"inline-size": props.inlineSize,
|
|
55
|
+
"max-inline-size": props.maxInlineSize,
|
|
56
|
+
"block-size": props.blockSize,
|
|
57
|
+
"max-block-size": props.maxBlockSize,
|
|
58
|
+
}, children: [head, props.children] }) });
|
|
59
|
+
}
|
|
60
|
+
export function DialogFooter(props) {
|
|
61
|
+
const theme = extract(THEME);
|
|
62
|
+
return _jsxs(Row, { size: "control", class: [
|
|
63
|
+
theme?.dialog_footer,
|
|
64
|
+
props.class,
|
|
65
|
+
], style: props.style, align: "center", children: [_jsx(Row, { size: "control", children: props.links }), _jsx(FlexSpace, {}), _jsx(Row, { size: "control", children: props.children })] });
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../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KAAK,EAAE;gBACN,aAAa,EAAE,KAAK,CAAC,UAAU;gBAC/B,iBAAiB,EAAE,KAAK,CAAC,aAAa;gBACtC,YAAY,EAAE,KAAK,CAAC,SAAS;gBAC7B,gBAAgB,EAAE,KAAK,CAAC,YAAY;aACpC,aAEA,IAAI,EACJ,KAAK,CAAC,QAAQ,IACV,GACD,CAAC;AACR,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAK5B;IACA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAC,GAAG,IACV,IAAI,EAAC,SAAS,EACd,KAAK,EAAE;YACN,KAAK,EAAE,aAAa;YACpB,KAAK,CAAC,KAAK;SACX,EACD,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,KAAK,EAAC,QAAQ,aAEd,KAAC,GAAG,IAAC,IAAI,EAAC,SAAS,YACjB,KAAK,CAAC,KAAK,GACP,EACN,KAAC,SAAS,KAAG,EACb,KAAC,GAAG,IAAC,IAAI,EAAC,SAAS,YACjB,KAAK,CAAC,QAAQ,GACV,IACD,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ClassValue, Expression, StyleValue } from "rvx";
|
|
2
|
+
import { ButtonVariant } from "./button.js";
|
|
3
|
+
import { PopoutAlignment, PopoutPlacement } from "./popout.js";
|
|
4
|
+
export interface DropdownValue<T> {
|
|
5
|
+
value: T;
|
|
6
|
+
label: unknown;
|
|
7
|
+
}
|
|
8
|
+
export declare function DropdownInput<T>(props: {
|
|
9
|
+
children?: unknown;
|
|
10
|
+
value: Expression<T>;
|
|
11
|
+
values: Expression<DropdownValue<T>[]>;
|
|
12
|
+
variant?: ButtonVariant;
|
|
13
|
+
disabled?: Expression<boolean | undefined>;
|
|
14
|
+
class?: ClassValue;
|
|
15
|
+
style?: StyleValue;
|
|
16
|
+
id?: Expression<string | undefined>;
|
|
17
|
+
autofocus?: Expression<boolean | undefined>;
|
|
18
|
+
title?: Expression<string | undefined>;
|
|
19
|
+
"aria-label"?: Expression<string | undefined>;
|
|
20
|
+
"aria-labelledby"?: Expression<string | undefined>;
|
|
21
|
+
dropdownId?: string;
|
|
22
|
+
dropdownClass?: ClassValue;
|
|
23
|
+
dropdownStyle?: StyleValue;
|
|
24
|
+
placement?: Expression<PopoutPlacement | undefined>;
|
|
25
|
+
alignment?: Expression<PopoutAlignment | undefined>;
|
|
26
|
+
foreignEvents?: string[];
|
|
27
|
+
}): unknown;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "rvx/jsx-runtime";
|
|
2
|
+
import { get, map, Signal } from "rvx";
|
|
3
|
+
import { Button } from "./button.js";
|
|
4
|
+
import { Dropdown } from "./dropdown.js";
|
|
5
|
+
import { validatorFor } from "./validation.js";
|
|
6
|
+
export function DropdownInput(props) {
|
|
7
|
+
const items = new WeakMap();
|
|
8
|
+
return _jsx(Dropdown, { anchor: a => _jsx(Button, { ...a, variant: map(props.variant, v => v ?? "input"), disabled: props.value instanceof Signal ? props.disabled : true, class: props.class, style: props.style, id: props.id, autofocus: props.autofocus, title: props.title, role: "combobox", "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], validator: props.value instanceof Signal ? validatorFor(props.value) : undefined, children: props.children ?? (() => {
|
|
9
|
+
const value = get(props.value);
|
|
10
|
+
return get(props.values).find(v => v.value === value)?.label;
|
|
11
|
+
}) }), items: () => get(props.values).map(value => {
|
|
12
|
+
let item = items.get(value);
|
|
13
|
+
if (item === undefined) {
|
|
14
|
+
item = {
|
|
15
|
+
label: value.label,
|
|
16
|
+
selected: () => value.value === get(props.value),
|
|
17
|
+
action: () => {
|
|
18
|
+
if (props.value instanceof Signal) {
|
|
19
|
+
props.value.value = value.value;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
items.set(value, item);
|
|
27
|
+
}
|
|
28
|
+
return item;
|
|
29
|
+
}), id: props.dropdownId, style: props.dropdownStyle, class: props.dropdownClass, placement: props.placement, alignment: props.alignment, foreignEvents: props.foreignEvents });
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=dropdown-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown-input.js","sourceRoot":"","sources":["../../src/components/dropdown-input.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0B,GAAG,EAAE,GAAG,EAAE,MAAM,EAAc,MAAM,KAAK,CAAC;AAE3E,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAgB,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAO/C,MAAM,UAAU,aAAa,CAAI,KAsBhC;IACA,MAAM,KAAK,GAAG,IAAI,OAAO,EAAkC,CAAC;IAC5D,OAAO,KAAC,QAAQ,IACf,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAC,MAAM,OACf,CAAC,EACL,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,EAC9C,QAAQ,EAAE,KAAK,CAAC,KAAK,YAAY,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAC/D,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,IAAI,EAAC,UAAU,gBACH,KAAK,CAAC,YAAY,CAAC,qBACd,KAAK,CAAC,iBAAiB,CAAC,EACzC,SAAS,EAAE,KAAK,CAAC,KAAK,YAAY,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,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AAS,EAC1B,aAAa,EAAE,KAAK,CAAC,aAAa,GACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ClassValue, Expression, StyleValue } from "rvx";
|
|
2
|
+
import { Action } from "../common/events.js";
|
|
3
|
+
import { Popout, PopoutAlignment, PopoutPlacement } from "./popout.js";
|
|
4
|
+
export interface DropdownItem {
|
|
5
|
+
/**
|
|
6
|
+
* The item label.
|
|
7
|
+
*/
|
|
8
|
+
label: unknown;
|
|
9
|
+
/**
|
|
10
|
+
* The action to run when this item is selected.
|
|
11
|
+
*/
|
|
12
|
+
action?: Action;
|
|
13
|
+
/**
|
|
14
|
+
* Optional child items.
|
|
15
|
+
*
|
|
16
|
+
* + If an action is also specified and runs when the item is selected, this is only accessible by hovering or pressing `ArrowRight`.
|
|
17
|
+
* + This expression is memoized and only evaluated while the dropdown is open.
|
|
18
|
+
*/
|
|
19
|
+
children?: Expression<DropdownItem[]>;
|
|
20
|
+
/**
|
|
21
|
+
* True if this item is currently selected.
|
|
22
|
+
*/
|
|
23
|
+
selected?: Expression<boolean>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a dropdown that is initially hidden.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createDropdown(props: {
|
|
29
|
+
/**
|
|
30
|
+
* The items contained in this dropdown.
|
|
31
|
+
*
|
|
32
|
+
* This expression is memoized and only evaluated while the dropdown is open.
|
|
33
|
+
*/
|
|
34
|
+
items: Expression<DropdownItem[]>;
|
|
35
|
+
/**
|
|
36
|
+
* True to indicate, that this is a nested dropdown.
|
|
37
|
+
*
|
|
38
|
+
* Currently, this allows the dropdown to be closed by pressing "ArrowRight".
|
|
39
|
+
*/
|
|
40
|
+
expansion?: boolean;
|
|
41
|
+
/** An id for the dropdown root. */
|
|
42
|
+
id?: Expression<string | undefined>;
|
|
43
|
+
/** Styles for the dropdown root. */
|
|
44
|
+
style?: StyleValue;
|
|
45
|
+
/** Classes for the dropdown root. */
|
|
46
|
+
class?: ClassValue;
|
|
47
|
+
/**
|
|
48
|
+
* Defines the direction in which the dropdown is placed in relation to the anchor.
|
|
49
|
+
*
|
|
50
|
+
* This expression is only evaluated when calculating the dropdown placement.
|
|
51
|
+
*
|
|
52
|
+
* See {@link PopoutPlacement}
|
|
53
|
+
*
|
|
54
|
+
* @default "block-end"
|
|
55
|
+
*/
|
|
56
|
+
placement?: Expression<PopoutPlacement | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* Defines which side of the anchor and popover are aligned orthogonally to the placement axis.
|
|
59
|
+
*
|
|
60
|
+
* This expression is only evaluated when calculating the popover placement.
|
|
61
|
+
*
|
|
62
|
+
* See {@link PopoutAlignment}
|
|
63
|
+
*
|
|
64
|
+
* @default "start"
|
|
65
|
+
*/
|
|
66
|
+
alignment?: Expression<PopoutAlignment | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* An array of event names that cause the dropdown to hide automatically when dispatched outside of the current layer stack or the anchor.
|
|
69
|
+
*
|
|
70
|
+
* @default ["resize", "scroll", "mousedown", "touchstart", "focusin", "rvx-ui:passive-action"]
|
|
71
|
+
*/
|
|
72
|
+
foreignEvents?: string[];
|
|
73
|
+
}): Popout;
|
|
74
|
+
export interface DropdownAnchorProps {
|
|
75
|
+
action: Action;
|
|
76
|
+
"aria-haspopup": Expression<string | undefined>;
|
|
77
|
+
"aria-controls": Expression<string | undefined>;
|
|
78
|
+
"aria-expanded": Expression<boolean>;
|
|
79
|
+
}
|
|
80
|
+
export declare function Dropdown(props: {
|
|
81
|
+
/**
|
|
82
|
+
* A function to immediately render the anchor.
|
|
83
|
+
*/
|
|
84
|
+
anchor: (props: DropdownAnchorProps) => unknown;
|
|
85
|
+
/**
|
|
86
|
+
* The items contained in this dropdown.
|
|
87
|
+
*
|
|
88
|
+
* This expression is memoized and only evaluated while the dropdown is open.
|
|
89
|
+
*/
|
|
90
|
+
items: Expression<DropdownItem[]>;
|
|
91
|
+
/** An id for the dropdown root. */
|
|
92
|
+
id?: Expression<string | undefined>;
|
|
93
|
+
/** Styles for the dropdown root. */
|
|
94
|
+
style?: StyleValue;
|
|
95
|
+
/** Classes for the dropdown root. */
|
|
96
|
+
class?: ClassValue;
|
|
97
|
+
/**
|
|
98
|
+
* Defines the direction in which the dropdown is placed in relation to the anchor.
|
|
99
|
+
*
|
|
100
|
+
* This expression is only evaluated when calculating the dropdown placement.
|
|
101
|
+
*
|
|
102
|
+
* See {@link PopoutPlacement}
|
|
103
|
+
*
|
|
104
|
+
* @default "block-end"
|
|
105
|
+
*/
|
|
106
|
+
placement?: Expression<PopoutPlacement | undefined>;
|
|
107
|
+
/**
|
|
108
|
+
* Defines which side of the anchor and popover are aligned orthogonally to the placement axis.
|
|
109
|
+
*
|
|
110
|
+
* This expression is only evaluated when calculating the popover placement.
|
|
111
|
+
*
|
|
112
|
+
* See {@link PopoutAlignment}
|
|
113
|
+
*
|
|
114
|
+
* @default "start"
|
|
115
|
+
*/
|
|
116
|
+
alignment?: Expression<PopoutAlignment | undefined>;
|
|
117
|
+
/**
|
|
118
|
+
* An array of event names that cause the dropdown to hide automatically when dispatched outside of the current layer stack or the anchor.
|
|
119
|
+
*
|
|
120
|
+
* @default ["resize", "scroll", "mousedown", "touchstart", "focusin", "rvx-ui:passive-action"]
|
|
121
|
+
*/
|
|
122
|
+
foreignEvents?: string[];
|
|
123
|
+
}): unknown;
|