@swan-io/lake 1.0.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/HISTORY.md +3 -0
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/package.json +60 -0
- package/src/components/Alert.d.ts +10 -0
- package/src/components/Alert.js +36 -0
- package/src/components/AppOpeningAnimation.d.ts +10 -0
- package/src/components/AppOpeningAnimation.js +50 -0
- package/src/components/AutoWidthImage.d.ts +8 -0
- package/src/components/AutoWidthImage.js +26 -0
- package/src/components/Avatar.d.ts +7 -0
- package/src/components/Avatar.js +42 -0
- package/src/components/BorderedButton.d.ts +16 -0
- package/src/components/BorderedButton.js +98 -0
- package/src/components/BorderedIcon.d.ts +12 -0
- package/src/components/BorderedIcon.js +25 -0
- package/src/components/BottomPanel.d.ts +9 -0
- package/src/components/BottomPanel.js +94 -0
- package/src/components/Box.d.ts +65 -0
- package/src/components/Box.js +31 -0
- package/src/components/Breadcrumbs.d.ts +18 -0
- package/src/components/Breadcrumbs.js +362 -0
- package/src/components/Button.d.ts +15 -0
- package/src/components/Button.js +83 -0
- package/src/components/Caption.d.ts +6 -0
- package/src/components/Caption.js +11 -0
- package/src/components/Checkbox.d.ts +12 -0
- package/src/components/Checkbox.js +83 -0
- package/src/components/ChoicePicker.d.ts +11 -0
- package/src/components/ChoicePicker.js +99 -0
- package/src/components/Combobox.d.ts +29 -0
- package/src/components/Combobox.js +182 -0
- package/src/components/FailureIcon.d.ts +8 -0
- package/src/components/FailureIcon.js +4 -0
- package/src/components/FileTile.d.ts +11 -0
- package/src/components/FileTile.js +37 -0
- package/src/components/Fill.d.ts +8 -0
- package/src/components/Fill.js +24 -0
- package/src/components/FilterChooser.d.ts +15 -0
- package/src/components/FilterChooser.js +52 -0
- package/src/components/Filters.d.ts +57 -0
- package/src/components/Filters.js +229 -0
- package/src/components/FixedListView.d.ts +104 -0
- package/src/components/FixedListView.js +821 -0
- package/src/components/FixedListViewCells.d.ts +55 -0
- package/src/components/FixedListViewCells.js +157 -0
- package/src/components/Flag.d.ts +8 -0
- package/src/components/Flag.js +36 -0
- package/src/components/FlowPresentation.d.ts +12 -0
- package/src/components/FlowPresentation.js +70 -0
- package/src/components/FocusTrap.d.ts +16 -0
- package/src/components/FocusTrap.js +90 -0
- package/src/components/Form.d.ts +8 -0
- package/src/components/Form.js +17 -0
- package/src/components/FullViewportLayer.d.ts +7 -0
- package/src/components/FullViewportLayer.js +91 -0
- package/src/components/Grid.d.ts +13 -0
- package/src/components/Grid.js +33 -0
- package/src/components/Heading.d.ts +61 -0
- package/src/components/Heading.js +27 -0
- package/src/components/Icon.d.ts +191 -0
- package/src/components/Icon.js +11 -0
- package/src/components/Input.d.ts +34 -0
- package/src/components/Input.js +115 -0
- package/src/components/InputError.d.ts +8 -0
- package/src/components/InputError.js +16 -0
- package/src/components/Label.d.ts +10 -0
- package/src/components/Label.js +19 -0
- package/src/components/LakeAlert.d.ts +14 -0
- package/src/components/LakeAlert.js +75 -0
- package/src/components/LakeButton.d.ts +36 -0
- package/src/components/LakeButton.js +171 -0
- package/src/components/LakeCheckbox.d.ts +16 -0
- package/src/components/LakeCheckbox.js +54 -0
- package/src/components/LakeCombobox.d.ts +28 -0
- package/src/components/LakeCombobox.js +166 -0
- package/src/components/LakeCopyButton.d.ts +10 -0
- package/src/components/LakeCopyButton.js +16 -0
- package/src/components/LakeDownloadButton.d.ts +8 -0
- package/src/components/LakeDownloadButton.js +6 -0
- package/src/components/LakeHeading.d.ts +10 -0
- package/src/components/LakeHeading.js +19 -0
- package/src/components/LakeLabel.d.ts +19 -0
- package/src/components/LakeLabel.js +43 -0
- package/src/components/LakeModal.d.ts +14 -0
- package/src/components/LakeModal.js +132 -0
- package/src/components/LakeRadio.d.ts +9 -0
- package/src/components/LakeRadio.js +44 -0
- package/src/components/LakeScrollView.d.ts +10 -0
- package/src/components/LakeScrollView.js +35 -0
- package/src/components/LakeSearchField.d.ts +10 -0
- package/src/components/LakeSearchField.js +111 -0
- package/src/components/LakeSelect.d.ts +30 -0
- package/src/components/LakeSelect.js +183 -0
- package/src/components/LakeSlider.d.ts +12 -0
- package/src/components/LakeSlider.js +31 -0
- package/src/components/LakeStepper.d.ts +21 -0
- package/src/components/LakeStepper.js +134 -0
- package/src/components/LakeText.d.ts +19 -0
- package/src/components/LakeText.js +20 -0
- package/src/components/LakeTextInput.d.ts +36 -0
- package/src/components/LakeTextInput.js +154 -0
- package/src/components/LakeTooltip.d.ts +24 -0
- package/src/components/LakeTooltip.js +188 -0
- package/src/components/Link.d.ts +138 -0
- package/src/components/Link.js +23 -0
- package/src/components/ListRightPanel.d.ts +17 -0
- package/src/components/ListRightPanel.js +79 -0
- package/src/components/LoadingView.d.ts +9 -0
- package/src/components/LoadingView.js +24 -0
- package/src/components/Modal.d.ts +12 -0
- package/src/components/Modal.js +80 -0
- package/src/components/MultiSelect.d.ts +27 -0
- package/src/components/MultiSelect.js +223 -0
- package/src/components/MultilineInput.d.ts +15 -0
- package/src/components/MultilineInput.js +55 -0
- package/src/components/Picker.d.ts +26 -0
- package/src/components/Picker.js +116 -0
- package/src/components/PlainListView.d.ts +36 -0
- package/src/components/PlainListView.js +208 -0
- package/src/components/Popover.d.ts +23 -0
- package/src/components/Popover.js +147 -0
- package/src/components/PopoverContent.d.ts +8 -0
- package/src/components/PopoverContent.js +9 -0
- package/src/components/Portal.d.ts +7 -0
- package/src/components/Portal.js +9 -0
- package/src/components/Pressable.d.ts +348 -0
- package/src/components/Pressable.js +91 -0
- package/src/components/ProgressBar.d.ts +11 -0
- package/src/components/ProgressBar.js +46 -0
- package/src/components/ProjectEnvTag.d.ts +7 -0
- package/src/components/ProjectEnvTag.js +12 -0
- package/src/components/QuickActions.d.ts +15 -0
- package/src/components/QuickActions.js +38 -0
- package/src/components/RadioGroup.d.ts +16 -0
- package/src/components/RadioGroup.js +34 -0
- package/src/components/ReadOnlyFieldList.d.ts +6 -0
- package/src/components/ReadOnlyFieldList.js +8 -0
- package/src/components/ResponsiveContainer.d.ts +13 -0
- package/src/components/ResponsiveContainer.js +23 -0
- package/src/components/RightPanel.d.ts +10 -0
- package/src/components/RightPanel.js +102 -0
- package/src/components/SegmentedControl.d.ts +19 -0
- package/src/components/SegmentedControl.js +74 -0
- package/src/components/Separator.d.ts +10 -0
- package/src/components/Separator.js +19 -0
- package/src/components/SidebarNavigationTracker.d.ts +13 -0
- package/src/components/SidebarNavigationTracker.js +93 -0
- package/src/components/Slider.d.ts +11 -0
- package/src/components/Slider.js +119 -0
- package/src/components/SmsOpeningAnimation.d.ts +8 -0
- package/src/components/SmsOpeningAnimation.js +52 -0
- package/src/components/Space.d.ts +10 -0
- package/src/components/Space.js +23 -0
- package/src/components/Stack.d.ts +12 -0
- package/src/components/Stack.js +23 -0
- package/src/components/StepDots.d.ts +7 -0
- package/src/components/StepDots.js +24 -0
- package/src/components/Stepper.d.ts +9 -0
- package/src/components/Stepper.js +67 -0
- package/src/components/SuccessIcon.d.ts +8 -0
- package/src/components/SuccessIcon.js +4 -0
- package/src/components/Svg.d.ts +145 -0
- package/src/components/Svg.js +24 -0
- package/src/components/SwanLogo.d.ts +8 -0
- package/src/components/SwanLogo.js +11 -0
- package/src/components/Switch.d.ts +9 -0
- package/src/components/Switch.js +74 -0
- package/src/components/TabView.d.ts +16 -0
- package/src/components/TabView.js +398 -0
- package/src/components/Table.d.ts +34 -0
- package/src/components/Table.js +79 -0
- package/src/components/Tag.d.ts +17 -0
- package/src/components/Tag.js +76 -0
- package/src/components/Tile.d.ts +34 -0
- package/src/components/Tile.js +130 -0
- package/src/components/TilePlaceholder.d.ts +6 -0
- package/src/components/TilePlaceholder.js +51 -0
- package/src/components/ToastStack.d.ts +2 -0
- package/src/components/ToastStack.js +96 -0
- package/src/components/Tooltip.d.ts +18 -0
- package/src/components/Tooltip.js +162 -0
- package/src/components/TransitionGroupView.d.ts +12 -0
- package/src/components/TransitionGroupView.js +43 -0
- package/src/components/TransitionView.d.ts +12 -0
- package/src/components/TransitionView.js +43 -0
- package/src/components/WithCurrentColor.d.ts +12 -0
- package/src/components/WithCurrentColor.js +65 -0
- package/src/components/WithPartnerAccentColor.d.ts +7 -0
- package/src/components/WithPartnerAccentColor.js +91 -0
- package/src/constants/colors.d.ts +42 -0
- package/src/constants/colors.js +42 -0
- package/src/constants/commonStyles.d.ts +66 -0
- package/src/constants/commonStyles.js +45 -0
- package/src/constants/design.d.ts +168 -0
- package/src/constants/design.js +564 -0
- package/src/constants/insets.d.ts +10 -0
- package/src/constants/insets.js +22 -0
- package/src/constants/typography.d.ts +26 -0
- package/src/constants/typography.js +54 -0
- package/src/hooks/useAnimatedValue.d.ts +2 -0
- package/src/hooks/useAnimatedValue.js +3 -0
- package/src/hooks/useBodyClassName.d.ts +3 -0
- package/src/hooks/useBodyClassName.js +14 -0
- package/src/hooks/useBoolean.d.ts +8 -0
- package/src/hooks/useBoolean.js +12 -0
- package/src/hooks/useComputedColors.d.ts +10 -0
- package/src/hooks/useComputedColors.js +42 -0
- package/src/hooks/useDebounce.d.ts +1 -0
- package/src/hooks/useDebounce.js +12 -0
- package/src/hooks/useDisclosure.d.ts +8 -0
- package/src/hooks/useDisclosure.js +12 -0
- package/src/hooks/useFirstMountState.d.ts +1 -0
- package/src/hooks/useFirstMountState.js +9 -0
- package/src/hooks/useForceableState.d.ts +1 -0
- package/src/hooks/useForceableState.js +6 -0
- package/src/hooks/useHover.d.ts +11 -0
- package/src/hooks/useHover.js +4 -0
- package/src/hooks/useInterval.d.ts +1 -0
- package/src/hooks/useInterval.js +11 -0
- package/src/hooks/useLazyRef.d.ts +2 -0
- package/src/hooks/useLazyRef.js +9 -0
- package/src/hooks/useMergeRefs.d.ts +2 -0
- package/src/hooks/useMergeRefs.js +5 -0
- package/src/hooks/useNativeProp.d.ts +2 -0
- package/src/hooks/useNativeProp.js +9 -0
- package/src/hooks/useOutsideClick.d.ts +8 -0
- package/src/hooks/useOutsideClick.js +54 -0
- package/src/hooks/usePersistedState.d.ts +1 -0
- package/src/hooks/usePersistedState.js +21 -0
- package/src/hooks/usePressEvents.d.ts +31 -0
- package/src/hooks/usePressEvents.js +4 -0
- package/src/hooks/usePreviousValue.d.ts +1 -0
- package/src/hooks/usePreviousValue.js +8 -0
- package/src/hooks/useResponsive.d.ts +7 -0
- package/src/hooks/useResponsive.js +20 -0
- package/src/hooks/useUpdateEffect.d.ts +2 -0
- package/src/hooks/useUpdateEffect.js +10 -0
- package/src/hooks/useUrqlMutation.d.ts +4 -0
- package/src/hooks/useUrqlMutation.js +30 -0
- package/src/hooks/useUrqlQuery.d.ts +19 -0
- package/src/hooks/useUrqlQuery.js +73 -0
- package/src/state/toasts.d.ts +21 -0
- package/src/state/toasts.js +61 -0
- package/src/utils/__tests__/array.test.d.ts +1 -0
- package/src/utils/__tests__/array.test.js +127 -0
- package/src/utils/__tests__/base64.test.d.ts +1 -0
- package/src/utils/__tests__/base64.test.js +27 -0
- package/src/utils/__tests__/function.test.d.ts +1 -0
- package/src/utils/__tests__/function.test.js +36 -0
- package/src/utils/__tests__/object.test.d.ts +1 -0
- package/src/utils/__tests__/object.test.js +17 -0
- package/src/utils/__tests__/rifm.test.d.ts +1 -0
- package/src/utils/__tests__/rifm.test.js +124 -0
- package/src/utils/__tests__/string.test.d.ts +1 -0
- package/src/utils/__tests__/string.test.js +16 -0
- package/src/utils/a11y.d.ts +1 -0
- package/src/utils/a11y.js +18 -0
- package/src/utils/array.d.ts +6 -0
- package/src/utils/array.js +71 -0
- package/src/utils/base64.d.ts +2 -0
- package/src/utils/base64.js +20 -0
- package/src/utils/file.d.ts +2 -0
- package/src/utils/file.js +10 -0
- package/src/utils/flagCountry.d.ts +1 -0
- package/src/utils/flagCountry.js +1 -0
- package/src/utils/function.d.ts +4 -0
- package/src/utils/function.js +19 -0
- package/src/utils/math.d.ts +16 -0
- package/src/utils/math.js +47 -0
- package/src/utils/nullish.d.ts +10 -0
- package/src/utils/nullish.js +8 -0
- package/src/utils/object.d.ts +2 -0
- package/src/utils/object.js +7 -0
- package/src/utils/popper.d.ts +3 -0
- package/src/utils/popper.js +30 -0
- package/src/utils/rifm.d.ts +14 -0
- package/src/utils/rifm.js +53 -0
- package/src/utils/string.d.ts +4 -0
- package/src/utils/string.js +233 -0
- package/src/utils/timer.d.ts +11 -0
- package/src/utils/timer.js +46 -0
- package/src/utils/types.d.ts +8 -0
- package/src/utils/types.js +1 -0
- package/src/utils/userAgent.d.ts +4 -0
- package/src/utils/userAgent.js +9 -0
- package/src/utils/viewport.d.ts +1 -0
- package/src/utils/viewport.js +12 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const getRootElement = (element) => {
|
|
2
|
+
let current = element;
|
|
3
|
+
while (current) {
|
|
4
|
+
const { parentElement: parent } = current;
|
|
5
|
+
if (!parent) {
|
|
6
|
+
break;
|
|
7
|
+
}
|
|
8
|
+
if (parent === document.body || parent.matches("[aria-modal=true]")) {
|
|
9
|
+
return current;
|
|
10
|
+
}
|
|
11
|
+
current = parent;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
export const matchReferenceWidthModifier = {
|
|
16
|
+
name: "matchReferenceWidth",
|
|
17
|
+
requires: ["computeStyles"],
|
|
18
|
+
enabled: false,
|
|
19
|
+
phase: "beforeWrite",
|
|
20
|
+
fn({ state }) {
|
|
21
|
+
if (state.styles.popper) {
|
|
22
|
+
state.styles.popper.width = state.rects.reference.width.toString() + "px";
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
effect({ state }) {
|
|
26
|
+
if (state.elements.reference instanceof HTMLElement) {
|
|
27
|
+
state.elements.popper.style.width = state.elements.reference.offsetWidth.toString() + "px";
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { Rifm } from "rifm";
|
|
3
|
+
export type Props = Required<Pick<ComponentProps<typeof Rifm>, "accept" | "append" | "format" | "mask">>;
|
|
4
|
+
declare const accepted: {
|
|
5
|
+
alpha: RegExp;
|
|
6
|
+
numeric: RegExp;
|
|
7
|
+
alphanumeric: RegExp;
|
|
8
|
+
};
|
|
9
|
+
export declare const getRifmProps: ({ accept, charMap, maxLength, }: {
|
|
10
|
+
accept: keyof typeof accepted;
|
|
11
|
+
maxLength: number;
|
|
12
|
+
charMap: Record<number, string>;
|
|
13
|
+
}) => Props;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isNotNullish, isNullish } from "./nullish";
|
|
2
|
+
const accepted = {
|
|
3
|
+
alpha: /[a-z]/gi,
|
|
4
|
+
numeric: /\d+/g,
|
|
5
|
+
alphanumeric: /[a-z\d]+/gi,
|
|
6
|
+
};
|
|
7
|
+
export const getRifmProps = ({ accept, charMap, maxLength, }) => {
|
|
8
|
+
const charIndexes = Object.keys(charMap).map(Number);
|
|
9
|
+
if (process.env.NODE_ENV === "development") {
|
|
10
|
+
const maxCharIndex = maxLength - 1;
|
|
11
|
+
charIndexes.forEach(charMapIndex => {
|
|
12
|
+
const char = charMap[charMapIndex];
|
|
13
|
+
if (isNullish(char)) {
|
|
14
|
+
throw new Error(`Invalid mask character value`);
|
|
15
|
+
}
|
|
16
|
+
if (char.length !== 1) {
|
|
17
|
+
throw new Error(`Invalid mask character value: "${char}"`);
|
|
18
|
+
}
|
|
19
|
+
if (charMapIndex > maxCharIndex) {
|
|
20
|
+
throw new Error(`Invalid mask character index: "${charMapIndex}"`);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const maxFormattedLength = maxLength + charIndexes.length;
|
|
25
|
+
const regExp = accepted[accept];
|
|
26
|
+
const shiftedCharMap = charIndexes.reduce((acc, charIndex, index) => {
|
|
27
|
+
const char = charMap[charIndex] ?? "";
|
|
28
|
+
return { ...acc, [charIndex + index]: char };
|
|
29
|
+
}, {});
|
|
30
|
+
const shiftedCharIndexes = Object.keys(shiftedCharMap).map(Number);
|
|
31
|
+
return {
|
|
32
|
+
accept: regExp,
|
|
33
|
+
mask: false,
|
|
34
|
+
append: (str) => {
|
|
35
|
+
const right = shiftedCharIndexes.includes(str.length) ? shiftedCharMap[str.length] : "";
|
|
36
|
+
return str + (right ?? "");
|
|
37
|
+
},
|
|
38
|
+
format: (str) => {
|
|
39
|
+
const chars = (str.match(regExp) ?? []).join("").split("");
|
|
40
|
+
const res = chars
|
|
41
|
+
.reduce((acc, char, index) => {
|
|
42
|
+
const center = charIndexes.includes(index) ? charMap[index] : "";
|
|
43
|
+
return acc + (center ?? "") + char;
|
|
44
|
+
}, "")
|
|
45
|
+
.substr(0, maxFormattedLength);
|
|
46
|
+
const char = shiftedCharMap[res.length];
|
|
47
|
+
return (res +
|
|
48
|
+
(isNotNullish(char) && str.endsWith(char) && shiftedCharIndexes.includes(res.length)
|
|
49
|
+
? char
|
|
50
|
+
: ""));
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
export const safeSplitAround = (string, expression) => {
|
|
2
|
+
let index = 0;
|
|
3
|
+
const splitString = [];
|
|
4
|
+
while (index < string.length) {
|
|
5
|
+
const nextIndexOfExpression = string.indexOf(expression, index);
|
|
6
|
+
if (nextIndexOfExpression === -1) {
|
|
7
|
+
splitString.push(string.slice(index));
|
|
8
|
+
return splitString;
|
|
9
|
+
}
|
|
10
|
+
if (nextIndexOfExpression > index) {
|
|
11
|
+
const endIndex = nextIndexOfExpression + expression.length;
|
|
12
|
+
splitString.push(string.slice(index, nextIndexOfExpression), string.slice(nextIndexOfExpression, endIndex));
|
|
13
|
+
index = endIndex;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (nextIndexOfExpression === index) {
|
|
17
|
+
const endIndex = nextIndexOfExpression + expression.length;
|
|
18
|
+
splitString.push(string.slice(nextIndexOfExpression, endIndex));
|
|
19
|
+
index = endIndex;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
return splitString;
|
|
23
|
+
}
|
|
24
|
+
return splitString;
|
|
25
|
+
};
|
|
26
|
+
/** Used to map Latin Unicode letters to basic Latin letters. */
|
|
27
|
+
const deburredLetters = {
|
|
28
|
+
// Latin-1 Supplement block.
|
|
29
|
+
"\xc0": "A",
|
|
30
|
+
"\xc1": "A",
|
|
31
|
+
"\xc2": "A",
|
|
32
|
+
"\xc3": "A",
|
|
33
|
+
"\xc4": "A",
|
|
34
|
+
"\xc5": "A",
|
|
35
|
+
"\xe0": "a",
|
|
36
|
+
"\xe1": "a",
|
|
37
|
+
"\xe2": "a",
|
|
38
|
+
"\xe3": "a",
|
|
39
|
+
"\xe4": "a",
|
|
40
|
+
"\xe5": "a",
|
|
41
|
+
"\xc7": "C",
|
|
42
|
+
"\xe7": "c",
|
|
43
|
+
"\xd0": "D",
|
|
44
|
+
"\xf0": "d",
|
|
45
|
+
"\xc8": "E",
|
|
46
|
+
"\xc9": "E",
|
|
47
|
+
"\xca": "E",
|
|
48
|
+
"\xcb": "E",
|
|
49
|
+
"\xe8": "e",
|
|
50
|
+
"\xe9": "e",
|
|
51
|
+
"\xea": "e",
|
|
52
|
+
"\xeb": "e",
|
|
53
|
+
"\xcc": "I",
|
|
54
|
+
"\xcd": "I",
|
|
55
|
+
"\xce": "I",
|
|
56
|
+
"\xcf": "I",
|
|
57
|
+
"\xec": "i",
|
|
58
|
+
"\xed": "i",
|
|
59
|
+
"\xee": "i",
|
|
60
|
+
"\xef": "i",
|
|
61
|
+
"\xd1": "N",
|
|
62
|
+
"\xf1": "n",
|
|
63
|
+
"\xd2": "O",
|
|
64
|
+
"\xd3": "O",
|
|
65
|
+
"\xd4": "O",
|
|
66
|
+
"\xd5": "O",
|
|
67
|
+
"\xd6": "O",
|
|
68
|
+
"\xd8": "O",
|
|
69
|
+
"\xf2": "o",
|
|
70
|
+
"\xf3": "o",
|
|
71
|
+
"\xf4": "o",
|
|
72
|
+
"\xf5": "o",
|
|
73
|
+
"\xf6": "o",
|
|
74
|
+
"\xf8": "o",
|
|
75
|
+
"\xd9": "U",
|
|
76
|
+
"\xda": "U",
|
|
77
|
+
"\xdb": "U",
|
|
78
|
+
"\xdc": "U",
|
|
79
|
+
"\xf9": "u",
|
|
80
|
+
"\xfa": "u",
|
|
81
|
+
"\xfb": "u",
|
|
82
|
+
"\xfc": "u",
|
|
83
|
+
"\xdd": "Y",
|
|
84
|
+
"\xfd": "y",
|
|
85
|
+
"\xff": "y",
|
|
86
|
+
"\xc6": "Ae",
|
|
87
|
+
"\xe6": "ae",
|
|
88
|
+
"\xde": "Th",
|
|
89
|
+
"\xfe": "th",
|
|
90
|
+
"\xdf": "ss",
|
|
91
|
+
// Latin Extended-A block.
|
|
92
|
+
"\u0100": "A",
|
|
93
|
+
"\u0102": "A",
|
|
94
|
+
"\u0104": "A",
|
|
95
|
+
"\u0101": "a",
|
|
96
|
+
"\u0103": "a",
|
|
97
|
+
"\u0105": "a",
|
|
98
|
+
"\u0106": "C",
|
|
99
|
+
"\u0108": "C",
|
|
100
|
+
"\u010a": "C",
|
|
101
|
+
"\u010c": "C",
|
|
102
|
+
"\u0107": "c",
|
|
103
|
+
"\u0109": "c",
|
|
104
|
+
"\u010b": "c",
|
|
105
|
+
"\u010d": "c",
|
|
106
|
+
"\u010e": "D",
|
|
107
|
+
"\u0110": "D",
|
|
108
|
+
"\u010f": "d",
|
|
109
|
+
"\u0111": "d",
|
|
110
|
+
"\u0112": "E",
|
|
111
|
+
"\u0114": "E",
|
|
112
|
+
"\u0116": "E",
|
|
113
|
+
"\u0118": "E",
|
|
114
|
+
"\u011a": "E",
|
|
115
|
+
"\u0113": "e",
|
|
116
|
+
"\u0115": "e",
|
|
117
|
+
"\u0117": "e",
|
|
118
|
+
"\u0119": "e",
|
|
119
|
+
"\u011b": "e",
|
|
120
|
+
"\u011c": "G",
|
|
121
|
+
"\u011e": "G",
|
|
122
|
+
"\u0120": "G",
|
|
123
|
+
"\u0122": "G",
|
|
124
|
+
"\u011d": "g",
|
|
125
|
+
"\u011f": "g",
|
|
126
|
+
"\u0121": "g",
|
|
127
|
+
"\u0123": "g",
|
|
128
|
+
"\u0124": "H",
|
|
129
|
+
"\u0126": "H",
|
|
130
|
+
"\u0125": "h",
|
|
131
|
+
"\u0127": "h",
|
|
132
|
+
"\u0128": "I",
|
|
133
|
+
"\u012a": "I",
|
|
134
|
+
"\u012c": "I",
|
|
135
|
+
"\u012e": "I",
|
|
136
|
+
"\u0130": "I",
|
|
137
|
+
"\u0129": "i",
|
|
138
|
+
"\u012b": "i",
|
|
139
|
+
"\u012d": "i",
|
|
140
|
+
"\u012f": "i",
|
|
141
|
+
"\u0131": "i",
|
|
142
|
+
"\u0134": "J",
|
|
143
|
+
"\u0135": "j",
|
|
144
|
+
"\u0136": "K",
|
|
145
|
+
"\u0137": "k",
|
|
146
|
+
"\u0138": "k",
|
|
147
|
+
"\u0139": "L",
|
|
148
|
+
"\u013b": "L",
|
|
149
|
+
"\u013d": "L",
|
|
150
|
+
"\u013f": "L",
|
|
151
|
+
"\u0141": "L",
|
|
152
|
+
"\u013a": "l",
|
|
153
|
+
"\u013c": "l",
|
|
154
|
+
"\u013e": "l",
|
|
155
|
+
"\u0140": "l",
|
|
156
|
+
"\u0142": "l",
|
|
157
|
+
"\u0143": "N",
|
|
158
|
+
"\u0145": "N",
|
|
159
|
+
"\u0147": "N",
|
|
160
|
+
"\u014a": "N",
|
|
161
|
+
"\u0144": "n",
|
|
162
|
+
"\u0146": "n",
|
|
163
|
+
"\u0148": "n",
|
|
164
|
+
"\u014b": "n",
|
|
165
|
+
"\u014c": "O",
|
|
166
|
+
"\u014e": "O",
|
|
167
|
+
"\u0150": "O",
|
|
168
|
+
"\u014d": "o",
|
|
169
|
+
"\u014f": "o",
|
|
170
|
+
"\u0151": "o",
|
|
171
|
+
"\u0154": "R",
|
|
172
|
+
"\u0156": "R",
|
|
173
|
+
"\u0158": "R",
|
|
174
|
+
"\u0155": "r",
|
|
175
|
+
"\u0157": "r",
|
|
176
|
+
"\u0159": "r",
|
|
177
|
+
"\u015a": "S",
|
|
178
|
+
"\u015c": "S",
|
|
179
|
+
"\u015e": "S",
|
|
180
|
+
"\u0160": "S",
|
|
181
|
+
"\u015b": "s",
|
|
182
|
+
"\u015d": "s",
|
|
183
|
+
"\u015f": "s",
|
|
184
|
+
"\u0161": "s",
|
|
185
|
+
"\u0162": "T",
|
|
186
|
+
"\u0164": "T",
|
|
187
|
+
"\u0166": "T",
|
|
188
|
+
"\u0163": "t",
|
|
189
|
+
"\u0165": "t",
|
|
190
|
+
"\u0167": "t",
|
|
191
|
+
"\u0168": "U",
|
|
192
|
+
"\u016a": "U",
|
|
193
|
+
"\u016c": "U",
|
|
194
|
+
"\u016e": "U",
|
|
195
|
+
"\u0170": "U",
|
|
196
|
+
"\u0172": "U",
|
|
197
|
+
"\u0169": "u",
|
|
198
|
+
"\u016b": "u",
|
|
199
|
+
"\u016d": "u",
|
|
200
|
+
"\u016f": "u",
|
|
201
|
+
"\u0171": "u",
|
|
202
|
+
"\u0173": "u",
|
|
203
|
+
"\u0174": "W",
|
|
204
|
+
"\u0175": "w",
|
|
205
|
+
"\u0176": "Y",
|
|
206
|
+
"\u0177": "y",
|
|
207
|
+
"\u0178": "Y",
|
|
208
|
+
"\u0179": "Z",
|
|
209
|
+
"\u017b": "Z",
|
|
210
|
+
"\u017d": "Z",
|
|
211
|
+
"\u017a": "z",
|
|
212
|
+
"\u017c": "z",
|
|
213
|
+
"\u017e": "z",
|
|
214
|
+
"\u0132": "IJ",
|
|
215
|
+
"\u0133": "ij",
|
|
216
|
+
"\u0152": "Oe",
|
|
217
|
+
"\u0153": "oe",
|
|
218
|
+
"\u0149": "'n",
|
|
219
|
+
"\u017f": "s",
|
|
220
|
+
};
|
|
221
|
+
export const deburr = (value) => {
|
|
222
|
+
/** Used to match Latin Unicode letters (excluding mathematical operators). */
|
|
223
|
+
const reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
|
224
|
+
return value
|
|
225
|
+
.replace(reLatin, char => deburredLetters[char] ?? "")
|
|
226
|
+
.replace(/[\u0300-\u036f]/g, "");
|
|
227
|
+
};
|
|
228
|
+
export const words = (string) => {
|
|
229
|
+
return string.split(/\b/).filter(x => /^[a-zA-Z0-9]+$/.test(x));
|
|
230
|
+
};
|
|
231
|
+
export const capitalize = (string) => {
|
|
232
|
+
return `${string.charAt(0).toUpperCase()}${string.slice(1).toLowerCase()}`;
|
|
233
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ControllableTimeout = {
|
|
2
|
+
readonly duration: number;
|
|
3
|
+
readonly clear: () => void;
|
|
4
|
+
readonly reset: () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const createControllableTimeout: (config: {
|
|
7
|
+
duration: number;
|
|
8
|
+
onStart: (duration: number) => void;
|
|
9
|
+
onEnd: () => void;
|
|
10
|
+
onReset: (duration: number) => void;
|
|
11
|
+
}) => ControllableTimeout;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// based on https://gist.github.com/ncou/3a0a1f89c8e22416d0d607f621a948a9
|
|
2
|
+
export const createControllableTimeout = (config) => {
|
|
3
|
+
const { duration, onStart, onReset, onEnd } = config;
|
|
4
|
+
let timerId = 0;
|
|
5
|
+
let remaining = duration;
|
|
6
|
+
const clear = () => {
|
|
7
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
8
|
+
window.clearTimeout(timerId);
|
|
9
|
+
};
|
|
10
|
+
const start = () => {
|
|
11
|
+
if (remaining <= 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
timerId = window.setTimeout(() => {
|
|
15
|
+
remaining = 0;
|
|
16
|
+
clear();
|
|
17
|
+
onEnd();
|
|
18
|
+
}, remaining);
|
|
19
|
+
onStart(duration);
|
|
20
|
+
};
|
|
21
|
+
const reset = () => {
|
|
22
|
+
window.clearTimeout(timerId);
|
|
23
|
+
remaining = duration;
|
|
24
|
+
timerId = window.setTimeout(() => {
|
|
25
|
+
remaining = 0;
|
|
26
|
+
clear();
|
|
27
|
+
onEnd();
|
|
28
|
+
}, duration);
|
|
29
|
+
onReset(duration);
|
|
30
|
+
};
|
|
31
|
+
const onVisibilityChange = () => {
|
|
32
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
33
|
+
start();
|
|
34
|
+
};
|
|
35
|
+
if (document.hidden) {
|
|
36
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
start();
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
duration,
|
|
43
|
+
clear,
|
|
44
|
+
reset,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isNullish } from "./nullish";
|
|
2
|
+
const CHROME_REGEXP = /Chrom(e|ium)\//;
|
|
3
|
+
const MOBI_REGEXP = /Mobi/;
|
|
4
|
+
const SAFARI_REGEXP = /Safari\//;
|
|
5
|
+
export const isChrome = CHROME_REGEXP.test(navigator.userAgent);
|
|
6
|
+
export const isMobile = MOBI_REGEXP.test(navigator.userAgent);
|
|
7
|
+
export const isChromeMobile = isChrome && isMobile;
|
|
8
|
+
// https://github.com/jakearchibald/safari-14-idb-fix/blob/v3.0.0/src/index.ts#L7
|
|
9
|
+
export const isSafari = isNullish(navigator.userAgentData) && SAFARI_REGEXP.test(navigator.userAgent) && !isChrome;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const preventSafariAutoZoomOnInputs: () => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isNotNullish } from "./nullish";
|
|
2
|
+
import { isSafari } from "./userAgent";
|
|
3
|
+
// Prevents Safari from zooming automatically on inputs, still allow user to zoom manually
|
|
4
|
+
export const preventSafariAutoZoomOnInputs = () => {
|
|
5
|
+
if (isSafari) {
|
|
6
|
+
const viewport = document.querySelector("meta[name=viewport]");
|
|
7
|
+
const content = viewport?.getAttribute("content");
|
|
8
|
+
if (isNotNullish(viewport) && isNotNullish(content)) {
|
|
9
|
+
viewport.setAttribute("content", content + ", maximum-scale=1.0");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|