* fix(data-table): type DataTableRowId as "any" #530

Fixes #530

* fix(tree-view): make first node focusable if activeId does not match selected

* fix(overflow-menu): set type="button" to prevent default submit behavior #554

Fixes #554

* fix(overflow-menu): update semantic attributes in OverflowMenuItem

* fix(number-input): do not dispatch change event on initialization #561

Fixes #561

* fix(tree-view): make first focusable node tabbable regardless of active/selected states

* fix(date-picker): load rangePlugin dynamically

* build(rollup): enable inlineDynamicImports

* build(rollup): remove "clipboard-copy" global

* fix(overflow-menu): do not render title if using a slot #537

Fixes #537

* fix(select): forward missing focus, input events #501

Fixes #501
This commit is contained in:
Eric Liu 2021-07-14 13:48:23 -07:00 committed by GitHub
commit a1e56bd135
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 79 additions and 66 deletions

View file

@ -128,43 +128,43 @@
},
});
async function initCalendar() {
calendar = await createCalendar({
options: {
appendTo: datePickerRef,
dateFormat,
defaultDate: $inputValue,
locale,
maxDate,
minDate,
mode: $mode,
},
base: inputRef,
input: inputRefTo,
dispatch: (event) => {
const detail = { selectedDates: calendar.selectedDates };
if ($range) {
const from = inputRef.value;
const to = inputRefTo.value;
detail.dateStr = {
from: inputRef.value,
to: inputRefTo.value,
};
valueFrom = from;
valueTo = to;
} else {
detail.dateStr = inputRef.value;
}
return dispatch(event, detail);
},
});
}
afterUpdate(() => {
if ($hasCalendar && !calendar) {
calendar = createCalendar({
options: {
appendTo: datePickerRef,
dateFormat,
defaultDate: $inputValue,
locale,
maxDate,
minDate,
mode: $mode,
},
base: inputRef,
input: inputRefTo,
dispatch: (event) => {
const detail = { selectedDates: calendar.selectedDates };
if ($range) {
const from = inputRef.value;
const to = inputRefTo.value;
detail.dateStr = {
from: inputRef.value,
to: inputRefTo.value,
};
valueFrom = from;
valueTo = to;
} else {
detail.dateStr = inputRef.value;
}
return dispatch(event, detail);
},
});
}
if (calendar) {
if ($range) {
calendar.setDate([$inputValueFrom, $inputValueTo]);
@ -189,6 +189,7 @@
$: valueFrom = $inputValueFrom;
$: inputValueTo.set(valueTo);
$: valueTo = $inputValueTo;
$: if ($hasCalendar && !calendar && inputRef) initCalendar();
</script>
<svelte:body

View file

@ -72,9 +72,7 @@
add({ id, labelText });
onMount(() => {
declareRef({ id, ref });
});
$: if (ref) declareRef({ id, ref });
</script>
<div

View file

@ -1,5 +1,4 @@
import flatpickr from "flatpickr";
import rangePlugin from "flatpickr/dist/plugins/rangePlugin";
let l10n;
@ -48,7 +47,7 @@ function updateMonthNode(instance) {
}
}
function createCalendar({ options, base, input, dispatch }) {
async function createCalendar({ options, base, input, dispatch }) {
let locale = options.locale;
if (options.locale === "en" && l10n && l10n.en) {
@ -61,6 +60,13 @@ function createCalendar({ options, base, input, dispatch }) {
locale = l10n.en;
}
let rangePlugin;
if (options.mode === "range") {
const importee = await import("flatpickr/dist/esm/plugins/rangePlugin");
rangePlugin = importee.default;
}
return new flatpickr(base, {
...options,
allowInput: true,