@fibrae/semi-foundation 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anchor/foundation.d.ts +1 -4
- package/dist/anchor/foundation.js +21 -22
- package/dist/audio-player/foundation.d.ts +10 -13
- package/dist/audio-player/foundation.js +19 -20
- package/dist/auto-complete/foundation.d.ts +12 -14
- package/dist/auto-complete/foundation.js +51 -52
- package/dist/avatar/foundation.d.ts +5 -6
- package/dist/avatar/foundation.js +16 -16
- package/dist/avatar/variables.scss +0 -1
- package/dist/backtop/foundation.d.ts +2 -5
- package/dist/backtop/foundation.js +7 -8
- package/dist/banner/foundation.d.ts +1 -1
- package/dist/banner/foundation.js +4 -4
- package/dist/base/auto-close-foundation.d.ts +8 -9
- package/dist/base/auto-close-foundation.js +15 -15
- package/dist/base/foundation.d.ts +4 -4
- package/dist/base/foundation.js +12 -11
- package/dist/base/list-store.d.ts +0 -1
- package/dist/breadcrumb/foundation.d.ts +5 -5
- package/dist/breadcrumb/foundation.js +9 -10
- package/dist/breadcrumb/item-foundation.d.ts +3 -3
- package/dist/breadcrumb/item-foundation.js +6 -6
- package/dist/calendar/event-util.d.ts +0 -10
- package/dist/calendar/event-util.js +1 -11
- package/dist/calendar/foundation.d.ts +1 -6
- package/dist/calendar/foundation.js +5 -9
- package/dist/calendar/month-foundation.d.ts +2 -3
- package/dist/calendar/month-foundation.js +6 -7
- package/dist/carousel/foundation.d.ts +17 -19
- package/dist/carousel/foundation.js +51 -51
- package/dist/cascader/foundation.d.ts +36 -32
- package/dist/cascader/foundation.js +145 -132
- package/dist/cascader/util.d.ts +1 -8
- package/dist/cascader/util.js +1 -8
- package/dist/checkbox/checkbox-foundation.d.ts +3 -7
- package/dist/checkbox/checkbox-foundation.js +15 -17
- package/dist/checkbox/checkbox-group-foundation.d.ts +2 -3
- package/dist/checkbox/checkbox-group-foundation.js +8 -8
- package/dist/code-highlight/index.d.ts +1 -2
- package/dist/code-highlight/index.js +3 -3
- package/dist/collapse/foundation.d.ts +2 -2
- package/dist/collapse/foundation.js +7 -7
- package/dist/collapsible/foundation.d.ts +3 -3
- package/dist/collapsible/foundation.js +8 -8
- package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
- package/dist/color-picker/alpha-slider-foundation.js +10 -10
- package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
- package/dist/color-picker/color-choose-area-foundation.js +14 -14
- package/dist/color-picker/color-picker.scss +0 -2
- package/dist/color-picker/color-slider-foundation.d.ts +2 -4
- package/dist/color-picker/color-slider-foundation.js +10 -10
- package/dist/color-picker/data-part-foundation.d.ts +5 -5
- package/dist/color-picker/data-part-foundation.js +11 -11
- package/dist/color-picker/foundation.d.ts +4 -4
- package/dist/color-picker/foundation.js +10 -10
- package/dist/color-picker/interface.d.ts +0 -1
- package/dist/config-provider/breakpoint-observer.d.ts +3 -3
- package/dist/config-provider/breakpoint-observer.js +6 -6
- package/dist/config-provider/responsive-types.d.ts +0 -16
- package/dist/cropper/foundation.d.ts +15 -16
- package/dist/cropper/foundation.js +26 -24
- package/dist/date-picker/_utils/get-default-picker-date.d.ts +0 -3
- package/dist/date-picker/_utils/get-default-picker-date.js +0 -3
- package/dist/date-picker/_utils/get-inset-input-format-token.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-format-token.js +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.js +0 -2
- package/dist/date-picker/_utils/parser.d.ts +0 -3
- package/dist/date-picker/_utils/parser.js +0 -7
- package/dist/date-picker/_utils/picker-type.d.ts +1 -3
- package/dist/date-picker/_utils/picker-type.js +0 -2
- package/dist/date-picker/_utils/to-callback-args.d.ts +0 -1
- package/dist/date-picker/_utils/to-callback-args.js +0 -1
- package/dist/date-picker/date-picker.scss +0 -3
- package/dist/date-picker/foundation.d.ts +39 -58
- package/dist/date-picker/foundation.js +126 -153
- package/dist/date-picker/input-foundation.d.ts +10 -16
- package/dist/date-picker/input-foundation.js +28 -30
- package/dist/date-picker/month-foundation.d.ts +0 -3
- package/dist/date-picker/month-foundation.js +0 -2
- package/dist/date-picker/months-grid-foundation.d.ts +17 -26
- package/dist/date-picker/months-grid-foundation.js +65 -75
- package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
- package/dist/date-picker/year-and-month-foundation.js +11 -11
- package/dist/drag-move/foundation.d.ts +2 -3
- package/dist/drag-move/foundation.js +15 -13
- package/dist/dropdown/foundation.d.ts +8 -7
- package/dist/dropdown/foundation.js +32 -28
- package/dist/dropdown/menu-foundation.d.ts +1 -2
- package/dist/dropdown/menu-foundation.js +11 -11
- package/dist/feedback/foundation.d.ts +9 -10
- package/dist/feedback/foundation.js +33 -33
- package/dist/feedback/variables.scss +1 -5
- package/dist/float-button/float-button.css +0 -1
- package/dist/float-button/float-button.scss +0 -2
- package/dist/form/form-api-proxy.d.ts +8 -7
- package/dist/form/form-api-proxy.js +25 -25
- package/dist/form/form.scss +0 -12
- package/dist/form/foundation.d.ts +5 -5
- package/dist/form/foundation.js +60 -76
- package/dist/form/interface.d.ts +2 -15
- package/dist/form/utils.d.ts +0 -8
- package/dist/form/utils.js +0 -7
- package/dist/form/variables.scss +1 -4
- package/dist/grid/variables.scss +0 -10
- package/dist/highlight/foundation.d.ts +0 -2
- package/dist/highlight/foundation.js +1 -3
- package/dist/hot-keys/foundation.d.ts +2 -3
- package/dist/hot-keys/foundation.js +5 -5
- package/dist/image/image-foundation.d.ts +4 -6
- package/dist/image/image-foundation.js +10 -10
- package/dist/image/preview-footer-foundation.d.ts +3 -4
- package/dist/image/preview-footer-foundation.js +10 -10
- package/dist/image/preview-foundation.d.ts +0 -3
- package/dist/image/preview-foundation.js +7 -6
- package/dist/image/preview-image-foundation.d.ts +6 -9
- package/dist/image/preview-image-foundation.js +14 -14
- package/dist/image/preview-inner-foundation.d.ts +9 -10
- package/dist/image/preview-inner-foundation.js +38 -38
- package/dist/input/foundation.d.ts +10 -11
- package/dist/input/foundation.js +47 -49
- package/dist/input/text-entry-foundation.d.ts +3 -5
- package/dist/input/text-entry-foundation.js +14 -15
- package/dist/input/textarea-foundation.d.ts +7 -8
- package/dist/input/textarea-foundation.js +36 -36
- package/dist/input-number/caret.d.ts +0 -1
- package/dist/input-number/caret.js +0 -1
- package/dist/input-number/foundation.d.ts +16 -19
- package/dist/input-number/foundation.js +54 -58
- package/dist/json-viewer/foundation.d.ts +8 -10
- package/dist/json-viewer/foundation.js +23 -24
- package/dist/locale/interface.d.ts +0 -3
- package/dist/lottie/foundation.d.ts +1 -1
- package/dist/lottie/foundation.js +4 -4
- package/dist/markdown-render/foundation.d.ts +2 -7
- package/dist/markdown-render/foundation.js +5 -9
- package/dist/modal/modal-content-foundation.d.ts +7 -7
- package/dist/modal/modal-content-foundation.js +20 -20
- package/dist/modal/modal-foundation.d.ts +6 -6
- package/dist/modal/modal-foundation.js +24 -24
- package/dist/navigation/foundation.d.ts +1 -8
- package/dist/navigation/foundation.js +14 -20
- package/dist/navigation/item-foundation.d.ts +1 -1
- package/dist/navigation/item-foundation.js +8 -8
- package/dist/navigation/sub-nav-foundation.d.ts +3 -4
- package/dist/navigation/sub-nav-foundation.js +17 -17
- package/dist/notification/notification-list-foundation.d.ts +7 -8
- package/dist/notification/notification-list-foundation.js +12 -13
- package/dist/notification/variables.scss +0 -1
- package/dist/overflow-list/foundation.d.ts +4 -6
- package/dist/overflow-list/foundation.js +18 -19
- package/dist/pagination/foundation.d.ts +8 -10
- package/dist/pagination/foundation.js +28 -28
- package/dist/pincode/foundation.d.ts +6 -9
- package/dist/pincode/foundation.js +23 -26
- package/dist/popconfirm/popconfirm-foundation.d.ts +7 -9
- package/dist/popconfirm/popconfirm-foundation.js +26 -26
- package/dist/progress/generates.d.ts +1 -4
- package/dist/progress/generates.js +1 -4
- package/dist/progress/utils.d.ts +1 -1
- package/dist/progress/utils.js +1 -1
- package/dist/radio/radio-foundation.d.ts +5 -9
- package/dist/radio/radio-foundation.js +15 -16
- package/dist/radio/radio-group-foundation.d.ts +2 -3
- package/dist/radio/radio-group-foundation.js +9 -9
- package/dist/rating/foundation.d.ts +10 -15
- package/dist/rating/foundation.js +35 -38
- package/dist/resizable/group/index.d.ts +6 -10
- package/dist/resizable/group/index.js +40 -44
- package/dist/resizable/resizable.scss +0 -1
- package/dist/resizable/single/index.d.ts +3 -7
- package/dist/resizable/single/index.js +10 -13
- package/dist/scroll-list/item-foundation.d.ts +7 -9
- package/dist/scroll-list/item-foundation.js +35 -36
- package/dist/scroll-list/variables.scss +1 -6
- package/dist/select/foundation.d.ts +42 -57
- package/dist/select/foundation.js +214 -279
- package/dist/select/option-foundation.d.ts +23 -28
- package/dist/select/option-foundation.js +10 -19
- package/dist/select/variables.scss +1 -8
- package/dist/side-sheet/side-sheet-foundation.d.ts +7 -12
- package/dist/side-sheet/side-sheet-foundation.js +23 -27
- package/dist/side-sheet/variables.scss +1 -3
- package/dist/slider/foundation.d.ts +17 -28
- package/dist/slider/foundation.js +47 -59
- package/dist/slider/variables.scss +1 -5
- package/dist/sortable/accessibility.d.ts +1 -1
- package/dist/sortable/accessibility.js +2 -2
- package/dist/spin/foundation.d.ts +2 -4
- package/dist/spin/foundation.js +6 -7
- package/dist/spin/variables.scss +1 -3
- package/dist/steps/utils.d.ts +1 -1
- package/dist/switch/foundation.d.ts +2 -3
- package/dist/switch/foundation.js +7 -7
- package/dist/switch/switch.scss +1 -1
- package/dist/switch/variables.scss +1 -5
- package/dist/table/foundation.d.ts +24 -33
- package/dist/table/foundation.js +144 -108
- package/dist/table/table.scss +0 -1
- package/dist/table/utils.d.ts +2 -10
- package/dist/table/utils.js +0 -13
- package/dist/table/variables.scss +1 -5
- package/dist/tabs/foundation.d.ts +5 -14
- package/dist/tabs/foundation.js +17 -21
- package/dist/tabs/tabs.scss +1 -1
- package/dist/tag/focus.js +0 -1
- package/dist/tag-input/foundation.d.ts +11 -13
- package/dist/tag-input/foundation.js +52 -53
- package/dist/tag-input/tag-input.scss +0 -1
- package/dist/tag-input/utils/tag-focus.d.ts +0 -1
- package/dist/tag-input/utils/tag-focus.js +0 -1
- package/dist/time-picker/combox-foundation.d.ts +3 -11
- package/dist/time-picker/combox-foundation.js +3 -10
- package/dist/time-picker/foundation.d.ts +13 -23
- package/dist/time-picker/foundation.js +39 -48
- package/dist/time-picker/input-foundation.d.ts +4 -4
- package/dist/time-picker/input-foundation.js +13 -13
- package/dist/time-picker/utils/index.d.ts +0 -11
- package/dist/time-picker/utils/index.js +0 -11
- package/dist/toast/toast-list-foundation.d.ts +7 -7
- package/dist/toast/toast-list-foundation.js +14 -14
- package/dist/tooltip/adjust-position.d.ts +1 -2
- package/dist/tooltip/constants.d.ts +0 -3
- package/dist/tooltip/constants.js +0 -3
- package/dist/tooltip/foundation.d.ts +9 -12
- package/dist/tooltip/foundation.js +67 -63
- package/dist/tooltip/position.scss +0 -1
- package/dist/transfer/foundation.d.ts +22 -13
- package/dist/transfer/foundation.js +38 -24
- package/dist/tree/foundation.d.ts +14 -16
- package/dist/tree/foundation.js +61 -62
- package/dist/tree/shared.d.ts +2 -4
- package/dist/tree/shared.js +0 -2
- package/dist/tree/tree-util.d.ts +0 -5
- package/dist/tree/tree-util.js +0 -5
- package/dist/tree-select/foundation.d.ts +26 -22
- package/dist/tree-select/foundation.js +91 -86
- package/dist/typography/ellipsis.d.ts +5 -7
- package/dist/typography/ellipsis.js +8 -10
- package/dist/typography/format-numeral.d.ts +1 -1
- package/dist/typography/format-numeral.js +2 -2
- package/dist/typography/typography.scss +0 -1
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +17 -23
- package/dist/upload/foundation.js +93 -103
- package/dist/upload/utils.d.ts +3 -8
- package/dist/upload/utils.js +6 -11
- package/dist/user-guide/foundation.d.ts +3 -5
- package/dist/user-guide/foundation.js +19 -19
- package/dist/utils/a11y.d.ts +2 -6
- package/dist/utils/a11y.js +1 -4
- package/dist/utils/announcer.d.ts +2 -2
- package/dist/utils/announcer.js +4 -4
- package/dist/utils/array.d.ts +0 -6
- package/dist/utils/array.js +0 -6
- package/dist/utils/date-fns-extra.js +1 -5
- package/dist/utils/dom.d.ts +0 -1
- package/dist/utils/dom.js +0 -1
- package/dist/utils/escape-html.js +0 -3
- package/dist/utils/field-sizing.d.ts +0 -2
- package/dist/utils/field-sizing.js +0 -2
- package/dist/utils/focus-handle.d.ts +1 -2
- package/dist/utils/focus-handle.js +1 -3
- package/dist/utils/focus-scope.d.ts +5 -6
- package/dist/utils/focus-scope.js +10 -11
- package/dist/utils/is-promise.d.ts +1 -1
- package/dist/utils/release-holder.d.ts +2 -2
- package/dist/utils/release-holder.js +4 -4
- package/dist/utils/scroll-lock.d.ts +3 -4
- package/dist/utils/scroll-lock.js +3 -4
- package/dist/utils/tween.d.ts +0 -1
- package/dist/utils/tween.js +0 -1
- package/dist/utils/uuid.d.ts +0 -1
- package/dist/utils/uuid.js +0 -1
- package/dist/utils/warning.d.ts +0 -1
- package/dist/utils/warning.js +0 -1
- package/dist/video-player/foundation.d.ts +15 -15
- package/dist/video-player/foundation.js +89 -89
- package/dist/video-player/progress-foundation.d.ts +2 -3
- package/dist/video-player/progress-foundation.js +12 -13
- package/dist/video-player/variables.scss +1 -1
- package/package.json +2 -2
package/dist/cascader/util.js
CHANGED
|
@@ -2,9 +2,6 @@ import { VALUE_SPLIT, strings } from "./constants.js";
|
|
|
2
2
|
import { getPosition } from "../tree/tree-util.js";
|
|
3
3
|
import { get } from "es-toolkit/compat";
|
|
4
4
|
// src/cascader/util.ts
|
|
5
|
-
/**
|
|
6
|
-
* @returns whether option matches sugInput; a function filterTreeNode decides with (sugInput, target, option).
|
|
7
|
-
*/
|
|
8
5
|
function filter(sugInput, option, filterTreeNode, filteredPath) {
|
|
9
6
|
if (!filterTreeNode) return true;
|
|
10
7
|
let filterFn = filterTreeNode;
|
|
@@ -18,7 +15,6 @@ function filter(sugInput, option, filterTreeNode, filteredPath) {
|
|
|
18
15
|
} else target = filteredPath.join();
|
|
19
16
|
return filterFn(sugInput, target, option);
|
|
20
17
|
}
|
|
21
|
-
/** One column per level of the active path: the top level, then the children of each active node that has some */
|
|
22
18
|
function getColumns(topLevel, activeKeys) {
|
|
23
19
|
const columns = [];
|
|
24
20
|
let items = topLevel;
|
|
@@ -31,10 +27,7 @@ function getColumns(topLevel, activeKeys) {
|
|
|
31
27
|
}
|
|
32
28
|
return columns;
|
|
33
29
|
}
|
|
34
|
-
/**
|
|
35
|
-
* The labels of a search result joined by the separator, split into the runs that match the keyword and the rest. Only
|
|
36
|
-
* a string label is matched, as the default filter does; any other label passes through whole.
|
|
37
|
-
*/
|
|
30
|
+
/** Only a string label is matched, as the default filter does; any other label passes through whole */
|
|
38
31
|
function highlightParts(searchText, keyword, separator) {
|
|
39
32
|
const parts = [];
|
|
40
33
|
const lowerKeyword = keyword.toLowerCase();
|
|
@@ -13,7 +13,6 @@ export interface BasicCheckboxEvent {
|
|
|
13
13
|
};
|
|
14
14
|
[x: string]: any;
|
|
15
15
|
}
|
|
16
|
-
/** The click that toggles the checkbox: only what the foundation reads or forwards */
|
|
17
16
|
export interface CheckboxSourceEvent {
|
|
18
17
|
stopPropagation: () => void;
|
|
19
18
|
preventDefault: () => void;
|
|
@@ -36,7 +35,6 @@ export interface CheckboxBaseState {
|
|
|
36
35
|
checked: boolean;
|
|
37
36
|
}
|
|
38
37
|
type AriaInvalid = boolean | 'true' | 'false' | 'grammar' | 'spelling';
|
|
39
|
-
/** What a CheckboxGroup hands to the checkboxes inside it */
|
|
40
38
|
export interface CheckboxGroupView {
|
|
41
39
|
value: CheckboxValue[];
|
|
42
40
|
disabled: boolean;
|
|
@@ -46,7 +44,7 @@ export interface CheckboxGroupView {
|
|
|
46
44
|
ariaInvalid?: AriaInvalid;
|
|
47
45
|
ariaErrormessage?: string;
|
|
48
46
|
}
|
|
49
|
-
/**
|
|
47
|
+
/** `checked` is the controlled value */
|
|
50
48
|
export interface CheckboxViewProps {
|
|
51
49
|
checked?: unknown;
|
|
52
50
|
disabled?: boolean;
|
|
@@ -68,12 +66,10 @@ export interface CheckboxView {
|
|
|
68
66
|
}
|
|
69
67
|
export default class CheckboxFoundation<P extends BaseCheckboxProps = BaseCheckboxProps, S extends CheckboxBaseState = CheckboxBaseState> extends BaseFoundation<CheckboxAdapter<P, S>, P, S> {
|
|
70
68
|
#private;
|
|
71
|
-
/** How the checkbox looks and behaves, from its own props or, with a value inside a group, from the group */
|
|
72
69
|
static deriveView(props: CheckboxViewProps, state: CheckboxBaseState, group?: CheckboxGroupView | null): CheckboxView;
|
|
73
|
-
/** Whether a click landed on an interactive element inside the root other than the checkbox's own input */
|
|
74
70
|
static isInnerInteractiveClick(target: Element, root: Element, input?: Element | null): boolean;
|
|
75
|
-
handleChange(e: CheckboxSourceEvent)
|
|
76
|
-
setChecked(checked: boolean)
|
|
71
|
+
handleChange: (e: CheckboxSourceEvent) => void;
|
|
72
|
+
setChecked: (checked: boolean) => void;
|
|
77
73
|
}
|
|
78
74
|
export interface BaseCheckboxProps {
|
|
79
75
|
id?: string;
|
|
@@ -5,17 +5,16 @@ import { strings } from "./constants.js";
|
|
|
5
5
|
const INTERACTIVE_SELECTOR = "a, button, input, select, textarea, [contenteditable]:not([contenteditable=\"false\"])";
|
|
6
6
|
var CheckboxFoundation = class extends BaseFoundation {
|
|
7
7
|
#notifyChange(checked, e) {
|
|
8
|
-
const cbValue = this.
|
|
9
|
-
this.
|
|
8
|
+
const cbValue = this.adapter.generateEvent(checked, e);
|
|
9
|
+
this.adapter.notifyChange(cbValue);
|
|
10
10
|
}
|
|
11
11
|
#handleChangeInGroup(e) {
|
|
12
12
|
const { value } = this.getProps();
|
|
13
|
-
const newChecked = !this.
|
|
14
|
-
const event = this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
13
|
+
const newChecked = !this.adapter.getGroupValue().includes(value);
|
|
14
|
+
const event = this.adapter.generateEvent(newChecked, e);
|
|
15
|
+
this.adapter.notifyChange(event);
|
|
16
|
+
this.adapter.notifyGroupChange(event);
|
|
17
17
|
}
|
|
18
|
-
/** How the checkbox looks and behaves, from its own props or, with a value inside a group, from the group */
|
|
19
18
|
static deriveView(props, state, group) {
|
|
20
19
|
if (group && props.value !== void 0) return {
|
|
21
20
|
inGroup: true,
|
|
@@ -39,27 +38,26 @@ var CheckboxFoundation = class extends BaseFoundation {
|
|
|
39
38
|
ariaErrormessage: props["aria-errormessage"]
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
|
-
/** Whether a click landed on an interactive element inside the root other than the checkbox's own input */
|
|
43
41
|
static isInnerInteractiveClick(target, root, input) {
|
|
44
42
|
const interactive = target.closest(INTERACTIVE_SELECTOR);
|
|
45
43
|
return Boolean(interactive && interactive !== input && root.contains(interactive));
|
|
46
44
|
}
|
|
47
|
-
handleChange(e) {
|
|
45
|
+
handleChange = (e) => {
|
|
48
46
|
if (this.getProp("disabled")) return;
|
|
49
|
-
this.
|
|
50
|
-
if (this.
|
|
51
|
-
if (!this.
|
|
47
|
+
this.adapter.focusCheckboxEntity();
|
|
48
|
+
if (this.adapter.getIsInGroup()) {
|
|
49
|
+
if (!this.adapter.getGroupDisabled()) this.#handleChangeInGroup(e);
|
|
52
50
|
return;
|
|
53
51
|
}
|
|
54
52
|
const newChecked = !this.getState("checked");
|
|
55
|
-
if (this.
|
|
53
|
+
if (this.isControlledComponent("checked")) this.#notifyChange(newChecked, e);
|
|
56
54
|
else {
|
|
57
55
|
this.setChecked(newChecked);
|
|
58
56
|
this.#notifyChange(newChecked, e);
|
|
59
57
|
}
|
|
60
|
-
}
|
|
61
|
-
setChecked(checked) {
|
|
62
|
-
this.
|
|
63
|
-
}
|
|
58
|
+
};
|
|
59
|
+
setChecked = (checked) => {
|
|
60
|
+
this.adapter.setChecked(checked);
|
|
61
|
+
};
|
|
64
62
|
};
|
|
65
63
|
export { CheckboxFoundation as default };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation.js";
|
|
2
2
|
import { BasicCheckboxEvent } from "./checkbox-foundation.js";
|
|
3
3
|
export type CheckboxValue = string | number | boolean;
|
|
4
|
-
/** The props the foundation reads with getProps */
|
|
5
4
|
export interface CheckboxGroupBaseProps {
|
|
6
5
|
defaultValue?: CheckboxValue[];
|
|
7
6
|
value?: CheckboxValue[];
|
|
@@ -16,6 +15,6 @@ export interface CheckboxGroupAdapter<P extends CheckboxGroupBaseProps = Checkbo
|
|
|
16
15
|
export default class CheckboxGroupFoundation<P extends CheckboxGroupBaseProps = CheckboxGroupBaseProps, S extends CheckboxGroupBaseState = CheckboxGroupBaseState> extends BaseFoundation<CheckboxGroupAdapter<P, S>, P, S> {
|
|
17
16
|
static deriveValue(props: CheckboxGroupBaseProps, state: CheckboxGroupBaseState): CheckboxValue[];
|
|
18
17
|
init(): void;
|
|
19
|
-
handleChange(evt: BasicCheckboxEvent)
|
|
20
|
-
handlePropValueChange(newPropValue: unknown)
|
|
18
|
+
handleChange: (evt: BasicCheckboxEvent) => void;
|
|
19
|
+
handlePropValueChange: (newPropValue: unknown) => void;
|
|
21
20
|
}
|
|
@@ -10,19 +10,19 @@ var CheckboxGroupFoundation = class CheckboxGroupFoundation extends BaseFoundati
|
|
|
10
10
|
if (typeof defaultValue !== "undefined" && !Array.isArray(defaultValue)) warning(true, "Warning: [Semi CheckboxGroup] defaultValue should be an Array");
|
|
11
11
|
if (typeof value !== "undefined" && !Array.isArray(value)) warning(true, "Warning: [Semi CheckboxGroup] value should be an Array");
|
|
12
12
|
}
|
|
13
|
-
handleChange(evt) {
|
|
13
|
+
handleChange = (evt) => {
|
|
14
14
|
const prevValue = CheckboxGroupFoundation.deriveValue(this.getProps(), this.getStates());
|
|
15
15
|
const { checked, value } = evt.target;
|
|
16
16
|
const newValue = checked ? [...prevValue, value] : prevValue.filter((item) => item !== value);
|
|
17
|
-
if (!this.
|
|
18
|
-
this.
|
|
19
|
-
}
|
|
20
|
-
handlePropValueChange(newPropValue) {
|
|
21
|
-
if (Array.isArray(newPropValue)) this.
|
|
17
|
+
if (!this.isControlledComponent()) this.adapter.updateGroupValue(newValue);
|
|
18
|
+
this.adapter.notifyChange(newValue);
|
|
19
|
+
};
|
|
20
|
+
handlePropValueChange = (newPropValue) => {
|
|
21
|
+
if (Array.isArray(newPropValue)) this.adapter.updateGroupValue(newPropValue);
|
|
22
22
|
else {
|
|
23
|
-
if (typeof newPropValue === "undefined") this.
|
|
23
|
+
if (typeof newPropValue === "undefined") this.adapter.updateGroupValue([]);
|
|
24
24
|
warning(true, "Warning: [Semi CheckboxGroup] value should be an Array");
|
|
25
25
|
}
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
27
|
};
|
|
28
28
|
export { CheckboxGroupFoundation as default };
|
|
@@ -7,7 +7,6 @@ export interface CodeHighlightBaseProps {
|
|
|
7
7
|
lineNumber?: boolean;
|
|
8
8
|
/** Grammars this block needs beyond the registered ones, loaded once into the shared highlighter */
|
|
9
9
|
languages?: LanguageInput[];
|
|
10
|
-
/** Overrides the registered themes for this block */
|
|
11
10
|
themes?: CodeHighlightThemes;
|
|
12
11
|
}
|
|
13
12
|
export interface CodeHighlightBaseState {
|
|
@@ -21,5 +20,5 @@ export interface CodeHighlightAdapter<P extends CodeHighlightBaseProps = CodeHig
|
|
|
21
20
|
export default class CodeHighlightFoundation<P extends CodeHighlightBaseProps = CodeHighlightBaseProps, S extends CodeHighlightBaseState = CodeHighlightBaseState> extends BaseFoundation<CodeHighlightAdapter<P, S>, P, S> {
|
|
22
21
|
#private;
|
|
23
22
|
destroy(): void;
|
|
24
|
-
highlightCode()
|
|
23
|
+
highlightCode: () => Promise<void>;
|
|
25
24
|
}
|
|
@@ -5,7 +5,7 @@ var CodeHighlightFoundation = class extends BaseFoundation {
|
|
|
5
5
|
destroy() {
|
|
6
6
|
this.#requestId++;
|
|
7
7
|
}
|
|
8
|
-
async
|
|
8
|
+
highlightCode = async () => {
|
|
9
9
|
const { code = "", language, languages, themes } = this.getProps();
|
|
10
10
|
const requestId = ++this.#requestId;
|
|
11
11
|
const { highlight } = await import("./highlighter.js");
|
|
@@ -13,7 +13,7 @@ var CodeHighlightFoundation = class extends BaseFoundation {
|
|
|
13
13
|
languages,
|
|
14
14
|
themes
|
|
15
15
|
});
|
|
16
|
-
if (requestId === this.#requestId) this.
|
|
17
|
-
}
|
|
16
|
+
if (requestId === this.#requestId) this.adapter.setHtml(html, code);
|
|
17
|
+
};
|
|
18
18
|
};
|
|
19
19
|
export { CodeHighlightFoundation as default };
|
|
@@ -42,6 +42,6 @@ export default class CollapseFoundation<E = unknown> extends BaseFoundation<Coll
|
|
|
42
42
|
lazyRender: boolean;
|
|
43
43
|
everOpened: boolean;
|
|
44
44
|
}): boolean;
|
|
45
|
-
syncActiveKey(activeKey: CollapseProps[
|
|
46
|
-
handleChange(newKey: string, e: E)
|
|
45
|
+
syncActiveKey: (activeKey: CollapseProps["activeKey"]) => void;
|
|
46
|
+
handleChange: (newKey: string, e: E) => void;
|
|
47
47
|
}
|
|
@@ -25,20 +25,20 @@ var CollapseFoundation = class CollapseFoundation extends BaseFoundation {
|
|
|
25
25
|
static isContentMounted({ hasBody, active, keepDOM, lazyRender, everOpened }) {
|
|
26
26
|
return hasBody && (active || keepDOM && (!lazyRender || everOpened));
|
|
27
27
|
}
|
|
28
|
-
syncActiveKey(activeKey) {
|
|
28
|
+
syncActiveKey = (activeKey) => {
|
|
29
29
|
if (activeKey !== void 0) {
|
|
30
30
|
const newSet = toSet(activeKey);
|
|
31
|
-
if (!isEqual(newSet, this.getStates().activeSet)) this.
|
|
31
|
+
if (!isEqual(newSet, this.getStates().activeSet)) this.adapter.setActiveSet(newSet);
|
|
32
32
|
}
|
|
33
|
-
}
|
|
34
|
-
handleChange(newKey, e) {
|
|
33
|
+
};
|
|
34
|
+
handleChange = (newKey, e) => {
|
|
35
35
|
const { activeKey, accordion } = this.getProps();
|
|
36
36
|
let newSet = new Set(CollapseFoundation.deriveActiveSet(this.getProps(), this.getStates()));
|
|
37
37
|
if (newSet.has(newKey)) newSet.delete(newKey);
|
|
38
38
|
else if (accordion) newSet = /* @__PURE__ */ new Set([newKey]);
|
|
39
39
|
else newSet.add(newKey);
|
|
40
|
-
this.
|
|
41
|
-
if (typeof activeKey === "undefined") this.
|
|
42
|
-
}
|
|
40
|
+
this.adapter.notifyChange([...newSet.values()], e);
|
|
41
|
+
if (typeof activeKey === "undefined") this.adapter.setActiveSet(newSet);
|
|
42
|
+
};
|
|
43
43
|
};
|
|
44
44
|
export { CollapseFoundation as default };
|
|
@@ -56,13 +56,13 @@ export default class CollapsibleFoundation<P extends CollapsibleBaseProps = Coll
|
|
|
56
56
|
* height animates between measured lengths instead and its end stands in for the transitionend. Removable, with
|
|
57
57
|
* the max-height rule of collapsible.scss, once Firefox and Safari support calc-size().
|
|
58
58
|
*/
|
|
59
|
-
handleOpenChange()
|
|
59
|
+
handleOpenChange: () => void;
|
|
60
60
|
/**
|
|
61
61
|
* `isSelf`: the event comes from the wrapper, not bubbling from the content. Only `height` is awaited: toggling
|
|
62
62
|
* `isOpen` always transitions it, even when `fade` also animates `opacity`.
|
|
63
63
|
*/
|
|
64
|
-
handleTransitionEnd({ isSelf, propertyName }: {
|
|
64
|
+
handleTransitionEnd: ({ isSelf, propertyName }: {
|
|
65
65
|
isSelf: boolean;
|
|
66
66
|
propertyName: string;
|
|
67
|
-
})
|
|
67
|
+
}) => void;
|
|
68
68
|
}
|
|
@@ -75,9 +75,9 @@ var CollapsibleFoundation = class CollapsibleFoundation extends BaseFoundation {
|
|
|
75
75
|
* height animates between measured lengths instead and its end stands in for the transitionend. Removable, with
|
|
76
76
|
* the max-height rule of collapsible.scss, once Firefox and Safari support calc-size().
|
|
77
77
|
*/
|
|
78
|
-
handleOpenChange() {
|
|
78
|
+
handleOpenChange = () => {
|
|
79
79
|
const { isOpen, duration, collapseHeight, collapseHeightAdaptive } = this.getProps();
|
|
80
|
-
const wrapper = this.
|
|
80
|
+
const wrapper = this.adapter.getWrapper();
|
|
81
81
|
if (!wrapper || !CollapsibleFoundation.hasMotion(this.getProps()) || CSS.supports("height", "calc-size(auto, size)")) return;
|
|
82
82
|
const current = this.#heightAnimation && this.#heightAnimation.playState !== "finished" ? wrapper.offsetHeight : void 0;
|
|
83
83
|
this.#heightAnimation?.cancel();
|
|
@@ -108,16 +108,16 @@ var CollapsibleFoundation = class CollapsibleFoundation extends BaseFoundation {
|
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
}, () => void 0);
|
|
111
|
-
}
|
|
111
|
+
};
|
|
112
112
|
/**
|
|
113
113
|
* `isSelf`: the event comes from the wrapper, not bubbling from the content. Only `height` is awaited: toggling
|
|
114
114
|
* `isOpen` always transitions it, even when `fade` also animates `opacity`.
|
|
115
115
|
*/
|
|
116
|
-
handleTransitionEnd({ isSelf, propertyName }) {
|
|
116
|
+
handleTransitionEnd = ({ isSelf, propertyName }) => {
|
|
117
117
|
if (!isSelf || propertyName !== "height") return;
|
|
118
|
-
if (!this.getProp("isOpen")) this.
|
|
119
|
-
this.
|
|
120
|
-
this.
|
|
121
|
-
}
|
|
118
|
+
if (!this.getProp("isOpen")) this.adapter.setVisible(false);
|
|
119
|
+
this.adapter.setIsTransitioning(false);
|
|
120
|
+
this.adapter.notifyMotionEnd();
|
|
121
|
+
};
|
|
122
122
|
};
|
|
123
123
|
export { CollapsibleFoundation as default };
|
|
@@ -15,15 +15,13 @@ export interface AlphaSliderAdapter<P extends AlphaSliderBaseProps = AlphaSlider
|
|
|
15
15
|
getDOM: () => HTMLDivElement;
|
|
16
16
|
}
|
|
17
17
|
export default class AlphaSliderFoundation<P extends AlphaSliderBaseProps = AlphaSliderBaseProps, S extends AlphaSliderBaseState = AlphaSliderBaseState> extends BaseFoundation<AlphaSliderAdapter<P, S>, P, S> {
|
|
18
|
+
#private;
|
|
18
19
|
constructor(adapter: AlphaSliderAdapter<P, S>);
|
|
19
20
|
/** Captures the pointer from the press, so moves and release arrive outside the slider too */
|
|
20
21
|
handlePointerDown: (e: DragPointerEvent) => void;
|
|
21
22
|
handlePointerMove: (e: DragPointerEvent) => void;
|
|
22
23
|
/** Follows pointerup and pointercancel; also fires when the slider leaves the page mid-drag */
|
|
23
24
|
handleLostPointerCapture: () => void;
|
|
24
|
-
setValue(percent: number)
|
|
25
|
+
setValue: (percent: number) => void;
|
|
25
26
|
handleKeyDown: (e: RangeKeyEvent) => void;
|
|
26
|
-
pickByPointer: (e: {
|
|
27
|
-
clientX: number;
|
|
28
|
-
}) => void;
|
|
29
27
|
}
|
|
@@ -7,23 +7,29 @@ var AlphaSliderFoundation = class extends BaseFoundation {
|
|
|
7
7
|
constructor(adapter) {
|
|
8
8
|
super({ ...adapter });
|
|
9
9
|
}
|
|
10
|
+
#pickByPointer(e) {
|
|
11
|
+
const rect = this.adapter.getDOM()?.getBoundingClientRect();
|
|
12
|
+
if (!rect) return;
|
|
13
|
+
const { width, foundation } = this.getProps();
|
|
14
|
+
foundation.handleAlphaChangeByHandle({ a: Number(clamp((e.clientX - rect.x) / width, 0, 1).toFixed(2)) });
|
|
15
|
+
}
|
|
10
16
|
/** Captures the pointer from the press, so moves and release arrive outside the slider too */
|
|
11
17
|
handlePointerDown = (e) => {
|
|
12
18
|
if (isSecondaryPress(e)) return;
|
|
13
19
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
14
20
|
this.setState({ isHandleGrabbing: true });
|
|
15
|
-
this
|
|
21
|
+
this.#pickByPointer(e);
|
|
16
22
|
};
|
|
17
23
|
handlePointerMove = (e) => {
|
|
18
|
-
if (this.getState("isHandleGrabbing")) this
|
|
24
|
+
if (this.getState("isHandleGrabbing")) this.#pickByPointer(e);
|
|
19
25
|
};
|
|
20
26
|
/** Follows pointerup and pointercancel; also fires when the slider leaves the page mid-drag */
|
|
21
27
|
handleLostPointerCapture = () => {
|
|
22
28
|
this.setState({ isHandleGrabbing: false });
|
|
23
29
|
};
|
|
24
|
-
setValue(percent) {
|
|
30
|
+
setValue = (percent) => {
|
|
25
31
|
this.getProps().foundation.handleAlphaChangeByHandle({ a: percent / 100 });
|
|
26
|
-
}
|
|
32
|
+
};
|
|
27
33
|
handleKeyDown = (e) => {
|
|
28
34
|
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
29
35
|
const percent = ColorPickerFoundation.getValueByKey(e.key, this.getProps().hsva.a * 100, 100);
|
|
@@ -31,11 +37,5 @@ var AlphaSliderFoundation = class extends BaseFoundation {
|
|
|
31
37
|
e.preventDefault();
|
|
32
38
|
this.setValue(percent);
|
|
33
39
|
};
|
|
34
|
-
pickByPointer = (e) => {
|
|
35
|
-
const rect = this._adapter.getDOM()?.getBoundingClientRect();
|
|
36
|
-
if (!rect) return;
|
|
37
|
-
const { width, foundation } = this.getProps();
|
|
38
|
-
foundation.handleAlphaChangeByHandle({ a: Number(clamp((e.clientX - rect.x) / width, 0, 1).toFixed(2)) });
|
|
39
|
-
};
|
|
40
40
|
};
|
|
41
41
|
export { AlphaSliderFoundation as default };
|
|
@@ -21,16 +21,13 @@ export interface ColorChooseAreaAdapter<P extends ColorChooseAreaBaseProps = Col
|
|
|
21
21
|
}) => void;
|
|
22
22
|
}
|
|
23
23
|
export default class ColorChooseAreaFoundation<P extends ColorChooseAreaBaseProps = ColorChooseAreaBaseProps, S extends ColorChooseAreaBaseState = ColorChooseAreaBaseState> extends BaseFoundation<ColorChooseAreaAdapter<P, S>, P, S> {
|
|
24
|
+
#private;
|
|
24
25
|
constructor(adapter: ColorChooseAreaAdapter<P, S>);
|
|
25
|
-
setValue(axis:
|
|
26
|
+
setValue: (axis: "s" | "v", value: number) => void;
|
|
26
27
|
handleKeyDown: (focusedAxis: "s" | "v", e: RangeKeyEvent) => void;
|
|
27
28
|
/** Captures the pointer from the press; positions outside pick the nearest edge or corner */
|
|
28
29
|
handlePointerDown: (e: DragPointerEvent) => void;
|
|
29
30
|
handlePointerMove: (e: DragPointerEvent) => void;
|
|
30
31
|
/** Follows pointerup and pointercancel; also fires when the area leaves the page mid-drag */
|
|
31
32
|
handleLostPointerCapture: () => void;
|
|
32
|
-
pickByPointer: (e: {
|
|
33
|
-
clientX: number;
|
|
34
|
-
clientY: number;
|
|
35
|
-
}) => void;
|
|
36
33
|
}
|
|
@@ -7,14 +7,23 @@ var ColorChooseAreaFoundation = class extends BaseFoundation {
|
|
|
7
7
|
constructor(adapter) {
|
|
8
8
|
super({ ...adapter });
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
#pickByPointer(e) {
|
|
11
|
+
const rect = this.adapter.getDOM()?.getBoundingClientRect();
|
|
12
|
+
if (!rect) return;
|
|
13
|
+
const { width, height } = this.getProps();
|
|
14
|
+
this.adapter.notifyChange({
|
|
15
|
+
s: Math.round(clamp((e.clientX - rect.x) / width, 0, 1) * 100),
|
|
16
|
+
v: Math.round(100 - clamp((e.clientY - rect.y) / height, 0, 1) * 100)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
setValue = (axis, value) => {
|
|
11
20
|
const { hsva } = this.getProps();
|
|
12
|
-
this.
|
|
21
|
+
this.adapter.notifyChange({
|
|
13
22
|
s: hsva.s,
|
|
14
23
|
v: hsva.v,
|
|
15
24
|
[axis]: value
|
|
16
25
|
});
|
|
17
|
-
}
|
|
26
|
+
};
|
|
18
27
|
handleKeyDown = (focusedAxis, e) => {
|
|
19
28
|
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
20
29
|
let axis = focusedAxis;
|
|
@@ -35,23 +44,14 @@ var ColorChooseAreaFoundation = class extends BaseFoundation {
|
|
|
35
44
|
if (isSecondaryPress(e)) return;
|
|
36
45
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
37
46
|
this.setState({ isHandleGrabbing: true });
|
|
38
|
-
this
|
|
47
|
+
this.#pickByPointer(e);
|
|
39
48
|
};
|
|
40
49
|
handlePointerMove = (e) => {
|
|
41
|
-
if (this.getState("isHandleGrabbing")) this
|
|
50
|
+
if (this.getState("isHandleGrabbing")) this.#pickByPointer(e);
|
|
42
51
|
};
|
|
43
52
|
/** Follows pointerup and pointercancel; also fires when the area leaves the page mid-drag */
|
|
44
53
|
handleLostPointerCapture = () => {
|
|
45
54
|
this.setState({ isHandleGrabbing: false });
|
|
46
55
|
};
|
|
47
|
-
pickByPointer = (e) => {
|
|
48
|
-
const rect = this._adapter.getDOM()?.getBoundingClientRect();
|
|
49
|
-
if (!rect) return;
|
|
50
|
-
const { width, height } = this.getProps();
|
|
51
|
-
this._adapter.notifyChange({
|
|
52
|
-
s: Math.round(clamp((e.clientX - rect.x) / width, 0, 1) * 100),
|
|
53
|
-
v: Math.round(100 - clamp((e.clientY - rect.y) / height, 0, 1) * 100)
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
56
|
};
|
|
57
57
|
export { ColorChooseAreaFoundation as default };
|
|
@@ -49,7 +49,6 @@ $module: #{$prefix}-colorPicker;
|
|
|
49
49
|
&-alphaSlider {
|
|
50
50
|
position: relative;
|
|
51
51
|
margin-top: $spacing-colorPicker_slider-marginTop;
|
|
52
|
-
// scrolling the page would cancel the pointer mid-drag
|
|
53
52
|
touch-action: none;
|
|
54
53
|
cursor: pointer;
|
|
55
54
|
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><rect x="8" width="8" height="8"/><rect y="8" width="8" height="8"/></svg>');
|
|
@@ -74,7 +73,6 @@ $module: #{$prefix}-colorPicker;
|
|
|
74
73
|
&-colorSlider {
|
|
75
74
|
position: relative;
|
|
76
75
|
margin-top: $spacing-colorPicker_slider-marginTop;
|
|
77
|
-
// scrolling the page would cancel the pointer mid-drag
|
|
78
76
|
touch-action: none;
|
|
79
77
|
cursor: pointer;
|
|
80
78
|
background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
|
|
@@ -15,15 +15,13 @@ export interface ColorSliderAdapter<P extends ColorSliderBaseProps = ColorSlider
|
|
|
15
15
|
getDOM: () => HTMLDivElement;
|
|
16
16
|
}
|
|
17
17
|
export default class ColorSliderFoundation<P extends ColorSliderBaseProps = ColorSliderBaseProps, S extends ColorSliderBaseState = ColorSliderBaseState> extends BaseFoundation<ColorSliderAdapter<P, S>, P, S> {
|
|
18
|
+
#private;
|
|
18
19
|
constructor(adapter: ColorSliderAdapter<P, S>);
|
|
19
20
|
/** Captures the pointer from the press, so moves and release arrive outside the slider too */
|
|
20
21
|
handlePointerDown: (e: DragPointerEvent) => void;
|
|
21
22
|
handlePointerMove: (e: DragPointerEvent) => void;
|
|
22
23
|
/** Follows pointerup and pointercancel; also fires when the slider leaves the page mid-drag */
|
|
23
24
|
handleLostPointerCapture: () => void;
|
|
24
|
-
setValue(h: number)
|
|
25
|
+
setValue: (h: number) => void;
|
|
25
26
|
handleKeyDown: (e: RangeKeyEvent) => void;
|
|
26
|
-
pickByPointer: (e: {
|
|
27
|
-
clientX: number;
|
|
28
|
-
}) => void;
|
|
29
27
|
}
|
|
@@ -7,23 +7,29 @@ var ColorSliderFoundation = class extends BaseFoundation {
|
|
|
7
7
|
constructor(adapter) {
|
|
8
8
|
super({ ...adapter });
|
|
9
9
|
}
|
|
10
|
+
#pickByPointer(e) {
|
|
11
|
+
const rect = this.adapter.getDOM()?.getBoundingClientRect();
|
|
12
|
+
if (!rect) return;
|
|
13
|
+
const { width, foundation } = this.getProps();
|
|
14
|
+
foundation.handleColorChangeByHandle({ h: Math.round(clamp((e.clientX - rect.x) / width, 0, 1) * 360) });
|
|
15
|
+
}
|
|
10
16
|
/** Captures the pointer from the press, so moves and release arrive outside the slider too */
|
|
11
17
|
handlePointerDown = (e) => {
|
|
12
18
|
if (isSecondaryPress(e)) return;
|
|
13
19
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
14
20
|
this.setState({ isHandleGrabbing: true });
|
|
15
|
-
this
|
|
21
|
+
this.#pickByPointer(e);
|
|
16
22
|
};
|
|
17
23
|
handlePointerMove = (e) => {
|
|
18
|
-
if (this.getState("isHandleGrabbing")) this
|
|
24
|
+
if (this.getState("isHandleGrabbing")) this.#pickByPointer(e);
|
|
19
25
|
};
|
|
20
26
|
/** Follows pointerup and pointercancel; also fires when the slider leaves the page mid-drag */
|
|
21
27
|
handleLostPointerCapture = () => {
|
|
22
28
|
this.setState({ isHandleGrabbing: false });
|
|
23
29
|
};
|
|
24
|
-
setValue(h) {
|
|
30
|
+
setValue = (h) => {
|
|
25
31
|
this.getProps().foundation.handleColorChangeByHandle({ h });
|
|
26
|
-
}
|
|
32
|
+
};
|
|
27
33
|
handleKeyDown = (e) => {
|
|
28
34
|
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
29
35
|
const h = ColorPickerFoundation.getValueByKey(e.key, this.getProps().hue, 360);
|
|
@@ -31,11 +37,5 @@ var ColorSliderFoundation = class extends BaseFoundation {
|
|
|
31
37
|
e.preventDefault();
|
|
32
38
|
this.setValue(h);
|
|
33
39
|
};
|
|
34
|
-
pickByPointer = (e) => {
|
|
35
|
-
const rect = this._adapter.getDOM()?.getBoundingClientRect();
|
|
36
|
-
if (!rect) return;
|
|
37
|
-
const { width, foundation } = this.getProps();
|
|
38
|
-
foundation.handleColorChangeByHandle({ h: Math.round(clamp((e.clientX - rect.x) / width, 0, 1) * 360) });
|
|
39
|
-
};
|
|
40
40
|
};
|
|
41
41
|
export { ColorSliderFoundation as default };
|
|
@@ -18,11 +18,11 @@ export default class DataPartFoundation<P extends DataPartBaseProps = DataPartBa
|
|
|
18
18
|
#private;
|
|
19
19
|
constructor(adapter: DataPartAdapter<P, S>);
|
|
20
20
|
static getInputValue(currentColor: ColorValue, format: ColorFormat): string;
|
|
21
|
-
syncInputValue()
|
|
21
|
+
syncInputValue: () => void;
|
|
22
22
|
/** Whether the text box already says `color`, so it must not overwrite what is being typed */
|
|
23
|
-
isInputValueOf(color: ColorValue)
|
|
24
|
-
getValueByInputValue(value: string)
|
|
23
|
+
isInputValueOf: (color: ColorValue) => boolean;
|
|
24
|
+
getValueByInputValue: (value: string) => string | false | RgbaColor | HsvaColor;
|
|
25
25
|
handlePickValueWithStraw: () => Promise<void>;
|
|
26
|
-
handleInputValueChange(value: string)
|
|
27
|
-
handleFormatChange(format: ColorFormat)
|
|
26
|
+
handleInputValueChange: (value: string) => void;
|
|
27
|
+
handleFormatChange: (format: ColorFormat) => void;
|
|
28
28
|
}
|
|
@@ -23,17 +23,17 @@ var DataPartFoundation = class DataPartFoundation extends BaseFoundation {
|
|
|
23
23
|
else if (format === "hsva") return `${hsva.h},${hsva.s},${hsva.v}`;
|
|
24
24
|
else return hex.slice(0, 7);
|
|
25
25
|
}
|
|
26
|
-
syncInputValue() {
|
|
26
|
+
syncInputValue = () => {
|
|
27
27
|
this.setState({ inputValue: DataPartFoundation.getInputValue(this.getProp("currentColor"), this.getState("format")) });
|
|
28
|
-
}
|
|
28
|
+
};
|
|
29
29
|
/** Whether the text box already says `color`, so it must not overwrite what is being typed */
|
|
30
|
-
isInputValueOf(color) {
|
|
30
|
+
isInputValueOf = (color) => {
|
|
31
31
|
const { format, inputValue } = this.getStates();
|
|
32
32
|
const parsed = this.getValueByInputValue(inputValue);
|
|
33
33
|
if (!parsed || format === "hex" && !inputValue.startsWith("#")) return false;
|
|
34
34
|
return isEqual(ColorPickerFoundation.getColorValue(parsed, format, Boolean(this.getProp("alpha"))), color);
|
|
35
|
-
}
|
|
36
|
-
getValueByInputValue(value) {
|
|
35
|
+
};
|
|
36
|
+
getValueByInputValue = (value) => {
|
|
37
37
|
const { format } = this.getStates();
|
|
38
38
|
if (format === "rgba" || format === "hsva") {
|
|
39
39
|
const parsed = format === "rgba" ? split(value, "rgba") : split(value, "hsva");
|
|
@@ -48,7 +48,7 @@ var DataPartFoundation = class DataPartFoundation extends BaseFoundation {
|
|
|
48
48
|
if (/^#[0-9a-f]{8}$/i.test(value)) return value;
|
|
49
49
|
}
|
|
50
50
|
return false;
|
|
51
|
-
}
|
|
51
|
+
};
|
|
52
52
|
handlePickValueWithStraw = async () => {
|
|
53
53
|
const colorPickerFoundation = this.getProps().foundation;
|
|
54
54
|
if (!window.EyeDropper) return;
|
|
@@ -63,14 +63,14 @@ var DataPartFoundation = class DataPartFoundation extends BaseFoundation {
|
|
|
63
63
|
if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
handleInputValueChange(value) {
|
|
67
|
-
this.
|
|
68
|
-
}
|
|
69
|
-
handleFormatChange(format) {
|
|
66
|
+
handleInputValueChange = (value) => {
|
|
67
|
+
this.adapter.setState({ inputValue: value });
|
|
68
|
+
};
|
|
69
|
+
handleFormatChange = (format) => {
|
|
70
70
|
this.setState({
|
|
71
71
|
format,
|
|
72
72
|
inputValue: DataPartFoundation.getInputValue(this.getProp("currentColor"), format)
|
|
73
73
|
});
|
|
74
|
-
}
|
|
74
|
+
};
|
|
75
75
|
};
|
|
76
76
|
export { DataPartFoundation as default };
|
|
@@ -45,11 +45,11 @@ export default class ColorPickerFoundation<P extends ColorPickerProps = ColorPic
|
|
|
45
45
|
*/
|
|
46
46
|
static getValueByKey(key: string, value: number, max: number): number;
|
|
47
47
|
/** After a controlled `value` is dropped, the uncontrolled state restarts from `defaultValue` */
|
|
48
|
-
resetToDefault()
|
|
49
|
-
handleChange(color: HsvaColor | RgbaColor | string, format: ColorFormat)
|
|
50
|
-
handleAlphaChangeByHandle(newAlpha: {
|
|
48
|
+
resetToDefault: () => void;
|
|
49
|
+
handleChange: (color: HsvaColor | RgbaColor | string, format: ColorFormat) => void;
|
|
50
|
+
handleAlphaChangeByHandle: (newAlpha: {
|
|
51
51
|
a: number;
|
|
52
|
-
})
|
|
52
|
+
}) => void;
|
|
53
53
|
handleColorChangeByHandle(newHue: {
|
|
54
54
|
h: number;
|
|
55
55
|
}): void;
|