@koine/react 1.0.9 → 1.0.12
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/Alert/Alert.js +7 -13
- package/Animations/Reveal.js +12 -10
- package/Animations/Underline.js +3 -13
- package/Animations/useReveal.js +18 -17
- package/Autocomplete/AutocompleteDownshift.js +1 -1
- package/Autocomplete/AutocompleteDownshiftMultiselect.js +1 -1
- package/Autocomplete/AutocompleteMui.js +61 -56
- package/Autocomplete/AutocompleteReach.js +1 -1
- package/Autocomplete/components.js +17 -72
- package/Autocomplete/helpers.js +1 -1
- package/Bg/BgColor.js +14 -24
- package/Bg/BgPhoto.js +11 -54
- package/Bg/BgSvg.js +6 -9
- package/Breadcrumbs/Breadcrumbs.js +14 -54
- package/Buttons/Button.js +8 -73
- package/Buttons/ButtonComposite.js +20 -41
- package/Buttons/ButtonFab.js +4 -6
- package/Buttons/ButtonLink.js +7 -6
- package/Buttons/IconButton.js +5 -17
- package/Calendar/CalendarDaygridCell.js +20 -14
- package/Calendar/CalendarDaygridNav.js +10 -9
- package/Calendar/CalendarDaygridTable.js +32 -30
- package/Calendar/CalendarLegend.js +7 -2
- package/Calendar/calendar-api-google.js +101 -68
- package/Calendar/useCalendar.js +114 -113
- package/Calendar/utils.js +73 -74
- package/Carousel/Carousel.js +1 -1
- package/Carousel/CarouselCss.js +14 -27
- package/Collapsable/Collapsable.d.ts +1 -1
- package/Collapsable/Collapsable.js +1 -1
- package/Collapsable/CollapsableReach.d.ts +4 -64
- package/Collapsable/CollapsableReach.js +247 -129
- package/Collapsable/index.d.ts +1 -1
- package/Collapsable/index.js +2 -1
- package/Debug/Debug.js +5 -17
- package/Details/Details.d.ts +114 -0
- package/Details/Details.js +65 -0
- package/Details/index.d.ts +1 -0
- package/Details/index.js +1 -0
- package/{Forms/Form → Details}/package.json +1 -1
- package/Dialog/DialogMui.d.ts +1 -1
- package/Dialog/DialogMui.js +22 -20
- package/Dialog/css/bare.js +17 -15
- package/Dialog/m/bare.js +17 -13
- package/Dialog/m/basic.js +2 -2
- package/Dialog/m/index.js +4 -4
- package/Dialog/sc/bare.js +25 -43
- package/Dialog/sc/framer.js +6 -6
- package/Dialog/sc/framerMaterial.js +6 -6
- package/Dialog/sc/material.js +17 -37
- package/Dialog/tw/bare.js +25 -19
- package/Dialog/tw/elegant.js +17 -15
- package/Dialog/tw/framer.js +6 -6
- package/Dialog/tw/framerMaterial.js +6 -6
- package/Dialog/tw/material.js +17 -15
- package/Editor/Editor--tiptap.js +14 -11
- package/Editor/components.js +6 -24
- package/Favicon/FaviconTags.js +2 -1
- package/Form/Form.d.ts +111 -0
- package/Form/Form.js +61 -0
- package/{Forms/Form → Form}/index.d.ts +0 -0
- package/{Forms/Form → Form}/index.js +0 -0
- package/Form/package.json +6 -0
- package/Form/sc/bare.d.ts +33 -0
- package/Form/sc/bare.js +20 -0
- package/Forms/Checkbox/Checkbox.js +9 -15
- package/Forms/Feedback/Feedback.js +6 -7
- package/Forms/Field/Field.js +15 -26
- package/Forms/Field/FieldControl.js +19 -15
- package/Forms/Field/FieldHint.js +3 -5
- package/Forms/Input/Input.js +10 -16
- package/Forms/InputGroup/InputGroup.js +9 -36
- package/Forms/Label/Label.js +5 -23
- package/Forms/Password/Password.js +10 -23
- package/Forms/Radio/Radio.js +15 -18
- package/Forms/Switch/Switch.js +9 -39
- package/Forms/Textarea/Textarea.js +6 -7
- package/Forms/Textarea/TextareaRich.js +10 -24
- package/Forms/Toggle/Toggle.js +21 -68
- package/Forms/Toggle/useToggle.js +29 -29
- package/Forms/antispam.js +12 -12
- package/Forms/helpers.js +8 -7
- package/Forms/index.d.ts +0 -1
- package/Forms/index.js +0 -1
- package/Forms/styles.js +12 -43
- package/Gauge/Gauge.js +1 -1
- package/Grid/Grid.js +25 -51
- package/Hamburger/Hamburger.js +35 -47
- package/Header/useHeader.js +12 -12
- package/Hidden/Hidden.js +9 -13
- package/Img/sc/bare.js +3 -1
- package/Link/Link.js +3 -1
- package/Link/LinkBlank.js +8 -17
- package/Menu/Menu.js +3 -10
- package/MenuItem/MenuItem.js +3 -19
- package/Meta/Meta.js +3 -2
- package/NoJs/NoJs.js +2 -2
- package/Pagination/PaginationNav.js +26 -48
- package/Pagination/PaginationResults.js +7 -6
- package/Pill/Pill.js +6 -36
- package/Progress/ProgressCircular.js +9 -30
- package/Progress/ProgressLinear.js +8 -16
- package/Progress/ProgressOverlay.js +11 -27
- package/Rating/Rating.js +26 -45
- package/Rating/index.js +19 -15
- package/Select/SelectDownshift.js +1 -1
- package/Select/components.js +6 -12
- package/Sidebar/Sidebar.js +13 -38
- package/Spacing/Spacing.js +12 -12
- package/Sticky/Sticky.js +1 -1
- package/Sticky/StickyCss.js +4 -2
- package/Tabs/TabsMui.d.ts +244 -0
- package/Tabs/TabsMui.js +46 -0
- package/Tabs/index.d.ts +1 -1
- package/Tabs/index.js +1 -1
- package/Tabs/sc/bare.d.ts +5 -0
- package/Tabs/sc/bare.js +87 -0
- package/Tabs/tw/bare.d.ts +248 -0
- package/Tabs/tw/bare.js +17 -0
- package/Tabs/tw/material.d.ts +472 -0
- package/Tabs/tw/material.js +18 -0
- package/Tabs/useTabs.d.ts +43 -0
- package/Tabs/useTabs.js +44 -0
- package/Typography/CopyPasteVisible.js +3 -5
- package/Typography/Native.js +12 -45
- package/Typography/ReadMore.js +26 -52
- package/Typography/TextLoop.js +19 -22
- package/Typography/TypeStairs.js +20 -16
- package/css/index.js +1 -0
- package/helpers/classed.js +22 -18
- package/helpers/extend-component.js +6 -6
- package/hooks/index.d.ts +8 -0
- package/hooks/index.js +8 -0
- package/hooks/types.d.ts +8 -0
- package/hooks/types.js +1 -0
- package/hooks/useAsyncFn.d.ts +26 -0
- package/hooks/useAsyncFn.js +36 -0
- package/hooks/useDateLocale.js +22 -13
- package/hooks/useEffectOnce.d.ts +5 -0
- package/hooks/useEffectOnce.js +8 -0
- package/hooks/useFirstMountState.d.ts +4 -0
- package/hooks/useFirstMountState.js +12 -0
- package/hooks/useFocus.js +3 -3
- package/hooks/useId.d.ts +4 -0
- package/hooks/useId.js +8 -0
- package/hooks/useIsomorphicLayoutEffect.d.ts +5 -0
- package/hooks/useIsomorphicLayoutEffect.js +8 -0
- package/hooks/useMount.d.ts +4 -0
- package/hooks/useMount.js +9 -0
- package/hooks/useMountedState.d.ts +4 -0
- package/hooks/useMountedState.js +15 -0
- package/hooks/usePrevious.js +2 -2
- package/hooks/useScrollPosition.js +21 -16
- package/hooks/useScrollTo.js +7 -5
- package/hooks/useTraceUpdate.js +4 -3
- package/hooks/useUpdateEffect.d.ts +5 -0
- package/hooks/useUpdateEffect.js +14 -0
- package/hooks/useWindowSize.js +3 -3
- package/m/MotionProvider.js +4 -2
- package/node/Alert/Alert.js +9 -16
- package/node/Alert/index.js +1 -1
- package/node/Animations/Reveal.js +15 -13
- package/node/Animations/Underline.js +5 -16
- package/node/Animations/index.js +1 -1
- package/node/Animations/useReveal.js +19 -18
- package/node/Autocomplete/AutocompleteMui.js +69 -64
- package/node/Autocomplete/components.js +26 -82
- package/node/Autocomplete/helpers.js +2 -2
- package/node/Bg/BgColor.js +18 -29
- package/node/Bg/BgPhoto.js +15 -59
- package/node/Bg/BgSvg.js +8 -12
- package/node/Bg/index.js +1 -1
- package/node/Breadcrumbs/Breadcrumbs.js +20 -61
- package/node/Breadcrumbs/index.js +1 -1
- package/node/Buttons/Button.js +10 -76
- package/node/Buttons/ButtonComposite.js +23 -45
- package/node/Buttons/ButtonFab.js +6 -9
- package/node/Buttons/ButtonLink.js +10 -10
- package/node/Buttons/IconButton.js +7 -20
- package/node/Buttons/index.js +1 -1
- package/node/Calendar/CalendarDaygridCell.js +24 -18
- package/node/Calendar/CalendarDaygridNav.js +14 -13
- package/node/Calendar/CalendarDaygridTable.js +39 -38
- package/node/Calendar/CalendarLegend.js +8 -3
- package/node/Calendar/calendar-api-google.js +105 -73
- package/node/Calendar/index.js +1 -1
- package/node/Calendar/useCalendar.js +117 -116
- package/node/Calendar/utils.js +82 -84
- package/node/Carousel/CarouselCss.js +17 -31
- package/node/Carousel/index.js +1 -1
- package/node/Collapsable/Collapsable.js +2 -2
- package/node/Collapsable/CollapsableReach.js +246 -134
- package/node/Collapsable/index.js +3 -2
- package/node/Debug/Debug.js +7 -20
- package/node/Debug/index.js +1 -1
- package/node/Details/Details.js +67 -0
- package/node/Details/index.js +4 -0
- package/node/Dialog/DialogMui.js +12 -11
- package/node/Dialog/css/bare.js +11 -10
- package/node/Dialog/m/bare.js +18 -14
- package/node/Dialog/m/basic.js +1 -1
- package/node/Dialog/m/index.js +4 -4
- package/node/Dialog/sc/bare.js +22 -41
- package/node/Dialog/sc/framer.js +5 -5
- package/node/Dialog/sc/framerMaterial.js +5 -5
- package/node/Dialog/sc/material.js +12 -33
- package/node/Dialog/tw/bare.js +19 -14
- package/node/Dialog/tw/elegant.js +11 -9
- package/node/Dialog/tw/framer.js +5 -5
- package/node/Dialog/tw/framerMaterial.js +5 -5
- package/node/Dialog/tw/material.js +11 -9
- package/node/Editor/Editor--tiptap.js +19 -17
- package/node/Editor/components.js +9 -28
- package/node/Editor/index.js +1 -1
- package/node/Favicon/FaviconTags.js +3 -2
- package/node/Favicon/index.js +1 -1
- package/node/Form/Form.js +65 -0
- package/node/{Forms/Form → Form}/index.js +1 -1
- package/node/Form/sc/bare.js +23 -0
- package/node/Forms/Checkbox/Checkbox.js +13 -20
- package/node/Forms/Checkbox/index.js +1 -1
- package/node/Forms/Feedback/Feedback.js +8 -10
- package/node/Forms/Feedback/index.js +1 -1
- package/node/Forms/Field/Field.js +18 -30
- package/node/Forms/Field/FieldControl.js +26 -22
- package/node/Forms/Field/FieldHint.js +4 -7
- package/node/Forms/Field/index.js +1 -1
- package/node/Forms/Input/Input.js +15 -22
- package/node/Forms/Input/index.js +1 -1
- package/node/Forms/InputGroup/InputGroup.js +14 -42
- package/node/Forms/InputGroup/index.js +1 -1
- package/node/Forms/Label/Label.js +6 -25
- package/node/Forms/Label/index.js +1 -1
- package/node/Forms/Password/Password.js +16 -30
- package/node/Forms/Password/index.js +1 -1
- package/node/Forms/Radio/Radio.js +21 -25
- package/node/Forms/Radio/index.js +1 -1
- package/node/Forms/Switch/Switch.js +15 -46
- package/node/Forms/Switch/index.js +1 -1
- package/node/Forms/Textarea/Textarea.js +11 -13
- package/node/Forms/Textarea/TextareaRich.js +16 -31
- package/node/Forms/Textarea/index.js +1 -1
- package/node/Forms/Toggle/Toggle.js +24 -72
- package/node/Forms/Toggle/index.js +1 -1
- package/node/Forms/Toggle/useToggle.js +33 -33
- package/node/Forms/antispam.js +14 -14
- package/node/Forms/helpers.js +9 -8
- package/node/Forms/index.js +1 -2
- package/node/Forms/styles.js +16 -48
- package/node/Gauge/Gauge.js +1 -1
- package/node/Grid/Grid.js +24 -51
- package/node/Grid/index.js +1 -1
- package/node/Hamburger/Hamburger.js +37 -50
- package/node/Hamburger/index.js +1 -1
- package/node/Header/index.js +1 -1
- package/node/Header/useHeader.js +16 -16
- package/node/Hidden/Hidden.js +10 -15
- package/node/Hidden/index.js +1 -1
- package/node/Img/index.js +1 -1
- package/node/Img/sc/bare.js +4 -3
- package/node/Link/Link.js +4 -3
- package/node/Link/LinkBlank.js +11 -21
- package/node/Link/index.js +1 -1
- package/node/Menu/Menu.js +4 -12
- package/node/Menu/index.js +1 -1
- package/node/MenuItem/MenuItem.js +4 -21
- package/node/MenuItem/index.js +1 -1
- package/node/Meta/Meta.js +4 -3
- package/node/Meta/index.js +1 -1
- package/node/NoJs/NoJs.js +3 -3
- package/node/NoJs/index.js +1 -1
- package/node/Pagination/PaginationNav.js +30 -53
- package/node/Pagination/PaginationResults.js +10 -10
- package/node/Pagination/index.js +1 -1
- package/node/Pill/Pill.js +7 -38
- package/node/Pill/index.js +1 -1
- package/node/Progress/ProgressCircular.js +11 -33
- package/node/Progress/ProgressLinear.js +11 -20
- package/node/Progress/ProgressOverlay.js +18 -35
- package/node/Progress/index.js +1 -1
- package/node/Rating/Rating.js +28 -48
- package/node/Rating/index.js +20 -16
- package/node/Select/components.js +11 -18
- package/node/Sidebar/Sidebar.js +21 -47
- package/node/Sidebar/index.js +1 -1
- package/node/Spacing/Spacing.js +16 -17
- package/node/Spacing/index.js +1 -1
- package/node/Sticky/StickyCss.js +5 -3
- package/node/Sticky/index.js +1 -1
- package/node/Tabs/TabsMui.js +49 -0
- package/node/Tabs/index.js +2 -2
- package/node/Tabs/sc/bare.js +87 -0
- package/node/Tabs/tw/bare.js +20 -0
- package/node/Tabs/tw/material.js +21 -0
- package/node/Tabs/useTabs.js +48 -0
- package/node/Typography/CopyPasteVisible.js +4 -7
- package/node/Typography/Native.js +14 -48
- package/node/Typography/ReadMore.js +30 -57
- package/node/Typography/TextLoop.js +22 -25
- package/node/Typography/TypeStairs.js +22 -18
- package/node/Typography/index.js +1 -1
- package/node/css/index.js +2 -1
- package/node/helpers/classed.js +23 -19
- package/node/helpers/extend-component.js +7 -7
- package/node/helpers/index.js +1 -1
- package/node/hooks/index.js +9 -1
- package/node/hooks/types.js +2 -0
- package/node/hooks/useAsyncFn.js +40 -0
- package/node/hooks/useDateLocale.js +23 -37
- package/node/hooks/useEffectOnce.js +12 -0
- package/node/hooks/useFirstMountState.js +16 -0
- package/node/hooks/useFocus.js +4 -4
- package/node/hooks/useId.js +12 -0
- package/node/hooks/useIsomorphicLayoutEffect.js +11 -0
- package/node/hooks/useMount.js +13 -0
- package/node/hooks/useMountedState.js +19 -0
- package/node/hooks/usePrevious.js +3 -3
- package/node/hooks/useScrollPosition.js +23 -19
- package/node/hooks/useScrollTo.js +9 -7
- package/node/hooks/useTraceUpdate.js +5 -4
- package/node/hooks/useUpdateEffect.js +18 -0
- package/node/hooks/useWindowSize.js +4 -4
- package/node/index.js +1 -1
- package/node/m/MotionProvider.js +6 -4
- package/node/m/index.js +1 -1
- package/node/m/lite.js +1 -1
- package/node/m/max.js +1 -1
- package/node/sc/index.js +4 -2
- package/node/scm/index.js +2 -1
- package/node/shared/index.js +1 -1
- package/node/styles/Body.js +5 -10
- package/node/styles/Global.js +5 -37
- package/node/styles/index.js +1 -1
- package/node/styles/media.js +42 -38
- package/node/styles/spacing.js +15 -16
- package/node/styles/styled.js +7 -21
- package/node/styles/theme--vanilla.js +21 -19
- package/node/styles/theme.js +9 -9
- package/node/tw/index.js +2 -1
- package/node/twm/index.js +2 -1
- package/package.json +20 -9
- package/sc/index.d.ts +1 -0
- package/sc/index.js +1 -0
- package/scm/index.js +1 -0
- package/styles/Body.js +4 -8
- package/styles/Global.js +4 -36
- package/styles/media.js +41 -36
- package/styles/spacing.js +15 -16
- package/styles/styled.js +7 -21
- package/styles/theme--vanilla.js +21 -19
- package/styles/theme.js +11 -11
- package/tw/index.js +1 -0
- package/twm/index.js +1 -0
- package/Forms/Form/Form.d.ts +0 -31
- package/Forms/Form/Form.js +0 -62
- package/Tabs/Tabs.d.ts +0 -27
- package/Tabs/Tabs.js +0 -62
- package/node/Forms/Form/Form.js +0 -67
- package/node/Tabs/Tabs.js +0 -67
|
@@ -1,30 +1,17 @@
|
|
|
1
|
+
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
3
|
import { forwardRef, useState } from "react";
|
|
3
4
|
import styled from "styled-components";
|
|
4
5
|
import { ImEye as IconVisible, ImEyeBlocked as IconInvisible, } from "react-icons/im";
|
|
5
6
|
import { Label } from "../Label/Label";
|
|
6
7
|
import { InputNative } from "../Input/Input";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
position: relative;
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const PasswordIcon = styled.span `
|
|
16
|
-
position: absolute;
|
|
17
|
-
top: 0;
|
|
18
|
-
right: 0;
|
|
19
|
-
bottom: 0;
|
|
20
|
-
width: ${ICON_WIDTH};
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
justify-content: center;
|
|
24
|
-
cursor: pointer;
|
|
25
|
-
opacity: 0.5;
|
|
26
|
-
`;
|
|
27
|
-
export const Password = forwardRef(function Password({ register, name, label, ...props }, ref) {
|
|
28
|
-
const [visible, setVisible] = useState(false);
|
|
29
|
-
return (_jsxs(_Fragment, { children: [label && _jsx(Label, { children: label }), _jsxs(PasswordInputWrap, { children: [_jsx(PasswordInputNative, { type: visible ? "text" : "password", autoComplete: "new-password", ...(register ? register(name) : { name, ref }), ...props }), _jsx(PasswordIcon, { onClick: () => setVisible((prev) => !prev), children: visible ? _jsx(IconInvisible, {}) : _jsx(IconVisible, {}) })] })] }));
|
|
8
|
+
var ICON_WIDTH = "2em";
|
|
9
|
+
var PasswordInputWrap = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
|
|
10
|
+
export var PasswordInputNative = styled(InputNative)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n padding-right: ", ";\n"], ["\n position: relative;\n padding-right: ", ";\n"])), ICON_WIDTH);
|
|
11
|
+
var PasswordIcon = styled.span(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n width: ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n opacity: 0.5;\n"], ["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n width: ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n opacity: 0.5;\n"])), ICON_WIDTH);
|
|
12
|
+
export var Password = forwardRef(function Password(_a, ref) {
|
|
13
|
+
var register = _a.register, name = _a.name, label = _a.label, props = __rest(_a, ["register", "name", "label"]);
|
|
14
|
+
var _b = useState(false), visible = _b[0], setVisible = _b[1];
|
|
15
|
+
return (_jsxs(_Fragment, { children: [label && _jsx(Label, { children: label }), _jsxs(PasswordInputWrap, { children: [_jsx(PasswordInputNative, __assign({ type: visible ? "text" : "password", autoComplete: "new-password" }, (register ? register(name) : { name: name, ref: ref }), props)), _jsx(PasswordIcon, __assign({ onClick: function () { return setVisible(function (prev) { return !prev; }); } }, { children: visible ? _jsx(IconInvisible, {}) : _jsx(IconVisible, {}) }))] })] }));
|
|
30
16
|
});
|
|
17
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
package/Forms/Radio/Radio.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
+
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { forwardRef } from "react";
|
|
3
4
|
import styled from "styled-components";
|
|
4
5
|
import { label } from "../Label/Label";
|
|
5
6
|
import { Toggle, ToggleLabel, ToggleIndicatorSquared } from "../Toggle";
|
|
6
7
|
import { InputInvisible } from "../styles";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const RadioToggle = styled(Toggle) ``;
|
|
18
|
-
const RadioIndicator = styled(ToggleIndicatorSquared) ``;
|
|
19
|
-
const RadioOptionLabel = styled(ToggleLabel) ``;
|
|
20
|
-
const RadioOption = forwardRef(function RadioOption({ register, name, label, $ref, ...props }, ref) {
|
|
21
|
-
const inputProps = register ? register(name) : { name, ref: $ref || ref };
|
|
22
|
-
return (_jsxs(RadioOptionRoot, { children: [_jsxs(RadioToggle, { children: [_jsx(InputInvisible, { type: "radio", ...inputProps, ...props }), _jsx(RadioIndicator, {})] }), _jsx(RadioOptionLabel, { children: label })] }));
|
|
8
|
+
var RadioRoot = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
|
|
9
|
+
var RadioLabel = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), label);
|
|
10
|
+
var RadioOptionRoot = styled.label(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n padding: 0.05em;\n cursor: pointer;\n"], ["\n display: flex;\n align-items: center;\n padding: 0.05em;\n cursor: pointer;\n"])));
|
|
11
|
+
var RadioToggle = styled(Toggle)(templateObject_4 || (templateObject_4 = __makeTemplateObject([""], [""])));
|
|
12
|
+
var RadioIndicator = styled(ToggleIndicatorSquared)(templateObject_5 || (templateObject_5 = __makeTemplateObject([""], [""])));
|
|
13
|
+
var RadioOptionLabel = styled(ToggleLabel)(templateObject_6 || (templateObject_6 = __makeTemplateObject([""], [""])));
|
|
14
|
+
var RadioOption = forwardRef(function RadioOption(_a, ref) {
|
|
15
|
+
var register = _a.register, name = _a.name, label = _a.label, $ref = _a.$ref, props = __rest(_a, ["register", "name", "label", "$ref"]);
|
|
16
|
+
var inputProps = register ? register(name) : { name: name, ref: $ref || ref };
|
|
17
|
+
return (_jsxs(RadioOptionRoot, { children: [_jsxs(RadioToggle, { children: [_jsx(InputInvisible, __assign({ type: "radio" }, inputProps, props)), _jsx(RadioIndicator, {})] }), _jsx(RadioOptionLabel, { children: label })] }));
|
|
23
18
|
});
|
|
24
|
-
export
|
|
19
|
+
export var Radio = forwardRef(function Radio(_a, ref) {
|
|
20
|
+
var label = _a.label, options = _a.options, props = __rest(_a, ["label", "options"]);
|
|
25
21
|
if (!options)
|
|
26
22
|
return null;
|
|
27
|
-
return (_jsxs(RadioRoot, { children: [label && _jsx(RadioLabel, { children: label }), options.map((option, idx)
|
|
23
|
+
return (_jsxs(RadioRoot, { children: [label && _jsx(RadioLabel, { children: label }), options.map(function (option, idx) { return (_jsx(RadioOption, __assign({}, option, props, { "$ref": ref }), idx)); })] }));
|
|
28
24
|
});
|
|
25
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
package/Forms/Switch/Switch.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign, __makeTemplateObject } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { forwardRef } from "react";
|
|
3
4
|
import styled from "styled-components";
|
|
@@ -5,46 +6,15 @@ import { CheckboxRoot, CheckboxLabel } from "../Checkbox";
|
|
|
5
6
|
import { toggleBase } from "../Toggle";
|
|
6
7
|
import { useToggle } from "../Toggle/useToggle";
|
|
7
8
|
import { stateFocus } from "../../styles/styled";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
position:
|
|
12
|
-
width: ${SWITCH_HANDLE_SIZE * 3}em;
|
|
13
|
-
height: ${SWITCH_HANDLE_SIZE * 1.5}em;
|
|
14
|
-
padding: ${SWITCH_GUTTER}em;
|
|
15
|
-
border-radius: ${SWITCH_HANDLE_SIZE}em;
|
|
16
|
-
${toggleBase}
|
|
17
|
-
|
|
18
|
-
input:focus ~ & {
|
|
19
|
-
${stateFocus}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
input:disabled ~ & {
|
|
23
|
-
opacity: 0.5;
|
|
24
|
-
cursor: not-allowed;
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
27
|
-
export const SwitchHandle = styled.span `
|
|
28
|
-
position: absolute;
|
|
29
|
-
width: ${SWITCH_HANDLE_SIZE}em;
|
|
30
|
-
height: ${SWITCH_HANDLE_SIZE}em;
|
|
31
|
-
left: ${SWITCH_GUTTER}em;
|
|
32
|
-
margin-top: -1px;
|
|
33
|
-
/* border: 1px solid currentColor; */
|
|
34
|
-
background: currentColor;
|
|
35
|
-
opacity: 0.5;
|
|
36
|
-
border-radius: 100%;
|
|
37
|
-
transition: all 0.18s ease-in-out;
|
|
38
|
-
|
|
39
|
-
input:checked + ${SwitchTrack} & {
|
|
40
|
-
opacity: 1;
|
|
41
|
-
left: calc(100% - ${SWITCH_HANDLE_SIZE}em - ${SWITCH_GUTTER}em);
|
|
42
|
-
}
|
|
43
|
-
`;
|
|
9
|
+
var SWITCH_GUTTER = 0.25;
|
|
10
|
+
var SWITCH_HANDLE_SIZE = 1;
|
|
11
|
+
export var SwitchTrack = styled.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n width: ", "em;\n height: ", "em;\n padding: ", "em;\n border-radius: ", "em;\n ", "\n\n input:focus ~ & {\n ", "\n }\n\n input:disabled ~ & {\n opacity: 0.5;\n cursor: not-allowed;\n }\n"], ["\n position: relative;\n width: ", "em;\n height: ", "em;\n padding: ", "em;\n border-radius: ", "em;\n ", "\n\n input:focus ~ & {\n ", "\n }\n\n input:disabled ~ & {\n opacity: 0.5;\n cursor: not-allowed;\n }\n"])), SWITCH_HANDLE_SIZE * 3, SWITCH_HANDLE_SIZE * 1.5, SWITCH_GUTTER, SWITCH_HANDLE_SIZE, toggleBase, stateFocus);
|
|
12
|
+
export var SwitchHandle = styled.span(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n width: ", "em;\n height: ", "em;\n left: ", "em;\n margin-top: -1px;\n /* border: 1px solid currentColor; */\n background: currentColor;\n opacity: 0.5;\n border-radius: 100%;\n transition: all 0.18s ease-in-out;\n\n input:checked + ", " & {\n opacity: 1;\n left: calc(100% - ", "em - ", "em);\n }\n"], ["\n position: absolute;\n width: ", "em;\n height: ", "em;\n left: ", "em;\n margin-top: -1px;\n /* border: 1px solid currentColor; */\n background: currentColor;\n opacity: 0.5;\n border-radius: 100%;\n transition: all 0.18s ease-in-out;\n\n input:checked + ", " & {\n opacity: 1;\n left: calc(100% - ", "em - ", "em);\n }\n"])), SWITCH_HANDLE_SIZE, SWITCH_HANDLE_SIZE, SWITCH_GUTTER, SwitchTrack, SWITCH_HANDLE_SIZE, SWITCH_GUTTER);
|
|
44
13
|
/**
|
|
45
14
|
* All logic and invisible Inputs come from the `useToggle` hook
|
|
46
15
|
*/
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
return (_jsxs(CheckboxRoot, {
|
|
16
|
+
export var Switch = forwardRef(function Switch(props, ref) {
|
|
17
|
+
var _a = useToggle(props, ref), rootProps = _a.rootProps, Inputs = _a.Inputs, label = _a.label;
|
|
18
|
+
return (_jsxs(CheckboxRoot, __assign({}, rootProps, { children: [Inputs, _jsx(SwitchTrack, { children: _jsx(SwitchHandle, {}) }), label && _jsx(CheckboxLabel, { children: label })] })));
|
|
50
19
|
});
|
|
20
|
+
var templateObject_1, templateObject_2;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
1
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { forwardRef } from "react";
|
|
3
4
|
import styled from "styled-components";
|
|
4
5
|
import { Label } from "../Label/Label";
|
|
5
6
|
import { inputBase, inputFocus } from "../styles";
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`;
|
|
11
|
-
export const Textarea = forwardRef(function Textarea({ register, name, label, ...props }, ref) {
|
|
12
|
-
return (_jsxs(_Fragment, { children: [label && _jsx(Label, { children: label }), _jsx(TextareaNative, { ...(register ? register(name) : { name, ref }), ...props })] }));
|
|
7
|
+
export var TextareaNative = styled.textarea(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n ", "\n resize: vertical;\n"], ["\n ", "\n ", "\n resize: vertical;\n"])), inputBase, inputFocus);
|
|
8
|
+
export var Textarea = forwardRef(function Textarea(_a, ref) {
|
|
9
|
+
var register = _a.register, name = _a.name, label = _a.label, props = __rest(_a, ["register", "name", "label"]);
|
|
10
|
+
return (_jsxs(_Fragment, { children: [label && _jsx(Label, { children: label }), _jsx(TextareaNative, __assign({}, (register ? register(name) : { name: name, ref: ref }), props))] }));
|
|
13
11
|
});
|
|
12
|
+
var templateObject_1;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { forwardRef } from "react";
|
|
3
4
|
import styled from "styled-components";
|
|
@@ -5,38 +6,23 @@ import styled from "styled-components";
|
|
|
5
6
|
import { Label } from "../Label/Label";
|
|
6
7
|
import { Editor } from "../../Editor";
|
|
7
8
|
import { triggerOnChange } from "../helpers";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
overflow: auto;
|
|
12
|
-
}
|
|
13
|
-
.EditorContent {
|
|
14
|
-
position: relative;
|
|
15
|
-
&:after {
|
|
16
|
-
position: absolute;
|
|
17
|
-
content: "";
|
|
18
|
-
bottom: 0;
|
|
19
|
-
left: 0;
|
|
20
|
-
right: 16px; /* scrollbar width? */
|
|
21
|
-
height: 3em;
|
|
22
|
-
background: linear-gradient(0deg, white, white 33%, transparent);
|
|
23
|
-
pointer-events: none;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
27
|
-
export const TextareaRich = forwardRef(function TextareaRich({ register, setValue, name, label, defaultValue = "", onChange, ...props }, ref) {
|
|
9
|
+
var Root = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n .ProseMirror {\n max-height: 160px;\n overflow: auto;\n }\n .EditorContent {\n position: relative;\n &:after {\n position: absolute;\n content: \"\";\n bottom: 0;\n left: 0;\n right: 16px; /* scrollbar width? */\n height: 3em;\n background: linear-gradient(0deg, white, white 33%, transparent);\n pointer-events: none;\n }\n }\n"], ["\n .ProseMirror {\n max-height: 160px;\n overflow: auto;\n }\n .EditorContent {\n position: relative;\n &:after {\n position: absolute;\n content: \"\";\n bottom: 0;\n left: 0;\n right: 16px; /* scrollbar width? */\n height: 3em;\n background: linear-gradient(0deg, white, white 33%, transparent);\n pointer-events: none;\n }\n }\n"])));
|
|
10
|
+
export var TextareaRich = forwardRef(function TextareaRich(_a, ref) {
|
|
11
|
+
var register = _a.register, setValue = _a.setValue, name = _a.name, label = _a.label, _b = _a.defaultValue, defaultValue = _b === void 0 ? "" : _b, onChange = _a.onChange, props = __rest(_a, ["register", "setValue", "name", "label", "defaultValue", "onChange"]);
|
|
28
12
|
if (register)
|
|
29
13
|
register(name);
|
|
30
|
-
return (_jsxs(Root, { children: [label && _jsx(Label, { children: label }), _jsx(Editor, { options: {
|
|
14
|
+
return (_jsxs(Root, { children: [label && _jsx(Label, { children: label }), _jsx(Editor, __assign({ options: {
|
|
31
15
|
// element: <TextareaAutosize />,
|
|
32
16
|
content: defaultValue,
|
|
33
17
|
onUpdate: (onChange || setValue) && name
|
|
34
|
-
? (
|
|
35
|
-
|
|
18
|
+
? function (_a) {
|
|
19
|
+
var editor = _a.editor;
|
|
20
|
+
var value = editor.getHTML();
|
|
36
21
|
if (setValue)
|
|
37
22
|
setValue(name, value);
|
|
38
23
|
triggerOnChange(onChange, name, value);
|
|
39
24
|
}
|
|
40
25
|
: undefined,
|
|
41
|
-
},
|
|
26
|
+
} }, props))] }));
|
|
42
27
|
});
|
|
28
|
+
var templateObject_1;
|
package/Forms/Toggle/Toggle.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign, __makeTemplateObject } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
/**
|
|
3
4
|
* @file
|
|
@@ -5,75 +6,27 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
6
|
* About accessibility:
|
|
6
7
|
* - minimum target size of 44px https://www.w3.org/TR/WCAG21/#target-size
|
|
7
8
|
*/
|
|
8
|
-
import { useId } from "react";
|
|
9
|
+
// import { useId } from "react";
|
|
9
10
|
import styled from "styled-components";
|
|
10
11
|
import { stateFocus } from "../../styles/styled";
|
|
11
|
-
|
|
12
|
-
border: 1px solid var(--forms-border-color);
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
flex-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
`;
|
|
26
|
-
export const toggleIndicatorFg = `
|
|
27
|
-
position: absolute;
|
|
28
|
-
left: 0;
|
|
29
|
-
width: 100%;
|
|
30
|
-
height: 100%;
|
|
31
|
-
fill: currentcolor;
|
|
32
|
-
`;
|
|
33
|
-
export const Toggle = styled.span `
|
|
34
|
-
position: relative;
|
|
35
|
-
display: inline-flex;
|
|
36
|
-
align-items: center;
|
|
37
|
-
justify-content: center;
|
|
38
|
-
width: 2em;
|
|
39
|
-
height: 2em;
|
|
40
|
-
margin: 0 -0.3em; /* rtl */
|
|
41
|
-
padding: 0.3em;
|
|
42
|
-
`;
|
|
43
|
-
export const ToggleLabel = styled.span `
|
|
44
|
-
margin-left: 0.6em; /* rtl */
|
|
45
|
-
`;
|
|
46
|
-
export const ToggleLabelSub = styled.small `
|
|
47
|
-
opacity: 0.7;
|
|
48
|
-
font-size: 0.7em; ;
|
|
49
|
-
`;
|
|
50
|
-
export const ToggleIndicatorHolder = styled.span `
|
|
51
|
-
position: relative;
|
|
52
|
-
display: flex;
|
|
53
|
-
|
|
54
|
-
input:focus ~ & {
|
|
55
|
-
${stateFocus}
|
|
56
|
-
}
|
|
57
|
-
`;
|
|
58
|
-
export const ToggleIndicatorBgSquare = styled.svg `
|
|
59
|
-
${toggleIndicatorBgShape}
|
|
60
|
-
`;
|
|
61
|
-
export const ToggleIndicatorBgCircle = styled.svg `
|
|
62
|
-
${toggleIndicatorBgShape}
|
|
63
|
-
`;
|
|
64
|
-
export const ToggleIndicatorFg = styled.svg `
|
|
65
|
-
${toggleIndicatorFg}
|
|
66
|
-
transform: scale(0);
|
|
67
|
-
transition: transform 0.18s ease;
|
|
68
|
-
|
|
69
|
-
input:checked + ${ToggleIndicatorHolder} & {
|
|
70
|
-
transform: scale(1);
|
|
71
|
-
}
|
|
72
|
-
`;
|
|
73
|
-
export const ToggleIndicatorSquared = (props) => {
|
|
74
|
-
return (_jsxs(ToggleIndicatorHolder, { children: [_jsx(ToggleIndicatorBgSquare, { viewBox: "0 0 24 24", children: _jsx("rect", { width: "24", height: "24" }) }), _jsx(ToggleIndicatorFg, { viewBox: "0 0 24 24", children: _jsx("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) })] }));
|
|
12
|
+
import { useId } from "../../hooks/useId";
|
|
13
|
+
export var toggleBase = "\n border: 1px solid var(--forms-border-color);\n";
|
|
14
|
+
export var toggleIndicatorBg = "\n display: inline-block;\n flex-shrink: 0;\n width: 100%;\n height: 100%;\n";
|
|
15
|
+
export var toggleIndicatorBgShape = "\n ".concat(toggleIndicatorBg, "\n fill: none;\n stroke-width: 2px;\n stroke: var(--forms-border-color);\n");
|
|
16
|
+
export var toggleIndicatorFg = "\n position: absolute;\n left: 0;\n width: 100%;\n height: 100%;\n fill: currentcolor;\n";
|
|
17
|
+
export var Toggle = styled.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2em;\n height: 2em;\n margin: 0 -0.3em; /* rtl */\n padding: 0.3em;\n"], ["\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2em;\n height: 2em;\n margin: 0 -0.3em; /* rtl */\n padding: 0.3em;\n"])));
|
|
18
|
+
export var ToggleLabel = styled.span(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-left: 0.6em; /* rtl */\n"], ["\n margin-left: 0.6em; /* rtl */\n"])));
|
|
19
|
+
export var ToggleLabelSub = styled.small(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n opacity: 0.7;\n font-size: 0.7em; ;\n"], ["\n opacity: 0.7;\n font-size: 0.7em; ;\n"])));
|
|
20
|
+
export var ToggleIndicatorHolder = styled.span(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n display: flex;\n\n input:focus ~ & {\n ", "\n }\n"], ["\n position: relative;\n display: flex;\n\n input:focus ~ & {\n ", "\n }\n"])), stateFocus);
|
|
21
|
+
export var ToggleIndicatorBgSquare = styled.svg(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), toggleIndicatorBgShape);
|
|
22
|
+
export var ToggleIndicatorBgCircle = styled.svg(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), toggleIndicatorBgShape);
|
|
23
|
+
export var ToggleIndicatorFg = styled.svg(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n ", "\n transform: scale(0);\n transition: transform 0.18s ease;\n\n input:checked + ", " & {\n transform: scale(1);\n }\n"], ["\n ", "\n transform: scale(0);\n transition: transform 0.18s ease;\n\n input:checked + ", " & {\n transform: scale(1);\n }\n"])), toggleIndicatorFg, ToggleIndicatorHolder);
|
|
24
|
+
export var ToggleIndicatorSquared = function (props) {
|
|
25
|
+
return (_jsxs(ToggleIndicatorHolder, { children: [_jsx(ToggleIndicatorBgSquare, __assign({ viewBox: "0 0 24 24" }, { children: _jsx("rect", { width: "24", height: "24" }) })), _jsx(ToggleIndicatorFg, __assign({ viewBox: "0 0 24 24" }, { children: _jsx("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }))] }));
|
|
75
26
|
};
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
|
|
27
|
+
export var ToggleIndicatorRounded = function (_a) {
|
|
28
|
+
var _b = _a.r, r = _b === void 0 ? 6 : _b;
|
|
29
|
+
var id = useId();
|
|
30
|
+
return (_jsxs(ToggleIndicatorHolder, { children: [_jsxs(ToggleIndicatorBgCircle, __assign({ viewBox: "0 0 24 24" }, { children: [_jsx("circle", { cy: "12", cx: "12", r: "12", id: "r_".concat(id), clipPath: "url(#c_".concat(id, ")") }), _jsx("clipPath", __assign({ id: "c_".concat(id) }, { children: _jsx("use", { xlinkHref: "#r_".concat(id) }) }))] })), _jsx(ToggleIndicatorFg, __assign({ viewBox: "0 0 24 24" }, { children: _jsx("circle", { r: r, cx: "12", cy: "12" }) }))] }));
|
|
79
31
|
};
|
|
32
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
1
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useCallback, useMemo } from "react";
|
|
3
4
|
import { useWatch } from "react-hook-form";
|
|
@@ -32,25 +33,25 @@ import { InputInvisible } from "../styles";
|
|
|
32
33
|
* an array of options with the shape of `Option`
|
|
33
34
|
*/
|
|
34
35
|
export function useToggle(props, ref) {
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
var name = props.name, control = props.control, register = props.register, label = props.label, options = props.options, propValue = props.value, restProps = __rest(props, ["name", "control", "register", "label", "options", "value"]);
|
|
37
|
+
var id = restProps.id, valueTrue = restProps.valueTrue, valueFalse = restProps.valueFalse,
|
|
37
38
|
// defaultChecked,
|
|
38
39
|
// defaultValue,
|
|
39
40
|
// eslint-disable-next-line prefer-const
|
|
40
|
-
|
|
41
|
+
remainingInputProps = __rest(restProps, ["id", "valueTrue", "valueFalse"]);
|
|
41
42
|
// use options data convention to pass on the true/false values
|
|
42
43
|
if (options) {
|
|
43
44
|
valueTrue = options
|
|
44
|
-
.filter((opt)
|
|
45
|
+
.filter(function (opt) { return opt.value === "true"; })[0]
|
|
45
46
|
.label.toString();
|
|
46
47
|
valueFalse = options
|
|
47
|
-
.filter((opt)
|
|
48
|
+
.filter(function (opt) { return opt.value === "false"; })[0]
|
|
48
49
|
.label.toString();
|
|
49
50
|
}
|
|
50
|
-
id =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
id = "switch-".concat(name);
|
|
52
|
+
var idTrue = "".concat(id, "-true");
|
|
53
|
+
var idFalse = "".concat(id, "-false");
|
|
54
|
+
var isRadio = !!(valueTrue && valueFalse);
|
|
54
55
|
// // manage default values for both toggle modes
|
|
55
56
|
// defaultChecked = isUndefined(defaultChecked) ? false : defaultChecked;
|
|
56
57
|
// // TODO: maybe throw an error if the defaultValue that arrives here is not
|
|
@@ -61,9 +62,9 @@ export function useToggle(props, ref) {
|
|
|
61
62
|
// : valueFalse;
|
|
62
63
|
// get the value either from the uncontrolled watched input or from the given
|
|
63
64
|
// prop to control the component
|
|
64
|
-
|
|
65
|
-
name,
|
|
66
|
-
control,
|
|
65
|
+
var value = useWatch({
|
|
66
|
+
name: name,
|
|
67
|
+
control: control,
|
|
67
68
|
// defaultValue: isRadio ? defaultValue : defaultChecked,
|
|
68
69
|
});
|
|
69
70
|
if (propValue) {
|
|
@@ -73,14 +74,14 @@ export function useToggle(props, ref) {
|
|
|
73
74
|
// a `register` function, then check if we have a `control` object or just
|
|
74
75
|
// rely on the `name` prop and `ref`, they probably would be passed alongside
|
|
75
76
|
// an `onChange` prop that is spreaded on the inputs
|
|
76
|
-
|
|
77
|
+
var inputProps = useMemo(function () {
|
|
77
78
|
return register
|
|
78
79
|
? register(name)
|
|
79
80
|
: control
|
|
80
81
|
? control.register(name)
|
|
81
82
|
: {
|
|
82
|
-
name,
|
|
83
|
-
ref,
|
|
83
|
+
name: name,
|
|
84
|
+
ref: ref,
|
|
84
85
|
};
|
|
85
86
|
}, [register, control, name, ref]);
|
|
86
87
|
/**
|
|
@@ -89,15 +90,15 @@ export function useToggle(props, ref) {
|
|
|
89
90
|
* Fake the spacebar keyboard behaviour on the radio mode of the checkbox.
|
|
90
91
|
* Without this *only* the arrow keys would change the checkbox state
|
|
91
92
|
*/
|
|
92
|
-
|
|
93
|
+
var handleKeyDown = useCallback(function (event) {
|
|
93
94
|
if (event.key === " ") {
|
|
94
95
|
event.preventDefault();
|
|
95
96
|
event.stopPropagation();
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
var firstInput = event.target;
|
|
98
|
+
var next = firstInput.nextElementSibling;
|
|
99
|
+
var prev = firstInput.previousElementSibling;
|
|
100
|
+
var secondInput = (next === null || next === void 0 ? void 0 : next.tagName) === "INPUT" ? next : prev;
|
|
101
|
+
var target = firstInput;
|
|
101
102
|
if (firstInput.checked) {
|
|
102
103
|
target = secondInput;
|
|
103
104
|
}
|
|
@@ -113,7 +114,7 @@ export function useToggle(props, ref) {
|
|
|
113
114
|
}, [valueTrue]);
|
|
114
115
|
// collect all the return values that are dependent on the current value
|
|
115
116
|
// of the input
|
|
116
|
-
|
|
117
|
+
var valueDependentProps = useMemo(function () { return ({
|
|
117
118
|
rootProps: {
|
|
118
119
|
htmlFor: isRadio
|
|
119
120
|
? !value || value === valueFalse
|
|
@@ -122,9 +123,11 @@ export function useToggle(props, ref) {
|
|
|
122
123
|
: id,
|
|
123
124
|
},
|
|
124
125
|
label: label ? label : value,
|
|
125
|
-
value,
|
|
126
|
-
}), [value, valueFalse, isRadio, id, idTrue, idFalse, label]);
|
|
127
|
-
|
|
126
|
+
value: value,
|
|
127
|
+
}); }, [value, valueFalse, isRadio, id, idTrue, idFalse, label]);
|
|
128
|
+
var Inputs = useMemo(function () {
|
|
129
|
+
return isRadio ? (_jsxs(_Fragment, { children: [_jsx(InputInvisible, __assign({ id: idFalse }, inputProps, remainingInputProps, { onKeyDown: handleKeyDown, type: "radio", value: valueFalse })), _jsx(InputInvisible, __assign({ id: idTrue }, inputProps, remainingInputProps, { onKeyDown: handleKeyDown, type: "radio", value: valueTrue }))] })) : (_jsx(InputInvisible, __assign({ id: id, type: "checkbox" }, inputProps, remainingInputProps)));
|
|
130
|
+
}, [
|
|
128
131
|
inputProps,
|
|
129
132
|
remainingInputProps,
|
|
130
133
|
handleKeyDown,
|
|
@@ -138,8 +141,5 @@ export function useToggle(props, ref) {
|
|
|
138
141
|
// defaultValue,
|
|
139
142
|
]);
|
|
140
143
|
// console.log("useToggle: render", value);
|
|
141
|
-
return {
|
|
142
|
-
...valueDependentProps,
|
|
143
|
-
Inputs,
|
|
144
|
-
};
|
|
144
|
+
return __assign(__assign({}, valueDependentProps), { Inputs: Inputs });
|
|
145
145
|
}
|
package/Forms/antispam.js
CHANGED
|
@@ -10,19 +10,19 @@ import { encode, decode, isUndefined } from "@koine/utils";
|
|
|
10
10
|
* form data not created by user input.
|
|
11
11
|
*/
|
|
12
12
|
export function encodeForm(validationRules) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for (
|
|
16
|
-
if (!
|
|
17
|
-
|
|
18
|
-
encoded[encodedName] = validationRules[
|
|
19
|
-
encodedNames[
|
|
13
|
+
var encoded = {};
|
|
14
|
+
var encodedNames = {};
|
|
15
|
+
for (var name_1 in validationRules) {
|
|
16
|
+
if (!name_1.startsWith("_")) {
|
|
17
|
+
var encodedName = encode(name_1);
|
|
18
|
+
encoded[encodedName] = validationRules[name_1];
|
|
19
|
+
encodedNames[name_1] = encodedName;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
// we need `.required()` to correctly infer the type @see
|
|
23
23
|
// https://github.com/jquense/yup/issues/946
|
|
24
|
-
|
|
25
|
-
return { encodedSchema, encodedNames };
|
|
24
|
+
var encodedSchema = object(encoded).required();
|
|
25
|
+
return { encodedSchema: encodedSchema, encodedNames: encodedNames };
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Decode form data
|
|
@@ -34,9 +34,9 @@ export function encodeForm(validationRules) {
|
|
|
34
34
|
* which are considered programmatic form data not created by user input.
|
|
35
35
|
*/
|
|
36
36
|
export function decodeForm(formData) {
|
|
37
|
-
|
|
38
|
-
for (
|
|
39
|
-
|
|
37
|
+
var json = {};
|
|
38
|
+
for (var encodedName in formData) {
|
|
39
|
+
var decodedName = decode(encodedName);
|
|
40
40
|
// always add underscore prefixed names as they are treated as internal
|
|
41
41
|
// private inputs outside of the honeypot system, normalise them here removing
|
|
42
42
|
// the underscore prefix
|
package/Forms/helpers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isString, matchSorter } from "@koine/utils";
|
|
2
|
-
export
|
|
3
|
-
|
|
2
|
+
export var normaliseOptions = function (options) {
|
|
3
|
+
if (options === void 0) { options = []; }
|
|
4
|
+
return options.map(function (option) {
|
|
4
5
|
return isString(option)
|
|
5
6
|
? {
|
|
6
7
|
label: option,
|
|
@@ -21,24 +22,24 @@ export function defaultOptionsFilterFn(options, inputValue) {
|
|
|
21
22
|
export function triggerOnChange(onChange, name, value) {
|
|
22
23
|
// @ts-expect-error nevermind
|
|
23
24
|
if (onChange)
|
|
24
|
-
onChange({ target: { name, value } });
|
|
25
|
+
onChange({ target: { name: name, value: value } });
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* @see https://hustle.bizongo.in/simulate-react-on-change-on-controlled-components-baa336920e04
|
|
28
29
|
* @deprecated
|
|
29
30
|
*/
|
|
30
31
|
export function triggerChange(input, value) {
|
|
31
|
-
|
|
32
|
+
var obj = window.Object;
|
|
32
33
|
if (!obj) {
|
|
33
|
-
// if (
|
|
34
|
+
// if (process.env["NODE_ENV"] !== "production") {
|
|
34
35
|
// console.warn("triggerChange: window.Object does not exists, bailing.");
|
|
35
36
|
// }
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
// @ts-expect-error nevermind
|
|
39
|
-
|
|
40
|
+
var nativeInputValueSetter = obj.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
|
|
40
41
|
// @ts-expect-error nevermind
|
|
41
42
|
nativeInputValueSetter.call(input, value);
|
|
42
|
-
|
|
43
|
+
var inputEvent = new Event("input", { bubbles: true });
|
|
43
44
|
input.dispatchEvent(inputEvent);
|
|
44
45
|
}
|
package/Forms/index.d.ts
CHANGED
package/Forms/index.js
CHANGED
package/Forms/styles.js
CHANGED
|
@@ -1,60 +1,29 @@
|
|
|
1
|
+
import { __assign, __makeTemplateObject } from "tslib";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import styled from "styled-components";
|
|
3
4
|
import { stateFocus } from "../styles/styled";
|
|
4
5
|
import { ProgressLinear } from "../Progress/ProgressLinear";
|
|
5
6
|
import { invisible } from "../styles/styled";
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
`;
|
|
9
|
-
export const InputHoneypot = styled(InputInvisible).attrs({
|
|
7
|
+
export var InputInvisible = styled.input(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), invisible);
|
|
8
|
+
export var InputHoneypot = styled(InputInvisible).attrs({
|
|
10
9
|
type: "text",
|
|
11
10
|
autoComplete: "new-password",
|
|
12
11
|
tabIndex: -1,
|
|
13
|
-
})
|
|
14
|
-
export
|
|
15
|
-
position: absolute;
|
|
16
|
-
bottom: 0;
|
|
17
|
-
left: 0;
|
|
18
|
-
width: 100%;
|
|
19
|
-
`;
|
|
12
|
+
})(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])));
|
|
13
|
+
export var InputProgress = styled(function (p) { return (_jsx(ProgressLinear, __assign({ fg: "var(--accent300)", bg: "var(--accent400)" }, p))); })(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n"], ["\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n"])));
|
|
20
14
|
/**
|
|
21
15
|
* Remove the default light blue background on autofilled inputs. To be used as
|
|
22
16
|
* a function that outputs a CSS string.
|
|
23
17
|
*
|
|
24
18
|
* @see https://stackoverflow.com/a/62624824/1938970
|
|
25
19
|
*/
|
|
26
|
-
export
|
|
27
|
-
&:-webkit-autofill,
|
|
28
|
-
&:-webkit-autofill:hover,
|
|
29
|
-
&:-webkit-autofill:focus,
|
|
30
|
-
&:-webkit-autofill:active {
|
|
31
|
-
-webkit-background-clip: text;
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
20
|
+
export var inputResetAutofill = "\n &:-webkit-autofill,\n &:-webkit-autofill:hover,\n &:-webkit-autofill:focus,\n &:-webkit-autofill:active {\n -webkit-background-clip: text;\n }\n";
|
|
34
21
|
/* FIXME: find a nice way to override this styling from implementation */
|
|
35
22
|
// border-bottom: 1px solid var(--forms-border-color);
|
|
36
23
|
// border: 0;
|
|
37
|
-
export
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export const inputReset = `
|
|
44
|
-
width: 100%;
|
|
45
|
-
min-height: 44px;
|
|
46
|
-
${inputBorder}
|
|
47
|
-
${inputPadding}
|
|
48
|
-
`;
|
|
49
|
-
export const inputBase = `
|
|
50
|
-
${inputReset}
|
|
51
|
-
${inputResetAutofill}
|
|
52
|
-
background: transparent;
|
|
53
|
-
`;
|
|
54
|
-
export const inputFocus = `
|
|
55
|
-
&:focus {
|
|
56
|
-
outline: 0px;
|
|
57
|
-
appearance: none;
|
|
58
|
-
${stateFocus}
|
|
59
|
-
}
|
|
60
|
-
`;
|
|
24
|
+
export var inputBorder = "\n border: 1px solid var(--forms-border-color);\n";
|
|
25
|
+
export var inputPadding = "\n padding: var(--forms-gutter-y) var(--forms-gutter-x);\n";
|
|
26
|
+
export var inputReset = "\n width: 100%;\n min-height: 44px;\n ".concat(inputBorder, "\n ").concat(inputPadding, "\n");
|
|
27
|
+
export var inputBase = "\n ".concat(inputReset, "\n ").concat(inputResetAutofill, "\n background: transparent;\n");
|
|
28
|
+
export var inputFocus = "\n &:focus {\n outline: 0px;\n appearance: none;\n ".concat(stateFocus, "\n }\n");
|
|
29
|
+
var templateObject_1, templateObject_2, templateObject_3;
|