@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
|
@@ -17,15 +17,11 @@ import toCallbackArgs, { toCallbackDates } from "./_utils/to-callback-args.js";
|
|
|
17
17
|
import { isEqual } from "es-toolkit";
|
|
18
18
|
import { format, isDate, isEqual as isEqual$1, isSameSecond, isValid, startOfDay } from "date-fns";
|
|
19
19
|
// src/date-picker/foundation.ts
|
|
20
|
-
/**
|
|
21
|
-
* Keeps the date value and the input text in sync: a selected date updates the input text, and a valid input text
|
|
22
|
-
* updates the date value; both notify the change.
|
|
23
|
-
*/
|
|
24
20
|
var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
25
21
|
#focusRecordTimers = /* @__PURE__ */ new Set();
|
|
26
22
|
#initialized = false;
|
|
27
23
|
#setRangeInputFocus(rangeInputFocus) {
|
|
28
|
-
this.
|
|
24
|
+
this.adapter.setRangeInputFocus(rangeInputFocus);
|
|
29
25
|
if (rangeInputFocus) this.#recordFocusLater(rangeInputFocus);
|
|
30
26
|
}
|
|
31
27
|
#recordFocusLater(rangeInputFocus) {
|
|
@@ -65,7 +61,7 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
65
61
|
return needConfirm(this.getProps());
|
|
66
62
|
}
|
|
67
63
|
#parseValue(value) {
|
|
68
|
-
const dateFnsLocale = this.
|
|
64
|
+
const dateFnsLocale = this.adapter.getProp("dateFnsLocale");
|
|
69
65
|
let dateObj;
|
|
70
66
|
if (isValidDate(value)) dateObj = value;
|
|
71
67
|
else if (typeof value === "string") dateObj = compatibleParse(value, this.getProp("format"), void 0, dateFnsLocale);
|
|
@@ -84,9 +80,9 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
84
80
|
if (!Array.isArray(value)) _value = value ? [value] : [];
|
|
85
81
|
else _value = value;
|
|
86
82
|
const changedDates = this.#getChangedDates(_value);
|
|
87
|
-
if (!this.
|
|
83
|
+
if (!this.isControlledComponent() && !this.#someDateDisabled(changedDates, _value) && !this.#needConfirm() && this.#isValueCommittable(_value)) this.adapter.updateValue(_value);
|
|
88
84
|
}
|
|
89
|
-
this.
|
|
85
|
+
this.adapter.updateInputValue(input);
|
|
90
86
|
}
|
|
91
87
|
#isValueCommittable(value) {
|
|
92
88
|
return !this.#isRangeType() || isRangeValueComplete(value);
|
|
@@ -94,11 +90,11 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
94
90
|
#notifyChange(value) {
|
|
95
91
|
if (!this.#isValueCommittable(value)) return;
|
|
96
92
|
const { notifyValue, notifyDate } = this.disposeCallbackArgs(value);
|
|
97
|
-
this.
|
|
93
|
+
this.adapter.notifyChange(notifyDate, notifyValue);
|
|
98
94
|
}
|
|
99
95
|
#getChangedDates(dates) {
|
|
100
|
-
const type = this.
|
|
101
|
-
const { cachedSelectedValue: lastDate } = this.
|
|
96
|
+
const type = this.adapter.getProp("type");
|
|
97
|
+
const { cachedSelectedValue: lastDate } = this.adapter.getStates();
|
|
102
98
|
const changedDates = [];
|
|
103
99
|
switch (type) {
|
|
104
100
|
case "dateRange":
|
|
@@ -156,25 +152,25 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
156
152
|
if (this.#shouldFocusRangeStart(result)) this.#setRangeInputFocus("rangeStart");
|
|
157
153
|
}
|
|
158
154
|
#getInitialValue() {
|
|
159
|
-
return this.
|
|
155
|
+
return this.isControlledComponent() ? this.getProp("value") : this.getProp("defaultValue");
|
|
160
156
|
}
|
|
161
157
|
#resolveValue(value, timeZone, prevTimeZone) {
|
|
162
158
|
const _value = (Array.isArray(value) ? [...value] : (value || value === 0) && [value]) || [];
|
|
163
159
|
return this.parseWithTimezone(_value, timeZone, prevTimeZone);
|
|
164
160
|
}
|
|
165
161
|
#initPanelOpenStatus(defaultOpen) {
|
|
166
|
-
this.
|
|
162
|
+
this.adapter.togglePanel(Boolean((this.getProp("open") || defaultOpen) && !this.getProp("disabled")));
|
|
167
163
|
}
|
|
168
164
|
#openPanel() {
|
|
169
165
|
if (!this.getProp("disabled") && !this.#isPanelShown()) {
|
|
170
|
-
if (!this.
|
|
171
|
-
this.
|
|
166
|
+
if (!this.isControlledComponent("open")) this.open();
|
|
167
|
+
this.adapter.notifyOpenChange(true);
|
|
172
168
|
}
|
|
173
169
|
}
|
|
174
170
|
#resetCachedSelectedValue(willUpdateDates) {
|
|
175
|
-
const { value, cachedSelectedValue } = this.
|
|
171
|
+
const { value, cachedSelectedValue } = this.adapter.getStates();
|
|
176
172
|
const newCachedSelectedValue = Array.isArray(willUpdateDates) ? willUpdateDates : value;
|
|
177
|
-
if (!isEqual(newCachedSelectedValue, cachedSelectedValue)) this.
|
|
173
|
+
if (!isEqual(newCachedSelectedValue, cachedSelectedValue)) this.adapter.updateCachedSelectedValue(newCachedSelectedValue);
|
|
178
174
|
}
|
|
179
175
|
#resetInnerSelectedStates(e) {
|
|
180
176
|
this.#resetCachedSelectedValue();
|
|
@@ -183,23 +179,12 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
183
179
|
}
|
|
184
180
|
#resetFocus(e) {
|
|
185
181
|
this.#setRangeInputFocus(false);
|
|
186
|
-
this.
|
|
182
|
+
this.adapter.notifyBlur(e);
|
|
187
183
|
}
|
|
188
184
|
#clearInputValue() {
|
|
189
|
-
this.
|
|
190
|
-
this.
|
|
185
|
+
this.adapter.updateInputValue(null);
|
|
186
|
+
this.adapter.updateInsetInputValue(null);
|
|
191
187
|
}
|
|
192
|
-
/**
|
|
193
|
-
* Parses a multiple input part by part with `parse`; an empty or unparsable part, or more than `max` dates,
|
|
194
|
-
* gives `[]`. `parseInputLoose` as `parse` keeps `null` for a half typed date.
|
|
195
|
-
*
|
|
196
|
-
* @example
|
|
197
|
-
* ```javascript
|
|
198
|
-
* this.#parseMultipleInput('2021-01-01,2021-10-15', parseInputLoose); // [Date, Date];
|
|
199
|
-
* this.#parseMultipleInput('2021-01-01,2021-10-', parseInputLoose); // [Date, null];
|
|
200
|
-
* this.#parseMultipleInput('', parseInputLoose); // [];
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
188
|
#parseMultipleInput(input, parse, { needDedupe = false } = {}) {
|
|
204
189
|
const max = this.getProp("max");
|
|
205
190
|
const result = [];
|
|
@@ -252,10 +237,7 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
252
237
|
const separator = rangeSeparator;
|
|
253
238
|
parsedResult = input.split(separator).map((cur) => cur && compatibleParse(cur, formatToken, nowDate, dateFnsLocale)).filter(Boolean);
|
|
254
239
|
formatedInput = parsedResult && parsedResult.map((v) => v && isValid(v) && this.localeFormat(v, formatToken)).join(separator);
|
|
255
|
-
if (parsedResult && formatedInput === input)
|
|
256
|
-
parsedResult.sort((d1, d2) => d1.getTime() - d2.getTime());
|
|
257
|
-
result = parsedResult;
|
|
258
|
-
}
|
|
240
|
+
if (parsedResult && formatedInput === input) result = parsedResult.toSorted((d1, d2) => d1.getTime() - d2.getTime());
|
|
259
241
|
}
|
|
260
242
|
}
|
|
261
243
|
return result;
|
|
@@ -300,8 +282,7 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
300
282
|
const parsedVal = compatibleParse(cur, formatToken, nowDate, dateFnsLocale);
|
|
301
283
|
return isValidDate(parsedVal) && this.localeFormat(parsedVal, formatToken) === cur ? parsedVal : null;
|
|
302
284
|
});
|
|
303
|
-
|
|
304
|
-
result = parsedResult;
|
|
285
|
+
result = Array.isArray(parsedResult) && parsedResult.every((item) => isValid(item)) ? parsedResult.toSorted((d1, d2) => d1.getTime() - d2.getTime()) : parsedResult;
|
|
305
286
|
}
|
|
306
287
|
}
|
|
307
288
|
return result;
|
|
@@ -356,7 +337,7 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
356
337
|
});
|
|
357
338
|
}
|
|
358
339
|
localeFormat(date, token) {
|
|
359
|
-
const dateFnsLocale = this.
|
|
340
|
+
const dateFnsLocale = this.adapter.getProp("dateFnsLocale");
|
|
360
341
|
return format(date, token, { locale: dateFnsLocale });
|
|
361
342
|
}
|
|
362
343
|
/**
|
|
@@ -371,10 +352,7 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
371
352
|
static isPanelShown(props, state) {
|
|
372
353
|
return (props.open !== void 0 ? Boolean(props.open) : Boolean(state.panelShow)) && !props.disabled;
|
|
373
354
|
}
|
|
374
|
-
/**
|
|
375
|
-
* The props derived from others. The rtl default of `position` stays with the
|
|
376
|
-
* frameworks, which read the direction from their config.
|
|
377
|
-
*/
|
|
355
|
+
/** The rtl default of `position` stays with the frameworks, which read the direction from their config. */
|
|
378
356
|
static normalizeProps({ type, format, rangeSeparator, insetInput, position, spacing }) {
|
|
379
357
|
const hasNoTime = typeof format === "string" && format && !/[Hhms]+/.test(format);
|
|
380
358
|
const normalizedType = hasNoTime && type === "dateTime" ? "date" : hasNoTime && type === "dateTimeRange" ? "dateRange" : type;
|
|
@@ -392,7 +370,6 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
392
370
|
* than `getProp` and `getProps`.
|
|
393
371
|
*
|
|
394
372
|
* @param props the props with the defaults applied and `timeZone` resolved from the ConfigProvider
|
|
395
|
-
* @returns `value`, `cachedSelectedValue`, `rangeInputFocus`, `inputValue` and `prevTimeZone`
|
|
396
373
|
*/
|
|
397
374
|
static getInitialState(props) {
|
|
398
375
|
const reader = new DatePickerFoundation({
|
|
@@ -426,89 +403,89 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
426
403
|
});
|
|
427
404
|
this.#initPanelOpenStatus(this.getProp("defaultOpen"));
|
|
428
405
|
}
|
|
429
|
-
initFromProps({ value, timeZone, prevTimeZone }) {
|
|
406
|
+
initFromProps = ({ value, timeZone, prevTimeZone }) => {
|
|
430
407
|
const result = this.#resolveValue(value, timeZone, prevTimeZone);
|
|
431
|
-
this.
|
|
408
|
+
this.adapter.updatePrevTimezone(prevTimeZone);
|
|
432
409
|
this.#clearInputValue();
|
|
433
|
-
this.
|
|
410
|
+
this.adapter.updateValue(result);
|
|
434
411
|
this.#resetCachedSelectedValue(result);
|
|
435
412
|
this.#initRangeInputFocus(result);
|
|
436
|
-
if (this.#needConfirm()) this.
|
|
437
|
-
}
|
|
413
|
+
if (this.#needConfirm()) this.adapter.updateCachedSelectedValue(result);
|
|
414
|
+
};
|
|
438
415
|
/** Called for a mousedown outside the trigger and the panel while the panel is shown */
|
|
439
|
-
handleClickOutside(e) {
|
|
440
|
-
this.
|
|
416
|
+
handleClickOutside = (e) => {
|
|
417
|
+
this.adapter.notifyClickOutSide(e);
|
|
441
418
|
if (!this.#needConfirm()) this.closePanel(e);
|
|
442
|
-
}
|
|
419
|
+
};
|
|
443
420
|
/** @param e the mousedown outside that closes the panel, passed on to onBlur */
|
|
444
421
|
closePanel(e) {
|
|
445
|
-
if (this.
|
|
446
|
-
if (typeof this.getProp("triggerRender") === "function") this.
|
|
447
|
-
else if (this.getProp("insetInput")) this.
|
|
422
|
+
if (this.adapter.isKeyboardFocusInPanel()) {
|
|
423
|
+
if (typeof this.getProp("triggerRender") === "function") this.adapter.setTriggerFocus();
|
|
424
|
+
else if (this.getProp("insetInput")) this.adapter.setTriggerDisabled(false, () => this.adapter.setTriggerFocus());
|
|
448
425
|
else this.focus(this.getState("rangeInputFocus") || void 0);
|
|
449
426
|
}
|
|
450
|
-
if (!this.
|
|
427
|
+
if (!this.isControlledComponent("open")) this.close(e);
|
|
451
428
|
else this.#resetInnerSelectedStates(e);
|
|
452
|
-
this.
|
|
429
|
+
this.adapter.notifyOpenChange(false);
|
|
453
430
|
}
|
|
454
|
-
open() {
|
|
431
|
+
open = () => {
|
|
455
432
|
this.#restartFocusRecords();
|
|
456
|
-
this.
|
|
457
|
-
}
|
|
433
|
+
this.adapter.togglePanel(true);
|
|
434
|
+
};
|
|
458
435
|
/** The controlled `open` turned true: starts what an uncontrolled open would */
|
|
459
|
-
handleControlledOpen() {
|
|
436
|
+
handleControlledOpen = () => {
|
|
460
437
|
this.#restartFocusRecords();
|
|
461
|
-
}
|
|
462
|
-
handleEscKeyDown() {
|
|
438
|
+
};
|
|
439
|
+
handleEscKeyDown = () => {
|
|
463
440
|
if (this.#needConfirm()) this.handleCancel();
|
|
464
441
|
else this.closePanel();
|
|
465
|
-
}
|
|
466
|
-
close(e) {
|
|
467
|
-
this.
|
|
442
|
+
};
|
|
443
|
+
close = (e) => {
|
|
444
|
+
this.adapter.togglePanel(false);
|
|
468
445
|
this.#clearFocusRecords();
|
|
469
446
|
this.#resetInnerSelectedStates(e);
|
|
470
|
-
}
|
|
447
|
+
};
|
|
471
448
|
/** Closes the panel without a blur or a returned focus, as when a Vue KeepAlive deactivates the host */
|
|
472
|
-
deactivate() {
|
|
473
|
-
if (!this.
|
|
474
|
-
this.
|
|
449
|
+
deactivate = () => {
|
|
450
|
+
if (!this.isControlledComponent("open")) {
|
|
451
|
+
this.adapter.togglePanel(false);
|
|
475
452
|
this.#clearFocusRecords();
|
|
476
453
|
}
|
|
477
454
|
this.#resetCachedSelectedValue();
|
|
478
455
|
this.#setRangeInputFocus(false);
|
|
479
456
|
this.#clearInputValue();
|
|
480
|
-
this.
|
|
481
|
-
}
|
|
457
|
+
this.adapter.notifyOpenChange(false);
|
|
458
|
+
};
|
|
482
459
|
destroy() {
|
|
483
460
|
this.#cancelFocusRecords();
|
|
484
461
|
}
|
|
485
|
-
focus(focusType) {
|
|
486
|
-
if (typeof this.getProp("triggerRender") === "function") this.
|
|
462
|
+
focus = (focusType) => {
|
|
463
|
+
if (typeof this.getProp("triggerRender") === "function") this.adapter.setTriggerFocus();
|
|
487
464
|
else if (this.#hasTwoInputs()) this.#setRangeInputFocus(focusType ?? "rangeStart");
|
|
488
|
-
else if (this.getProp("insetInput") && this.#isPanelShown()) this.
|
|
489
|
-
else this.
|
|
490
|
-
}
|
|
491
|
-
blur() {
|
|
492
|
-
this.
|
|
465
|
+
else if (this.getProp("insetInput") && this.#isPanelShown()) this.adapter.setInsetInputFocus();
|
|
466
|
+
else this.adapter.setInputFocus();
|
|
467
|
+
};
|
|
468
|
+
blur = () => {
|
|
469
|
+
this.adapter.blurFocusedElement();
|
|
493
470
|
if (this.#isRangeType()) this.#setRangeInputFocus(false);
|
|
494
|
-
}
|
|
471
|
+
};
|
|
495
472
|
/** The controlled `open` turned false: clears what an uncontrolled close would */
|
|
496
|
-
handleControlledClose() {
|
|
473
|
+
handleControlledClose = () => {
|
|
497
474
|
this.#clearFocusRecords();
|
|
498
|
-
const { type } = this.
|
|
499
|
-
const { rangeInputFocus } = this.
|
|
475
|
+
const { type } = this.adapter.getProps();
|
|
476
|
+
const { rangeInputFocus } = this.adapter.getStates();
|
|
500
477
|
if (type === "dateTimeRange" && rangeInputFocus) this.#setRangeInputFocus(false);
|
|
501
|
-
}
|
|
478
|
+
};
|
|
502
479
|
/** Whether the range input other than `currentRangeInput` has been focused since the panel opened */
|
|
503
|
-
hasOtherRangeInputBeenFocused(currentRangeInput) {
|
|
480
|
+
hasOtherRangeInputBeenFocused = (currentRangeInput) => {
|
|
504
481
|
return this.getState("focusRecords")[currentRangeInput === "rangeStart" ? "rangeEnd" : "rangeStart"];
|
|
505
|
-
}
|
|
506
|
-
handleInputChange(input, e) {
|
|
482
|
+
};
|
|
483
|
+
handleInputChange = (input, e) => {
|
|
507
484
|
const result = this.#isMultiple() ? this.#parseMultipleInput(input, (part) => this.parseInput(part)) : this.parseInput(input);
|
|
508
485
|
const { value: stateValue } = this.getStates();
|
|
509
486
|
this.#updateCachedSelectedValueFromInput(input);
|
|
510
487
|
if (result && result.length || input === "") {
|
|
511
|
-
if (e
|
|
488
|
+
if (typeof e === "object" && e !== null && strings$1.CLEARBTN_CLICKED_EVENT_FLAG in e && e[strings$1.CLEARBTN_CLICKED_EVENT_FLAG] && this.isControlledComponent("value")) {
|
|
512
489
|
this.#notifyChange(result);
|
|
513
490
|
return;
|
|
514
491
|
}
|
|
@@ -517,12 +494,9 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
517
494
|
if (!this.#someDateDisabled(changedDates, result)) {
|
|
518
495
|
if (!isEqual(result, stateValue)) this.#notifyChange(result);
|
|
519
496
|
}
|
|
520
|
-
} else this.
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
* Always updates insetInputValue; inputValue and value are updated only when the text parses to a valid date.
|
|
524
|
-
*/
|
|
525
|
-
handleInsetInputChange({ insetInputStr, format, insetInputValue }) {
|
|
497
|
+
} else this.adapter.updateInputValue(input);
|
|
498
|
+
};
|
|
499
|
+
handleInsetInputChange = ({ insetInputStr, format, insetInputValue }) => {
|
|
526
500
|
const _isMultiple = this.#isMultiple();
|
|
527
501
|
const result = _isMultiple ? this.#parseMultipleInput(insetInputStr, (part) => this.parseInput(part, format)) : this.parseInput(insetInputStr, format);
|
|
528
502
|
const { value: stateValue } = this.getStates();
|
|
@@ -531,43 +505,43 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
531
505
|
const changedDates = this.#getChangedDates(result);
|
|
532
506
|
if (!this.#someDateDisabled(changedDates, result)) {
|
|
533
507
|
if (!isEqual(result, stateValue)) {
|
|
534
|
-
if (!this.
|
|
508
|
+
if (!this.isControlledComponent() && !this.#needConfirm() && this.#isValueCommittable(result)) this.adapter.updateValue(result);
|
|
535
509
|
this.#notifyChange(result);
|
|
536
510
|
}
|
|
537
511
|
const triggerInput = _isMultiple ? this.formatMultipleDates(result) : this.formatDates(result);
|
|
538
|
-
this.
|
|
512
|
+
this.adapter.updateInputValue(triggerInput);
|
|
539
513
|
}
|
|
540
514
|
}
|
|
541
|
-
this.
|
|
542
|
-
}
|
|
543
|
-
handleRangeEndTabPress() {
|
|
515
|
+
this.adapter.updateInsetInputValue(insetInputValue);
|
|
516
|
+
};
|
|
517
|
+
handleRangeEndTabPress = () => {
|
|
544
518
|
this.#setRangeInputFocus(false);
|
|
545
|
-
}
|
|
546
|
-
handleInputFocus(e, range) {
|
|
519
|
+
};
|
|
520
|
+
handleInputFocus = (e, range) => {
|
|
547
521
|
if (range && !this.#isRangeType()) return;
|
|
548
|
-
const rangeInputFocus = this.
|
|
522
|
+
const rangeInputFocus = this.adapter.getState("rangeInputFocus");
|
|
549
523
|
if (range) this.#setRangeInputFocus(range);
|
|
550
|
-
if (!range || !rangeInputFocus) this.
|
|
551
|
-
}
|
|
552
|
-
handleSetRangeFocus(rangeInputFocus) {
|
|
524
|
+
if (!range || !rangeInputFocus) this.adapter.notifyFocus(e, range);
|
|
525
|
+
};
|
|
526
|
+
handleSetRangeFocus = (rangeInputFocus) => {
|
|
553
527
|
this.#setRangeInputFocus(rangeInputFocus);
|
|
554
|
-
}
|
|
555
|
-
handleInputClear(e) {
|
|
556
|
-
this.
|
|
557
|
-
}
|
|
558
|
-
handleRangeInputClear(e) {
|
|
528
|
+
};
|
|
529
|
+
handleInputClear = (e) => {
|
|
530
|
+
this.adapter.notifyClear(e);
|
|
531
|
+
};
|
|
532
|
+
handleRangeInputClear = (e) => {
|
|
559
533
|
const value = [];
|
|
560
534
|
const inputValue = "";
|
|
561
|
-
if (!this.
|
|
535
|
+
if (!this.isControlledComponent("value")) {
|
|
562
536
|
this.#updateValueAndInput(value, true, inputValue);
|
|
563
|
-
this.
|
|
537
|
+
this.adapter.updateInsetInputValue(null);
|
|
564
538
|
this.#resetCachedSelectedValue(value);
|
|
565
539
|
}
|
|
566
540
|
this.#notifyChange(value);
|
|
567
541
|
this.#setRangeInputFocus(false);
|
|
568
|
-
this.
|
|
569
|
-
}
|
|
570
|
-
handleInputComplete(input = "") {
|
|
542
|
+
this.adapter.notifyClear(e);
|
|
543
|
+
};
|
|
544
|
+
handleInputComplete = (input = "") => {
|
|
571
545
|
let parsedResult = input ? this.#isMultiple() ? this.#parseMultipleInput(input, (part) => this.parseInput(part), { needDedupe: true }) : this.parseInput(input) : [];
|
|
572
546
|
parsedResult = parsedResult && parsedResult.length ? parsedResult : this.getState("value");
|
|
573
547
|
if (!(this.#isRangeType() ? input.split(this.getProp("rangeSeparator")).every((part) => !part.trim()) : !input.trim()) && !parsedResult?.length) return;
|
|
@@ -585,15 +559,15 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
585
559
|
this.#updateValueAndInput(parsedResult);
|
|
586
560
|
const changedDates = this.#getChangedDates(parsedResult);
|
|
587
561
|
if (!this.#someDateDisabled(changedDates, parsedResult) && !isEqual(parsedResult, stateValue)) this.#notifyChange(parsedResult);
|
|
588
|
-
}
|
|
562
|
+
};
|
|
589
563
|
/**
|
|
590
564
|
* @param options `rangeInputFocus` is the range input the dates were picked for, when the panel has moved
|
|
591
565
|
* the focus on before telling about the change
|
|
592
566
|
*/
|
|
593
|
-
handleSelectedChange(value, options) {
|
|
594
|
-
const { type, format, rangeSeparator, insetInput } = this.
|
|
567
|
+
handleSelectedChange = (value, options) => {
|
|
568
|
+
const { type, format, rangeSeparator, insetInput } = this.adapter.getProps();
|
|
595
569
|
const { value: stateValue } = this.getStates();
|
|
596
|
-
const controlled = this.
|
|
570
|
+
const controlled = this.isControlledComponent();
|
|
597
571
|
const closePanel = options?.closePanel ?? true;
|
|
598
572
|
const needCheckFocusRecord = options?.needCheckFocusRecord ?? true;
|
|
599
573
|
const dates = Array.isArray(value) ? [...value] : value ? [value] : [];
|
|
@@ -615,20 +589,20 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
615
589
|
});
|
|
616
590
|
}
|
|
617
591
|
if (this.#isRangeType() && !isRangeValueComplete(dates)) {
|
|
618
|
-
this.
|
|
619
|
-
this.
|
|
592
|
+
this.adapter.updateInputValue(inputValue);
|
|
593
|
+
this.adapter.updateInsetInputValue(insetInputValue);
|
|
620
594
|
return;
|
|
621
595
|
} else if (!controlled) {
|
|
622
596
|
this.#updateValueAndInput(dates, true, inputValue);
|
|
623
|
-
this.
|
|
597
|
+
this.adapter.updateInsetInputValue(insetInputValue);
|
|
624
598
|
}
|
|
625
599
|
if (!isEqual(value, stateValue)) this.#notifyChange(value);
|
|
626
600
|
}
|
|
627
601
|
const { rangeStart, rangeEnd } = this.getState("focusRecords");
|
|
628
602
|
const focusRecordChecked = !needCheckFocusRecord || rangeStart && rangeEnd;
|
|
629
603
|
if (type === "date" && !this.#isMultiple() && closePanel || type === "dateRange" && isRangeValueComplete(dates) && closePanel && focusRecordChecked) this.closePanel();
|
|
630
|
-
}
|
|
631
|
-
handleYMSelectedChange({ currentMonth, currentYear } = {}) {
|
|
604
|
+
};
|
|
605
|
+
handleYMSelectedChange = ({ currentMonth, currentYear } = {}) => {
|
|
632
606
|
const { type } = this.getProps();
|
|
633
607
|
if (type === "year") this.handleSelectedChange([new Date(currentYear["left"], 0)]);
|
|
634
608
|
else if (type === "month") {
|
|
@@ -639,25 +613,25 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
639
613
|
const dateRight = new Date(currentYear["right"], currentMonth["right"] - 1);
|
|
640
614
|
this.handleSelectedChange([dateLeft, dateRight]);
|
|
641
615
|
}
|
|
642
|
-
}
|
|
643
|
-
handleConfirm() {
|
|
644
|
-
const { cachedSelectedValue, value } = this.
|
|
616
|
+
};
|
|
617
|
+
handleConfirm = () => {
|
|
618
|
+
const { cachedSelectedValue, value } = this.adapter.getStates();
|
|
645
619
|
const isComplete = this.#isRangeType() ? isRangeValueComplete(cachedSelectedValue) : !cachedSelectedValue.some((date) => date == null);
|
|
646
620
|
const newValue = isComplete ? cachedSelectedValue : value;
|
|
647
|
-
if (this.#needConfirm() && !this.
|
|
621
|
+
if (this.#needConfirm() && !this.isControlledComponent()) this.adapter.updateValue(newValue);
|
|
648
622
|
this.closePanel();
|
|
649
623
|
if (isComplete) {
|
|
650
624
|
const { notifyValue, notifyDate } = this.disposeCallbackArgs(cachedSelectedValue);
|
|
651
|
-
this.
|
|
625
|
+
this.adapter.notifyConfirm(notifyDate, notifyValue);
|
|
652
626
|
}
|
|
653
|
-
}
|
|
654
|
-
handleCancel() {
|
|
627
|
+
};
|
|
628
|
+
handleCancel = () => {
|
|
655
629
|
this.closePanel();
|
|
656
630
|
const value = this.getState("value");
|
|
657
631
|
const { notifyValue, notifyDate } = this.disposeCallbackArgs(value);
|
|
658
|
-
this.
|
|
659
|
-
}
|
|
660
|
-
handlePresetClick(item, e) {
|
|
632
|
+
this.adapter.notifyCancel(notifyDate, notifyValue);
|
|
633
|
+
};
|
|
634
|
+
handlePresetClick = (item, e) => {
|
|
661
635
|
const { type, timeZone } = this.getProps();
|
|
662
636
|
const start = typeof item.start === "function" ? item.start() : item.start;
|
|
663
637
|
const end = typeof item.end === "function" ? item.end() : item.end;
|
|
@@ -681,25 +655,24 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
681
655
|
value = this.parseWithTimezone([start, end], timeZone);
|
|
682
656
|
this.handleSelectedChange(value, { needCheckFocusRecord: false });
|
|
683
657
|
}
|
|
684
|
-
this.
|
|
685
|
-
}
|
|
686
|
-
disabledDisposeDate(date, ...rest) {
|
|
658
|
+
this.adapter.notifyPresetsClick(item, e);
|
|
659
|
+
};
|
|
660
|
+
disabledDisposeDate = (date, ...rest) => {
|
|
687
661
|
return DatePickerFoundation.disposeDateFn(this.getProp("timeZone"), this.getProp("disabledDate"), date, ...rest);
|
|
688
|
-
}
|
|
689
|
-
disabledDisposeTime(date, ...rest) {
|
|
662
|
+
};
|
|
663
|
+
disabledDisposeTime = (date, ...rest) => {
|
|
690
664
|
return DatePickerFoundation.disposeDateFn(this.getProp("timeZone"), this.getProp("disabledTime"), date, ...rest);
|
|
691
|
-
}
|
|
665
|
+
};
|
|
692
666
|
/**
|
|
693
|
-
* Opens the panel on trigger click and, for range types, focuses rangeStart when no range input is focused.
|
|
694
667
|
* Non-range triggers are native inputs that already handle focus. isEventTarget tells a click on the input
|
|
695
668
|
* wrapper itself from one bubbled up from a child, which already handled focus.
|
|
696
669
|
*/
|
|
697
670
|
handleTriggerWrapperClick(e) {
|
|
698
|
-
const { disabled, triggerRender } = this.
|
|
699
|
-
const { rangeInputFocus } = this.
|
|
671
|
+
const { disabled, triggerRender } = this.adapter.getProps();
|
|
672
|
+
const { rangeInputFocus } = this.adapter.getStates();
|
|
700
673
|
if (disabled) return;
|
|
701
674
|
if (this.#isRangeType() && !rangeInputFocus) {
|
|
702
|
-
if (this.
|
|
675
|
+
if (this.adapter.isEventTarget(e)) this.handleInputFocus(e, "rangeStart");
|
|
703
676
|
else if (typeof triggerRender === "function") this.#setRangeInputFocus("rangeStart");
|
|
704
677
|
this.#openPanel();
|
|
705
678
|
} else this.#openPanel();
|
|
@@ -711,26 +684,26 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
711
684
|
* control that must not open it stops propagation itself). Keys reach handleTriggerWrapperClick through
|
|
712
685
|
* handleTriggerKeyDown instead, so the check stays out of it.
|
|
713
686
|
*/
|
|
714
|
-
handleTriggerClick(e, isCustomTrigger) {
|
|
687
|
+
handleTriggerClick = (e, isCustomTrigger) => {
|
|
715
688
|
if (isCustomTrigger || !isInnerControlActivation(e)) this.handleTriggerWrapperClick(e);
|
|
716
|
-
}
|
|
689
|
+
};
|
|
717
690
|
/**
|
|
718
691
|
* APG combobox: Down Arrow on the closed trigger opens the panel (once it is open, the Popover moves focus into
|
|
719
692
|
* it). A custom trigger that is itself the Tab stop is a button, so Enter and Space open it too.
|
|
720
693
|
*/
|
|
721
|
-
handleTriggerKeyDown(e, isTriggerButton) {
|
|
722
|
-
const open = this.
|
|
694
|
+
handleTriggerKeyDown = (e, isTriggerButton) => {
|
|
695
|
+
const open = this.isControlledComponent("open") ? this.getProp("open") : this.getState("panelShow");
|
|
723
696
|
const opens = e.key === "ArrowDown" || isTriggerButton && (e.key === "Enter" || e.key === " ");
|
|
724
697
|
if (!open && opens) {
|
|
725
698
|
e.preventDefault();
|
|
726
699
|
this.handleTriggerWrapperClick(e);
|
|
727
700
|
}
|
|
728
|
-
}
|
|
729
|
-
handlePanelVisibleChange(visible) {
|
|
701
|
+
};
|
|
702
|
+
handlePanelVisibleChange = (visible) => {
|
|
730
703
|
if (visible) {
|
|
731
|
-
if (this.getProp("insetInput")) this.
|
|
732
|
-
this.
|
|
733
|
-
} else this.
|
|
734
|
-
}
|
|
704
|
+
if (this.getProp("insetInput")) this.adapter.setInsetInputFocus();
|
|
705
|
+
this.adapter.setTriggerDisabled(true);
|
|
706
|
+
} else this.adapter.setTriggerDisabled(false);
|
|
707
|
+
};
|
|
735
708
|
};
|
|
736
709
|
export { DatePickerFoundation as default };
|
|
@@ -3,7 +3,6 @@ import { Locale } from "../locale/interface.js";
|
|
|
3
3
|
import { strings } from "./constants.js";
|
|
4
4
|
import { BaseValueType, ValidateStatus, ValueType } from "./foundation.js";
|
|
5
5
|
export type Type = 'date' | 'dateRange' | 'year' | 'month' | 'dateTime' | 'dateTimeRange' | 'monthRange';
|
|
6
|
-
/** The range input, start or end, that a focus or a value belongs to */
|
|
7
6
|
export type RangeInput = 'rangeStart' | 'rangeEnd';
|
|
8
7
|
export type PanelType = 'left' | 'right';
|
|
9
8
|
export interface DateInputEventHandlerProps {
|
|
@@ -42,10 +41,7 @@ export interface DateInputFoundationProps extends DateInputElementProps, DateInp
|
|
|
42
41
|
validateStatus?: ValidateStatus;
|
|
43
42
|
prefixCls?: string;
|
|
44
43
|
rangeSeparator?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Only for UI render. Keep `semi-foundation` framework-agnostic (no React types).
|
|
47
|
-
* `semi-ui-react` layer should declare this as `React.ReactNode`.
|
|
48
|
-
*/
|
|
44
|
+
/** `any` keeps the foundation framework-agnostic; each framework package declares its own node type */
|
|
49
45
|
rangeSeparatorNode?: any;
|
|
50
46
|
panelType?: PanelType;
|
|
51
47
|
insetInput?: boolean | InsetInputProps;
|
|
@@ -88,9 +84,7 @@ export interface DateInputAdapter extends DefaultAdapter<DateInputFoundationProp
|
|
|
88
84
|
type InputProps = Pick<DateInputFoundationProps, 'type' | 'format' | 'rangeSeparator' | 'dateFnsLocale'>;
|
|
89
85
|
export default class InputFoundation extends BaseFoundation<DateInputAdapter, DateInputFoundationProps, Record<string, never>> {
|
|
90
86
|
#private;
|
|
91
|
-
/** The text the trigger input shows for `value` */
|
|
92
87
|
static formatShowText({ type, dateFnsLocale, format, rangeSeparator }: InputProps, value: BaseValueType[], customFormat?: string): string;
|
|
93
|
-
/** The trigger text: the text being typed, else `value` formatted */
|
|
94
88
|
static getShowText(props: InputProps & {
|
|
95
89
|
inputValue?: string | null;
|
|
96
90
|
value?: BaseValueType[];
|
|
@@ -130,15 +124,15 @@ export default class InputFoundation extends BaseFoundation<DateInputAdapter, Da
|
|
|
130
124
|
static concatInsetInputValue(props: InputProps, { insetInputValue }: {
|
|
131
125
|
insetInputValue: InsetInputValue;
|
|
132
126
|
}): string;
|
|
133
|
-
handleChange(value: string, e: unknown)
|
|
134
|
-
handleInputComplete(e:
|
|
135
|
-
handleInputClear(e: unknown)
|
|
127
|
+
handleChange: (value: string, e: unknown) => void;
|
|
128
|
+
handleInputComplete: (e: Pick<KeyboardEvent, "key" | "target">) => void;
|
|
129
|
+
handleInputClear: (e: unknown) => void;
|
|
136
130
|
handleRangeInputClear(e: Pick<Event, 'stopPropagation'>): void;
|
|
137
|
-
handleRangeInputClearClick(e: Pick<MouseEvent,
|
|
138
|
-
handleRangeInputClearMouseDown(e: Pick<MouseEvent,
|
|
139
|
-
handleRangeInputEnterPress(e: Pick<KeyboardEvent,
|
|
140
|
-
handleRangeInputEndKeyPress(e: Pick<KeyboardEvent,
|
|
141
|
-
handleRangeInputFocus(e: unknown, rangeType: RangeInput)
|
|
142
|
-
handleInsetInputChange({ value, panel, field, insetInputValue }: InsetInputChangeFoundationProps)
|
|
131
|
+
handleRangeInputClearClick: (e: Pick<MouseEvent, "detail" | "stopPropagation">) => void;
|
|
132
|
+
handleRangeInputClearMouseDown: (e: Pick<MouseEvent, "button" | "preventDefault" | "stopPropagation">) => void;
|
|
133
|
+
handleRangeInputEnterPress: (e: Pick<KeyboardEvent, "key">, rangeInputValue: string) => void;
|
|
134
|
+
handleRangeInputEndKeyPress: (e: Pick<KeyboardEvent, "key">) => void;
|
|
135
|
+
handleRangeInputFocus: (e: unknown, rangeType: RangeInput) => void;
|
|
136
|
+
handleInsetInputChange: ({ value, panel, field, insetInputValue }: InsetInputChangeFoundationProps) => void;
|
|
143
137
|
}
|
|
144
138
|
export {};
|