@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { classed, extendComponent } from "../../helpers";
|
|
3
|
+
import { KoineTabs as _ } from "./bare";
|
|
4
|
+
export var Root = classed(_.Root)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["< class=\""], ["< class=\""])));
|
|
5
|
+
export var List = classed(_.List)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["< class=\"border-b-gray-200 border-b border-solid"], ["< class=\"border-b-gray-200 border-b border-solid"])));
|
|
6
|
+
export var Tab = classed(_.Tab)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["< class=\"flex-col relative py-3 px-4 uppercase"], ["< class=\"flex-col relative py-3 px-4 uppercase"]))); // ${p => p.selected ? "text-cyan-600" : ""}
|
|
7
|
+
export var Indicator = classed(_.Indicator)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["< class=\"absolute bottom-0 w-full h-[2px] ", ""], ["< class=\"absolute bottom-0 w-full h-[2px] ", ""])), function (p) {
|
|
8
|
+
return p.selected ? "bg-current" : "";
|
|
9
|
+
});
|
|
10
|
+
export var Panel = classed(_.Panel)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["< class=\"tabsPanel"], ["< class=\"tabsPanel"])));
|
|
11
|
+
export var KoineTabs = extendComponent(_, {
|
|
12
|
+
Root: Root,
|
|
13
|
+
List: List,
|
|
14
|
+
Tab: Tab,
|
|
15
|
+
Indicator: Indicator,
|
|
16
|
+
Panel: Panel,
|
|
17
|
+
});
|
|
18
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface UseTabsProps {
|
|
3
|
+
/**
|
|
4
|
+
* The value of the currently selected `Tab`.
|
|
5
|
+
* If you don't want any selected `Tab`, you can set this prop to `false`.
|
|
6
|
+
*/
|
|
7
|
+
value?: string | number | false;
|
|
8
|
+
/**
|
|
9
|
+
* The default value. Use when the component is not controlled.
|
|
10
|
+
*/
|
|
11
|
+
defaultValue?: string | number | false;
|
|
12
|
+
/**
|
|
13
|
+
* The component orientation (layout flow direction).
|
|
14
|
+
* @default 'horizontal'
|
|
15
|
+
*/
|
|
16
|
+
orientation?: "horizontal" | "vertical";
|
|
17
|
+
/**
|
|
18
|
+
* The direction of the text.
|
|
19
|
+
* @default 'ltr'
|
|
20
|
+
*/
|
|
21
|
+
direction?: "ltr" | "rtl";
|
|
22
|
+
/**
|
|
23
|
+
* Callback invoked when new value is being set.
|
|
24
|
+
*/
|
|
25
|
+
onChange?: (event: React.SyntheticEvent, value: number | string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* If `true` the selected tab changes on focus. Otherwise it only
|
|
28
|
+
* changes on activation.
|
|
29
|
+
*/
|
|
30
|
+
selectionFollowsFocus?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare const useTabs: (props: UseTabsProps) => {
|
|
33
|
+
getRootProps: () => {};
|
|
34
|
+
tabsContextValue: {
|
|
35
|
+
idPrefix: string;
|
|
36
|
+
value: string | number | false;
|
|
37
|
+
onSelected: (event: React.SyntheticEvent, value: number | string) => void;
|
|
38
|
+
orientation: "horizontal" | "vertical" | undefined;
|
|
39
|
+
direction: "ltr" | "rtl" | undefined;
|
|
40
|
+
selectionFollowsFocus: boolean | undefined;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export default useTabs;
|
package/Tabs/useTabs.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useCallback, /* useId, */ useMemo } from "react";
|
|
2
|
+
import { unstable_useControlled as useControlled } from "@mui/utils";
|
|
3
|
+
import { useId } from "../hooks/useId";
|
|
4
|
+
export var useTabs = function (props) {
|
|
5
|
+
var valueProp = props.value, defaultValue = props.defaultValue, onChange = props.onChange, orientation = props.orientation, direction = props.direction, selectionFollowsFocus = props.selectionFollowsFocus;
|
|
6
|
+
var _a = useControlled({
|
|
7
|
+
controlled: valueProp,
|
|
8
|
+
default: defaultValue,
|
|
9
|
+
name: "Tabs",
|
|
10
|
+
state: "value",
|
|
11
|
+
}), value = _a[0], setValue = _a[1];
|
|
12
|
+
var idPrefix = useId();
|
|
13
|
+
var onSelected = useCallback(function (e, newValue) {
|
|
14
|
+
setValue(newValue);
|
|
15
|
+
if (onChange) {
|
|
16
|
+
onChange(e, newValue);
|
|
17
|
+
}
|
|
18
|
+
}, [onChange, setValue]);
|
|
19
|
+
var getRootProps = function () {
|
|
20
|
+
return {};
|
|
21
|
+
};
|
|
22
|
+
var tabsContextValue = useMemo(function () {
|
|
23
|
+
return {
|
|
24
|
+
idPrefix: idPrefix,
|
|
25
|
+
value: value,
|
|
26
|
+
onSelected: onSelected,
|
|
27
|
+
orientation: orientation,
|
|
28
|
+
direction: direction,
|
|
29
|
+
selectionFollowsFocus: selectionFollowsFocus,
|
|
30
|
+
};
|
|
31
|
+
}, [
|
|
32
|
+
idPrefix,
|
|
33
|
+
value,
|
|
34
|
+
onSelected,
|
|
35
|
+
orientation,
|
|
36
|
+
direction,
|
|
37
|
+
selectionFollowsFocus,
|
|
38
|
+
]);
|
|
39
|
+
return {
|
|
40
|
+
getRootProps: getRootProps,
|
|
41
|
+
tabsContextValue: tabsContextValue,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export default useTabs;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
1
2
|
import styled from "styled-components";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
opacity: 0;
|
|
5
|
-
font-size: 0;
|
|
6
|
-
`;
|
|
3
|
+
export var CopyPasteVisible = styled.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: transparent;\n opacity: 0;\n font-size: 0;\n"], ["\n color: transparent;\n opacity: 0;\n font-size: 0;\n"])));
|
|
4
|
+
var templateObject_1;
|
package/Typography/Native.js
CHANGED
|
@@ -1,47 +1,14 @@
|
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
1
2
|
import styled from "styled-components";
|
|
2
3
|
import { min } from "../styles/media";
|
|
3
|
-
export
|
|
4
|
-
margin: 0 0
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
margin: 0 0
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
`;
|
|
15
|
-
export const h2 = `
|
|
16
|
-
margin: 0 0 1em 0;
|
|
17
|
-
font-size: 24px;
|
|
18
|
-
font-weight: 800;
|
|
19
|
-
line-height: var(--headingsLineHeight);
|
|
20
|
-
`;
|
|
21
|
-
export const h3 = `
|
|
22
|
-
margin: 0 0 1em 0;
|
|
23
|
-
font-size: 20px;
|
|
24
|
-
font-weight: 600;
|
|
25
|
-
line-height: var(--headingsLineHeight);
|
|
26
|
-
`;
|
|
27
|
-
export const h4 = `
|
|
28
|
-
margin: 0 0 1em 0;
|
|
29
|
-
font-size: 13px;
|
|
30
|
-
font-weight: 600;
|
|
31
|
-
line-height: var(--headingsLineHeight);
|
|
32
|
-
`;
|
|
33
|
-
export const P = styled.div `
|
|
34
|
-
${p}
|
|
35
|
-
`;
|
|
36
|
-
export const H1 = styled.div `
|
|
37
|
-
${h1}
|
|
38
|
-
`;
|
|
39
|
-
export const H2 = styled.div `
|
|
40
|
-
${h2}
|
|
41
|
-
`;
|
|
42
|
-
export const H3 = styled.div `
|
|
43
|
-
${h3}
|
|
44
|
-
`;
|
|
45
|
-
export const H4 = styled.div `
|
|
46
|
-
${h4}
|
|
47
|
-
`;
|
|
4
|
+
export var p = "\n margin: 0 0 1em 0;\n";
|
|
5
|
+
export var h1 = "\n margin: 0 0 10px 0;\n font-size: 30px;\n font-weight: 800;\n line-height: var(--headingsLineHeight);\n ".concat(min.md, " {\n font-size: 50px;\n }\n");
|
|
6
|
+
export var h2 = "\n margin: 0 0 1em 0;\n font-size: 24px;\n font-weight: 800;\n line-height: var(--headingsLineHeight);\n";
|
|
7
|
+
export var h3 = "\n margin: 0 0 1em 0;\n font-size: 20px;\n font-weight: 600;\n line-height: var(--headingsLineHeight);\n";
|
|
8
|
+
export var h4 = "\n margin: 0 0 1em 0;\n font-size: 13px;\n font-weight: 600;\n line-height: var(--headingsLineHeight);\n";
|
|
9
|
+
export var P = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), p);
|
|
10
|
+
export var H1 = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), h1);
|
|
11
|
+
export var H2 = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), h2);
|
|
12
|
+
export var H3 = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), h3);
|
|
13
|
+
export var H4 = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), h4);
|
|
14
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
package/Typography/ReadMore.js
CHANGED
|
@@ -1,60 +1,33 @@
|
|
|
1
|
+
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useState, useRef, useMemo } from "react";
|
|
3
4
|
import styled from "styled-components";
|
|
4
|
-
import { useIsomorphicLayoutEffect } from "react-use";
|
|
5
5
|
import { m, useSpring } from "framer-motion";
|
|
6
6
|
// import { CgArrowsExpandDownRight as IconExpand } from "react-icons/cg";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
& p:first-child {
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const Btn = styled.span `
|
|
27
|
-
padding: 0 10px 0 10px;
|
|
28
|
-
line-height: ${(p) => (p.$lineHeight ? p.$lineHeight : "inherit")};
|
|
29
|
-
background: var(--bodyBg);
|
|
30
|
-
color: var(--grey600);
|
|
31
|
-
white-space: nowrap;
|
|
32
|
-
font-size: ${(p) => p.$fontSize}px;
|
|
33
|
-
cursor: pointer;
|
|
34
|
-
`;
|
|
35
|
-
const BtnIcon = styled.span `
|
|
36
|
-
display: inline-block;
|
|
37
|
-
margin: 0 0 0 4px;
|
|
38
|
-
transition: transform 0.18s ease-in-out;
|
|
39
|
-
${(p) => (p.$expanded ? "transform: rotate(180deg);" : "")};
|
|
40
|
-
font-size: ${(p) => p.$fontSize}px;
|
|
41
|
-
`;
|
|
42
|
-
export const ReadMore = ({ lines = 3, lineHeight = 1.6, fontSize = 14, bg = "var(--bodyBg)", expand = "Expand", collapse = "Collapse", ...props }) => {
|
|
43
|
-
const defaultMaxHeight = lines * (lineHeight * fontSize);
|
|
44
|
-
const [expanded, setExpanded] = useState(false);
|
|
45
|
-
const [maxHeight, setMaxHeight] = useState(defaultMaxHeight);
|
|
46
|
-
const [fullHeight, setFullHeight] = useState(0);
|
|
47
|
-
const [exceeds, setExceeds] = useState(false);
|
|
48
|
-
const content = useRef(null);
|
|
49
|
-
const height = useSpring(defaultMaxHeight);
|
|
50
|
-
const styles = useMemo(() => (exceeds ? { height, overflow: "hidden" } : {}), [exceeds, height]);
|
|
51
|
-
const handleExpandClick = () => {
|
|
52
|
-
setExpanded((prevExpanded) => !prevExpanded);
|
|
7
|
+
import { useIsomorphicLayoutEffect } from "../hooks";
|
|
8
|
+
var Root = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
|
|
9
|
+
var Content = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n & p:first-child {\n margin-top: 0;\n }\n"], ["\n & p:first-child {\n margin-top: 0;\n }\n"])));
|
|
10
|
+
var BtnWrap = styled.span(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-end;\n transition: transform 0.18s ease-in-out;\n text-align: right;\n transform: translateY(", ");\n opacity: ", ";\n"], ["\n display: flex;\n justify-content: flex-end;\n transition: transform 0.18s ease-in-out;\n text-align: right;\n transform: translateY(", ");\n opacity: ", ";\n"])), function (p) { return (p.$expanded ? "0" : "-100%"); }, function (p) { return (p.$expanded ? 0 : 1); });
|
|
11
|
+
var BtnFader = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 30%;\n transition: transform 0.18s ease-in-out;\n background: linear-gradient(45deg, transparent 50%, ", " 70%);\n"], ["\n width: 30%;\n transition: transform 0.18s ease-in-out;\n background: linear-gradient(45deg, transparent 50%, ", " 70%);\n"])), function (p) { return p.$bg; });
|
|
12
|
+
var Btn = styled.span(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding: 0 10px 0 10px;\n line-height: ", ";\n background: var(--bodyBg);\n color: var(--grey600);\n white-space: nowrap;\n font-size: ", "px;\n cursor: pointer;\n"], ["\n padding: 0 10px 0 10px;\n line-height: ", ";\n background: var(--bodyBg);\n color: var(--grey600);\n white-space: nowrap;\n font-size: ", "px;\n cursor: pointer;\n"])), function (p) { return (p.$lineHeight ? p.$lineHeight : "inherit"); }, function (p) { return p.$fontSize; });
|
|
13
|
+
var BtnIcon = styled.span(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: inline-block;\n margin: 0 0 0 4px;\n transition: transform 0.18s ease-in-out;\n ", ";\n font-size: ", "px;\n"], ["\n display: inline-block;\n margin: 0 0 0 4px;\n transition: transform 0.18s ease-in-out;\n ", ";\n font-size: ", "px;\n"])), function (p) { return (p.$expanded ? "transform: rotate(180deg);" : ""); }, function (p) { return p.$fontSize; });
|
|
14
|
+
export var ReadMore = function (_a) {
|
|
15
|
+
var _b = _a.lines, lines = _b === void 0 ? 3 : _b, _c = _a.lineHeight, lineHeight = _c === void 0 ? 1.6 : _c, _d = _a.fontSize, fontSize = _d === void 0 ? 14 : _d, _e = _a.bg, bg = _e === void 0 ? "var(--bodyBg)" : _e, _f = _a.expand, expand = _f === void 0 ? "Expand" : _f, _g = _a.collapse, collapse = _g === void 0 ? "Collapse" : _g, props = __rest(_a, ["lines", "lineHeight", "fontSize", "bg", "expand", "collapse"]);
|
|
16
|
+
var defaultMaxHeight = lines * (lineHeight * fontSize);
|
|
17
|
+
var _h = useState(false), expanded = _h[0], setExpanded = _h[1];
|
|
18
|
+
var _j = useState(defaultMaxHeight), maxHeight = _j[0], setMaxHeight = _j[1];
|
|
19
|
+
var _k = useState(0), fullHeight = _k[0], setFullHeight = _k[1];
|
|
20
|
+
var _l = useState(false), exceeds = _l[0], setExceeds = _l[1];
|
|
21
|
+
var content = useRef(null);
|
|
22
|
+
var height = useSpring(defaultMaxHeight);
|
|
23
|
+
var styles = useMemo(function () { return (exceeds ? { height: height, overflow: "hidden" } : {}); }, [exceeds, height]);
|
|
24
|
+
var handleExpandClick = function () {
|
|
25
|
+
setExpanded(function (prevExpanded) { return !prevExpanded; });
|
|
53
26
|
};
|
|
54
|
-
useIsomorphicLayoutEffect(()
|
|
27
|
+
useIsomorphicLayoutEffect(function () {
|
|
55
28
|
if (content.current) {
|
|
56
|
-
|
|
57
|
-
|
|
29
|
+
var elementHeight = content.current.offsetHeight;
|
|
30
|
+
var newExceeds = elementHeight > maxHeight;
|
|
58
31
|
if (!newExceeds) {
|
|
59
32
|
setMaxHeight(elementHeight);
|
|
60
33
|
}
|
|
@@ -62,8 +35,9 @@ export const ReadMore = ({ lines = 3, lineHeight = 1.6, fontSize = 14, bg = "var
|
|
|
62
35
|
setFullHeight(elementHeight);
|
|
63
36
|
}
|
|
64
37
|
}, [content, maxHeight]);
|
|
65
|
-
useIsomorphicLayoutEffect(()
|
|
38
|
+
useIsomorphicLayoutEffect(function () {
|
|
66
39
|
height.set(expanded ? fullHeight : maxHeight);
|
|
67
40
|
}, [expanded, height, fullHeight, maxHeight]);
|
|
68
|
-
return (_jsxs(Root, { children: [_jsx(m.div, { style: styles, children: _jsx(Content, { ref: content,
|
|
41
|
+
return (_jsxs(Root, { children: [_jsx(m.div, __assign({ style: styles }, { children: _jsx(Content, __assign({ ref: content }, props)) })), exceeds && (_jsxs(BtnWrap, __assign({ "$expanded": expanded }, { children: [_jsx(BtnFader, { "$bg": bg }), _jsxs(Btn, __assign({ "$fontSize": fontSize, "$lineHeight": lineHeight, onClick: handleExpandClick, "aria-expanded": expanded, "aria-label": expanded ? collapse : expand }, { children: [expanded ? collapse : expand, _jsx(BtnIcon, { "$expanded": expanded })] }))] })))] }));
|
|
69
42
|
};
|
|
43
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
package/Typography/TextLoop.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useEffect, useRef, useState } from "react";
|
|
3
4
|
import { m, AnimatePresence } from "framer-motion";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export var TextLoopPiece = function (_a) {
|
|
6
|
+
var _b = _a.text, text = _b === void 0 ? "" : _b, _c = _a.style, style = _c === void 0 ? {} : _c, _d = _a.className, className = _d === void 0 ? "" : _d, _e = _a.direction, direction = _e === void 0 ? "up" : _e, _f = _a.inline, inline = _f === void 0 ? true : _f, _g = _a.noOverflow, noOverflow = _g === void 0 ? true : _g, _h = _a.delay, delay = _h === void 0 ? 400 : _h;
|
|
7
|
+
var placeholderRef = useRef(null);
|
|
8
|
+
var _j = useState({ data: "", key: "" }), content = _j[0], setContent = _j[1];
|
|
9
|
+
var _k = useState(inline ? 0 : "auto"), width = _k[0], setWidth = _k[1];
|
|
10
|
+
useEffect(function () {
|
|
11
|
+
var timeoutId = setTimeout(function () {
|
|
10
12
|
if (!placeholderRef.current)
|
|
11
13
|
return;
|
|
12
14
|
placeholderRef.current.innerHTML = text + "";
|
|
@@ -14,15 +16,9 @@ export const TextLoopPiece = ({ text = "", style = {}, className = "", direction
|
|
|
14
16
|
setWidth(placeholderRef.current.offsetWidth);
|
|
15
17
|
setContent({ data: text + "", key: new Date() + "" });
|
|
16
18
|
}, delay);
|
|
17
|
-
return ()
|
|
19
|
+
return function () { return clearTimeout(timeoutId); };
|
|
18
20
|
}, [text, delay, inline]);
|
|
19
|
-
return (_jsxs("div", { className: className, style: {
|
|
20
|
-
...style,
|
|
21
|
-
position: "relative",
|
|
22
|
-
display: inline ? "inline-block" : "block",
|
|
23
|
-
width,
|
|
24
|
-
whiteSpace: inline ? "nowrap" : "normal",
|
|
25
|
-
}, children: [_jsx("span", { ref: placeholderRef, style: { visibility: "hidden" } }), _jsx("div", { style: {
|
|
21
|
+
return (_jsxs("div", __assign({ className: className, style: __assign(__assign({}, style), { position: "relative", display: inline ? "inline-block" : "block", width: width, whiteSpace: inline ? "nowrap" : "normal" }) }, { children: [_jsx("span", { ref: placeholderRef, style: { visibility: "hidden" } }), _jsx("div", __assign({ style: {
|
|
26
22
|
overflow: noOverflow ? "hidden" : "visible",
|
|
27
23
|
display: "block",
|
|
28
24
|
position: "absolute",
|
|
@@ -30,20 +26,21 @@ export const TextLoopPiece = ({ text = "", style = {}, className = "", direction
|
|
|
30
26
|
left: 0,
|
|
31
27
|
height: "100%",
|
|
32
28
|
width: "100%",
|
|
33
|
-
}, children: _jsx(AnimatePresence, { children: _jsx(m.div, { style: { position: "absolute" }, initial: {
|
|
29
|
+
} }, { children: _jsx(AnimatePresence, { children: _jsx(m.div, __assign({ style: { position: "absolute" }, initial: {
|
|
34
30
|
opacity: 0,
|
|
35
31
|
y: direction === "down" ? "-100%" : "100%",
|
|
36
32
|
}, animate: { opacity: 1, y: 0 }, exit: {
|
|
37
33
|
opacity: 0,
|
|
38
34
|
y: direction === "down" ? "100%" : "-100%",
|
|
39
|
-
}, children: content.data }, content.key) }) })] }));
|
|
35
|
+
} }, { children: content.data }), content.key) }) }))] })));
|
|
40
36
|
};
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
export var TextLoop = function (_a) {
|
|
38
|
+
var texts = _a.texts, _b = _a.interval, interval = _b === void 0 ? 3000 : _b, props = __rest(_a, ["texts", "interval"]);
|
|
39
|
+
var _c = useState(0), index = _c[0], setIndex = _c[1];
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
var intervalId = setInterval(function () { return setIndex(function (index) { return index + 1; }); }, interval // every 3 seconds
|
|
45
42
|
);
|
|
46
|
-
return ()
|
|
43
|
+
return function () { return clearTimeout(intervalId); };
|
|
47
44
|
}, [interval]);
|
|
48
|
-
return _jsx(TextLoopPiece, {
|
|
45
|
+
return _jsx(TextLoopPiece, __assign({}, props, { text: texts[index % texts.length] }));
|
|
49
46
|
};
|
package/Typography/TypeStairs.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
3
|
import { forwardRef } from "react";
|
|
3
|
-
export
|
|
4
|
+
export var TypeStairs = forwardRef(function (_a, ref) {
|
|
5
|
+
var children = _a.children, limit = _a.limit;
|
|
4
6
|
// split in rows or just use one row if there is no limit
|
|
5
|
-
|
|
6
|
-
return rows.length > 1 ? (_jsx(_Fragment, { children: rows.map((row, rowIndex)
|
|
7
|
-
return (_jsxs("span", { children: [renderRow(row, rowIndex, ref), rowIndex !== rows.length - 1 && _jsx("br", {})] },
|
|
7
|
+
var rows = limit ? splitTextIntoRows(children, limit) : [children];
|
|
8
|
+
return rows.length > 1 ? (_jsx(_Fragment, { children: rows.map(function (row, rowIndex) {
|
|
9
|
+
return (_jsxs("span", { children: [renderRow(row, rowIndex, ref), rowIndex !== rows.length - 1 && _jsx("br", {})] }, "row-".concat(rowIndex)));
|
|
8
10
|
}) })) : (renderRow(rows[0], 0, ref));
|
|
9
11
|
});
|
|
10
12
|
/**
|
|
11
13
|
* every number chars find a space and break, then restart the gradient weight
|
|
12
14
|
* @see https://stackoverflow.com/a/25770787
|
|
13
15
|
*/
|
|
14
|
-
function splitTextIntoRows(input
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
function splitTextIntoRows(input, limit) {
|
|
17
|
+
if (input === void 0) { input = ""; }
|
|
18
|
+
if (limit === void 0) { limit = 18; }
|
|
19
|
+
var rows = [];
|
|
20
|
+
var arr = input.split(" ");
|
|
21
|
+
var currow = arr[0];
|
|
22
|
+
var rowlen = currow.length;
|
|
23
|
+
for (var i = 1; i < arr.length; i++) {
|
|
24
|
+
var word = arr[i];
|
|
21
25
|
rowlen += word.length + 1;
|
|
22
26
|
if (rowlen <= limit) {
|
|
23
27
|
currow += " " + word;
|
|
@@ -32,15 +36,15 @@ function splitTextIntoRows(input = "", limit = 18) {
|
|
|
32
36
|
return rows;
|
|
33
37
|
}
|
|
34
38
|
function renderRow(row, rowIndex, ref) {
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
var letters = row.split("");
|
|
40
|
+
var fontWeightIdx = 1;
|
|
37
41
|
// const fontWeight = Math.min(fontWeightIdx * 100, 800);
|
|
38
|
-
return (_jsx(_Fragment, { children: letters.map((letter, letterIndex)
|
|
39
|
-
|
|
42
|
+
return (_jsx(_Fragment, { children: letters.map(function (letter, letterIndex) {
|
|
43
|
+
var fontWeight = Math.min(fontWeightIdx * 100, 800);
|
|
40
44
|
// don't waste a fontWeight for a white space
|
|
41
45
|
if (letter !== " ") {
|
|
42
46
|
fontWeightIdx++;
|
|
43
47
|
}
|
|
44
|
-
return (_jsx("span", { style: { fontWeight }, ref: ref, children: letter },
|
|
48
|
+
return (_jsx("span", __assign({ style: { fontWeight: fontWeight }, ref: ref }, { children: letter }), "letter-".concat(rowIndex, "-").concat(letterIndex)));
|
|
45
49
|
}) }));
|
|
46
50
|
}
|
package/css/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from "../shared";
|
|
|
9
9
|
// export * from "../Collapsable";
|
|
10
10
|
// export * from "../Debug";
|
|
11
11
|
export { KoineDialog } from "../Dialog/css/bare";
|
|
12
|
+
// export * from "../Form";
|
|
12
13
|
// export * from "../Forms";
|
|
13
14
|
// export * from "../Grid";
|
|
14
15
|
// export * from "../Hamburger";
|
package/helpers/classed.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { createElement, forwardRef } from "react";
|
|
2
3
|
/**
|
|
3
4
|
* This utility allows to extend a component a là `styled-components` but for
|
|
@@ -15,12 +16,17 @@ import { createElement, forwardRef } from "react";
|
|
|
15
16
|
*/
|
|
16
17
|
export function classed(component) {
|
|
17
18
|
// @ts-expect-error nevermind for now...
|
|
18
|
-
|
|
19
|
-
return function (strings
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
var type = component.type || component;
|
|
20
|
+
return function (strings) {
|
|
21
|
+
var args = [];
|
|
22
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
23
|
+
args[_i - 1] = arguments[_i];
|
|
24
|
+
}
|
|
25
|
+
var WrappedComponent = forwardRef(function (props, ref) {
|
|
26
|
+
var _a;
|
|
27
|
+
var argResolved = args
|
|
28
|
+
.map(function (arg, index) {
|
|
29
|
+
var result = "";
|
|
24
30
|
if (typeof arg === "function") {
|
|
25
31
|
result = arg(props);
|
|
26
32
|
}
|
|
@@ -30,32 +36,30 @@ export function classed(component) {
|
|
|
30
36
|
return strings[index] + result;
|
|
31
37
|
})
|
|
32
38
|
.join("");
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
var isNativeHtmlElement = typeof type === "string";
|
|
40
|
+
var propsToForward = isNativeHtmlElement
|
|
35
41
|
? {}
|
|
36
42
|
: props;
|
|
37
43
|
if (isNativeHtmlElement) {
|
|
38
|
-
for (
|
|
44
|
+
for (var key in props) {
|
|
39
45
|
// like styled-components `transient` props
|
|
40
46
|
if (!key.startsWith("$")) {
|
|
47
|
+
// FIXME: for react 18 we need: @ts-expect-error
|
|
41
48
|
propsToForward[key] = props[key];
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
// get the tagged function string outcome
|
|
46
|
-
|
|
53
|
+
var className = argResolved || strings[0];
|
|
47
54
|
// check if we need to clean it or not from the optional structure `< class="..."`
|
|
48
|
-
className = className.match(/class="([^"]*)/)
|
|
55
|
+
className = ((_a = className.match(/class="([^"]*)/)) === null || _a === void 0 ? void 0 : _a[1]) || className;
|
|
49
56
|
// add the custom classes from props
|
|
50
|
-
className += props
|
|
51
|
-
return createElement(type, {
|
|
52
|
-
// ...props,
|
|
53
|
-
...propsToForward,
|
|
57
|
+
className += (props === null || props === void 0 ? void 0 : props.className) ? " " + (props === null || props === void 0 ? void 0 : props.className) : "";
|
|
58
|
+
return createElement(type, __assign(__assign({}, propsToForward), {
|
|
54
59
|
// only add ot props if it is not an empty string
|
|
55
|
-
className: className || undefined,
|
|
60
|
+
className: className || undefined,
|
|
56
61
|
// add ref to props
|
|
57
|
-
ref
|
|
58
|
-
});
|
|
62
|
+
ref: ref }));
|
|
59
63
|
});
|
|
60
64
|
// FIXME: not sure if this is needed
|
|
61
65
|
// WrappedComponent.displayName = type.toString();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { createElement } from "react";
|
|
2
|
-
export
|
|
3
|
+
export var extendComponent = function (component, defaultProps) {
|
|
3
4
|
// FIXME: check if we need to forwardRef or not
|
|
4
|
-
|
|
5
|
+
var NewComponent = function (props) {
|
|
6
|
+
return createElement(component, props);
|
|
7
|
+
};
|
|
5
8
|
// const NewComponent = forwardRef<React.ComponentProps<Component>, Component>(
|
|
6
9
|
// (props, ref) => createElement(component, { ...props, ref })
|
|
7
10
|
// );
|
|
8
|
-
return Object.assign(NewComponent, {
|
|
9
|
-
...defaultProps,
|
|
10
|
-
defaultProps,
|
|
11
|
-
});
|
|
11
|
+
return Object.assign(NewComponent, __assign(__assign({}, defaultProps), { defaultProps: defaultProps }));
|
|
12
12
|
};
|
package/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
export * from "./useAsyncFn";
|
|
1
2
|
export * from "./useDateLocale";
|
|
3
|
+
export * from "./useEffectOnce";
|
|
4
|
+
export * from "./useFirstMountState";
|
|
2
5
|
export * from "./useFocus";
|
|
6
|
+
export * from "./useId";
|
|
7
|
+
export * from "./useIsomorphicLayoutEffect";
|
|
8
|
+
export * from "./useMount";
|
|
9
|
+
export * from "./useMountedState";
|
|
3
10
|
export * from "./usePrevious";
|
|
4
11
|
export * from "./useScrollPosition";
|
|
5
12
|
export * from "./useTraceUpdate";
|
|
13
|
+
export * from "./useUpdateEffect";
|
|
6
14
|
export * from "./useWindowSize";
|
package/hooks/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
export * from "./useAsyncFn";
|
|
1
2
|
export * from "./useDateLocale";
|
|
3
|
+
export * from "./useEffectOnce";
|
|
4
|
+
export * from "./useFirstMountState";
|
|
2
5
|
export * from "./useFocus";
|
|
6
|
+
export * from "./useId";
|
|
7
|
+
export * from "./useIsomorphicLayoutEffect";
|
|
8
|
+
export * from "./useMount";
|
|
9
|
+
export * from "./useMountedState";
|
|
3
10
|
export * from "./usePrevious";
|
|
4
11
|
export * from "./useScrollPosition";
|
|
5
12
|
// export * from "./useScrollTo";
|
|
6
13
|
export * from "./useTraceUpdate";
|
|
14
|
+
export * from "./useUpdateEffect";
|
|
7
15
|
export * from "./useWindowSize";
|
package/hooks/types.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/misc/types.ts)
|
|
3
|
+
*/
|
|
4
|
+
export declare type PromiseType<P extends Promise<any>> = P extends Promise<infer T> ? T : never;
|
|
5
|
+
/**
|
|
6
|
+
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/misc/types.ts)
|
|
7
|
+
*/
|
|
8
|
+
export declare type FunctionReturningPromise = (...args: any[]) => Promise<any>;
|
package/hooks/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { FunctionReturningPromise, PromiseType } from "./types";
|
|
3
|
+
export declare type AsyncState<T> = {
|
|
4
|
+
loading: boolean;
|
|
5
|
+
error?: undefined;
|
|
6
|
+
value?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
loading: true;
|
|
9
|
+
error?: Error | undefined;
|
|
10
|
+
value?: T;
|
|
11
|
+
} | {
|
|
12
|
+
loading: false;
|
|
13
|
+
error: Error;
|
|
14
|
+
value?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
loading: false;
|
|
17
|
+
error?: undefined;
|
|
18
|
+
value: T;
|
|
19
|
+
};
|
|
20
|
+
declare type StateFromFunctionReturningPromise<T extends FunctionReturningPromise> = AsyncState<PromiseType<ReturnType<T>>>;
|
|
21
|
+
export declare type AsyncFnReturn<T extends FunctionReturningPromise = FunctionReturningPromise> = [StateFromFunctionReturningPromise<T>, T];
|
|
22
|
+
/**
|
|
23
|
+
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts)
|
|
24
|
+
*/
|
|
25
|
+
export declare function useAsyncFn<T extends FunctionReturningPromise>(fn: T, deps?: React.DependencyList, initialState?: StateFromFunctionReturningPromise<T>): AsyncFnReturn<T>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { useCallback, useRef, useState } from "react";
|
|
3
|
+
import { useMountedState } from "./useMountedState";
|
|
4
|
+
/**
|
|
5
|
+
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts)
|
|
6
|
+
*/
|
|
7
|
+
export function useAsyncFn(fn, deps, initialState) {
|
|
8
|
+
if (deps === void 0) { deps = []; }
|
|
9
|
+
if (initialState === void 0) { initialState = { loading: false }; }
|
|
10
|
+
var lastCallId = useRef(0);
|
|
11
|
+
var isMounted = useMountedState();
|
|
12
|
+
var _a = useState(initialState), state = _a[0], set = _a[1];
|
|
13
|
+
var callback = useCallback(function () {
|
|
14
|
+
var args = [];
|
|
15
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
|
+
args[_i] = arguments[_i];
|
|
17
|
+
}
|
|
18
|
+
var callId = ++lastCallId.current;
|
|
19
|
+
if (!state.loading) {
|
|
20
|
+
set(function (prevState) { return (__assign(__assign({}, prevState), { loading: true })); });
|
|
21
|
+
}
|
|
22
|
+
return fn.apply(void 0, args).then(function (value) {
|
|
23
|
+
isMounted() &&
|
|
24
|
+
callId === lastCallId.current &&
|
|
25
|
+
set({ value: value, loading: false });
|
|
26
|
+
return value;
|
|
27
|
+
}, function (error) {
|
|
28
|
+
isMounted() &&
|
|
29
|
+
callId === lastCallId.current &&
|
|
30
|
+
set({ error: error, loading: false });
|
|
31
|
+
return error;
|
|
32
|
+
});
|
|
33
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
+
}, deps);
|
|
35
|
+
return [state, callback];
|
|
36
|
+
}
|