@koine/react 2.0.0-beta.10 → 2.0.0-beta.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.
Files changed (216) hide show
  1. package/package.json +11 -11
  2. package/Alert/Alert.js +0 -33
  3. package/Alert/Alert.stories.js +0 -39
  4. package/Alert/index.js +0 -6
  5. package/Animations/Reveal.js +0 -53
  6. package/Animations/Underline.js +0 -26
  7. package/Animations/index.js +0 -8
  8. package/Animations/useReveal.js +0 -83
  9. package/Autocomplete/AutocompleteDownshift.js +0 -167
  10. package/Autocomplete/AutocompleteDownshiftMultiselect.js +0 -362
  11. package/Autocomplete/AutocompleteMui.js +0 -183
  12. package/Autocomplete/AutocompleteReach.js +0 -121
  13. package/Autocomplete/components.js +0 -132
  14. package/Autocomplete/helpers.js +0 -34
  15. package/Autocomplete/index.js +0 -15
  16. package/Bg/BgColor.js +0 -64
  17. package/Bg/BgPhoto.js +0 -82
  18. package/Bg/BgSvg.js +0 -31
  19. package/Bg/index.js +0 -8
  20. package/Breadcrumbs/Breadcrumbs.js +0 -103
  21. package/Breadcrumbs/index.js +0 -6
  22. package/Buttons/Button.js +0 -106
  23. package/Buttons/ButtonComposite.js +0 -116
  24. package/Buttons/ButtonFab.js +0 -27
  25. package/Buttons/ButtonLink.js +0 -29
  26. package/Buttons/IconButton.js +0 -41
  27. package/Buttons/index.js +0 -10
  28. package/Calendar/CalendarDaygridCell.js +0 -105
  29. package/Calendar/CalendarDaygridNav.js +0 -63
  30. package/Calendar/CalendarDaygridTable.js +0 -126
  31. package/Calendar/CalendarLegend.js +0 -39
  32. package/Calendar/calendar-api-google.js +0 -110
  33. package/Calendar/index.js +0 -11
  34. package/Calendar/types.js +0 -4
  35. package/Calendar/useCalendar.js +0 -235
  36. package/Calendar/utils.js +0 -252
  37. package/Carousel/Carousel.js +0 -387
  38. package/Carousel/CarouselCss.js +0 -64
  39. package/Carousel/index.js +0 -6
  40. package/Collapsable/Collapsable.js +0 -11
  41. package/Collapsable/CollapsableReach.js +0 -251
  42. package/Collapsable/index.js +0 -7
  43. package/Debug/Debug.js +0 -34
  44. package/Debug/index.js +0 -6
  45. package/Details/Details.js +0 -117
  46. package/Details/Details.stories.js +0 -39
  47. package/Details/index.js +0 -6
  48. package/Dialog/DialogMui.js +0 -143
  49. package/Dialog/DialogMui.stories.js +0 -38
  50. package/Dialog/css/bare.js +0 -55
  51. package/Dialog/css/index.stories.js +0 -93
  52. package/Dialog/index.js +0 -11
  53. package/Dialog/m/bare.js +0 -125
  54. package/Dialog/m/basic.js +0 -50
  55. package/Dialog/m/index.js +0 -14
  56. package/Dialog/sc/bare.js +0 -83
  57. package/Dialog/sc/framer.js +0 -26
  58. package/Dialog/sc/framerMaterial.js +0 -26
  59. package/Dialog/sc/index.stories.js +0 -75
  60. package/Dialog/sc/material.js +0 -78
  61. package/Dialog/tw/bare.js +0 -55
  62. package/Dialog/tw/elegant.js +0 -54
  63. package/Dialog/tw/framer.js +0 -26
  64. package/Dialog/tw/framerMaterial.js +0 -26
  65. package/Dialog/tw/index.stories.js +0 -113
  66. package/Dialog/tw/material.js +0 -54
  67. package/Editor/Editor--tiptap.js +0 -72
  68. package/Editor/components.js +0 -59
  69. package/Editor/index.js +0 -6
  70. package/FaviconTags.js +0 -73
  71. package/Form/Form.js +0 -130
  72. package/Form/index.js +0 -6
  73. package/Form/sc/bare.js +0 -55
  74. package/Forms/Checkbox/Checkbox.js +0 -62
  75. package/Forms/Checkbox/index.js +0 -6
  76. package/Forms/Feedback/Feedback.js +0 -25
  77. package/Forms/Feedback/index.js +0 -6
  78. package/Forms/Field/Field.js +0 -75
  79. package/Forms/Field/FieldControl.js +0 -69
  80. package/Forms/Field/FieldHint.js +0 -17
  81. package/Forms/Field/index.js +0 -7
  82. package/Forms/Input/Input.js +0 -67
  83. package/Forms/Input/index.js +0 -6
  84. package/Forms/InputGroup/InputGroup.js +0 -85
  85. package/Forms/InputGroup/index.js +0 -6
  86. package/Forms/Label/Label.js +0 -46
  87. package/Forms/Label/index.js +0 -6
  88. package/Forms/Password/Password.js +0 -72
  89. package/Forms/Password/index.js +0 -6
  90. package/Forms/Radio/Radio.js +0 -68
  91. package/Forms/Radio/index.js +0 -6
  92. package/Forms/Switch/Switch.js +0 -80
  93. package/Forms/Switch/index.js +0 -6
  94. package/Forms/Textarea/Textarea.js +0 -45
  95. package/Forms/Textarea/TextareaRich.js +0 -58
  96. package/Forms/Textarea/index.js +0 -7
  97. package/Forms/Toggle/Toggle-tailwind.js +0 -99
  98. package/Forms/Toggle/Toggle.js +0 -175
  99. package/Forms/Toggle/index.js +0 -6
  100. package/Forms/Toggle/useToggle-tailwind.js +0 -202
  101. package/Forms/Toggle/useToggle.js +0 -145
  102. package/Forms/antispam.js +0 -59
  103. package/Forms/helpers.js +0 -72
  104. package/Forms/index.js +0 -19
  105. package/Forms/styles.js +0 -94
  106. package/Gauge/Gauge.js +0 -111
  107. package/Grid/Grid.js +0 -106
  108. package/Grid/index.js +0 -6
  109. package/Hamburger/Hamburger.js +0 -90
  110. package/Hamburger/index.js +0 -6
  111. package/Header/index.js +0 -6
  112. package/Header/useHeader.js +0 -54
  113. package/Hidden/Hidden.js +0 -21
  114. package/Hidden/index.js +0 -6
  115. package/Img/index.js +0 -6
  116. package/Img/sc/bare.js +0 -43
  117. package/Img/types.js +0 -6
  118. package/Link/Link.js +0 -13
  119. package/Link/LinkBlank.js +0 -52
  120. package/Link/index.js +0 -7
  121. package/Menu/Menu.js +0 -22
  122. package/Menu/MenuMui.js +0 -165
  123. package/Menu/index.js +0 -6
  124. package/MenuItem/MenuItem.js +0 -31
  125. package/MenuItem/MenuItemMui.js +0 -32
  126. package/MenuItem/index.js +0 -6
  127. package/MenuItem/useMenuItem.js +0 -96
  128. package/Meta/Meta.js +0 -26
  129. package/Meta/index.js +0 -12
  130. package/NoJs/NoJs.js +0 -28
  131. package/NoJs/index.js +0 -12
  132. package/Pagination/PaginationNav.js +0 -126
  133. package/Pagination/PaginationResults.js +0 -45
  134. package/Pagination/index.js +0 -7
  135. package/Pill/Pill.js +0 -62
  136. package/Pill/index.js +0 -6
  137. package/Progress/ProgressCircular.js +0 -62
  138. package/Progress/ProgressLinear.js +0 -53
  139. package/Progress/ProgressOverlay.js +0 -75
  140. package/Progress/index.js +0 -8
  141. package/Rating/Rating.js +0 -188
  142. package/Rating/index.js +0 -85
  143. package/Select/SelectDownshift.js +0 -47
  144. package/Select/components.js +0 -44
  145. package/Select/index.js +0 -13
  146. package/Sidebar/Sidebar.js +0 -74
  147. package/Sidebar/index.js +0 -6
  148. package/Spacing/Spacing.js +0 -55
  149. package/Spacing/index.js +0 -6
  150. package/Sticky/Sticky.js +0 -228
  151. package/Sticky/StickyCss.js +0 -20
  152. package/Sticky/index.js +0 -19
  153. package/Tabs/TabsMui.js +0 -91
  154. package/Tabs/TabsMui.stories.js +0 -38
  155. package/Tabs/index.js +0 -6
  156. package/Tabs/sc/bare.js +0 -86
  157. package/Tabs/sc/index.stories.js +0 -1
  158. package/Tabs/tw/bare.js +0 -45
  159. package/Tabs/tw/index.stories.js +0 -46
  160. package/Tabs/tw/material.js +0 -44
  161. package/Tabs/useTabs.js +0 -66
  162. package/Typography/CopyPasteVisible.js +0 -17
  163. package/Typography/Native.js +0 -90
  164. package/Typography/ReadMore.js +0 -125
  165. package/Typography/TextLoop.js +0 -108
  166. package/Typography/TypeStairs.js +0 -71
  167. package/Typography/index.js +0 -10
  168. package/css/index.js +0 -33
  169. package/helpers/classed.js +0 -66
  170. package/helpers/classed.stories.js +0 -140
  171. package/helpers/createUseMediaQueryWidth.js +0 -193
  172. package/helpers/extend-component.js +0 -32
  173. package/helpers/index.js +0 -9
  174. package/helpers/mergeRefs.js +0 -30
  175. package/hooks/index.js +0 -92
  176. package/hooks/types.js +0 -6
  177. package/hooks/useAsyncFn.js +0 -56
  178. package/hooks/useDateLocale.js +0 -51
  179. package/hooks/useFirstMountState.js +0 -28
  180. package/hooks/useFixedOffset.js +0 -67
  181. package/hooks/useFocus.js +0 -30
  182. package/hooks/useInterval.js +0 -44
  183. package/hooks/useIsomorphicLayoutEffect.js +0 -23
  184. package/hooks/useKeyUp.js +0 -40
  185. package/hooks/useMeasure.js +0 -189
  186. package/hooks/useMountedState.js +0 -31
  187. package/hooks/useNavigateAway.js +0 -69
  188. package/hooks/usePrevious.js +0 -33
  189. package/hooks/usePreviousRef.js +0 -27
  190. package/hooks/useScrollPosition.js +0 -83
  191. package/hooks/useScrollThreshold.js +0 -52
  192. package/hooks/useScrollTo.js +0 -39
  193. package/hooks/useSmoothScroll.js +0 -49
  194. package/hooks/useSpinDelay.js +0 -59
  195. package/hooks/useTraceUpdate.js +0 -39
  196. package/hooks/useUpdateEffect.js +0 -30
  197. package/hooks/useWindowSize.js +0 -43
  198. package/index.js +0 -10
  199. package/m/MotionProvider.js +0 -27
  200. package/m/index.js +0 -10
  201. package/m/lite.js +0 -12
  202. package/m/max.js +0 -12
  203. package/sc/index.js +0 -49
  204. package/scm/index.js +0 -40
  205. package/shared/index.js +0 -13
  206. package/styles/Body.js +0 -28
  207. package/styles/Global.js +0 -55
  208. package/styles/index.js +0 -142
  209. package/styles/media.js +0 -139
  210. package/styles/spacing.js +0 -70
  211. package/styles/styled.js +0 -58
  212. package/styles/theme--vanilla.js +0 -82
  213. package/styles/theme.js +0 -49
  214. package/tw/index.js +0 -33
  215. package/twm/index.js +0 -33
  216. package/types.js +0 -4
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- SwitchTrack: function() {
13
- return SwitchTrack;
14
- },
15
- SwitchHandle: function() {
16
- return SwitchHandle;
17
- },
18
- Switch: function() {
19
- return Switch;
20
- }
21
- });
22
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _react = require("react");
25
- const _styledcomponents = /*#__PURE__*/ _interop_require_default._(require("styled-components"));
26
- const _styled = require("../../styles/styled");
27
- const _Checkbox = require("../Checkbox");
28
- const _Toggle = require("../Toggle");
29
- const _useToggle = require("../Toggle/useToggle");
30
- const SWITCH_GUTTER = 0.25;
31
- const SWITCH_HANDLE_SIZE = 1;
32
- const SwitchTrack = _styledcomponents.default.span`
33
- position: relative;
34
- width: ${SWITCH_HANDLE_SIZE * 3}em;
35
- height: ${SWITCH_HANDLE_SIZE * 1.5}em;
36
- padding: ${SWITCH_GUTTER}em;
37
- border-radius: ${SWITCH_HANDLE_SIZE}em;
38
- ${_Toggle.toggleBase}
39
-
40
- input:focus ~ & {
41
- ${_styled.stateFocus}
42
- }
43
-
44
- input:disabled ~ & {
45
- opacity: 0.5;
46
- cursor: not-allowed;
47
- }
48
- `;
49
- const SwitchHandle = _styledcomponents.default.span`
50
- position: absolute;
51
- width: ${SWITCH_HANDLE_SIZE}em;
52
- height: ${SWITCH_HANDLE_SIZE}em;
53
- left: ${SWITCH_GUTTER}em;
54
- margin-top: -1px;
55
- /* border: 1px solid currentColor; */
56
- background: currentColor;
57
- opacity: 0.5;
58
- border-radius: 100%;
59
- transition: all 0.18s ease-in-out;
60
-
61
- input:checked + ${SwitchTrack} & {
62
- opacity: 1;
63
- left: calc(100% - ${SWITCH_HANDLE_SIZE}em - ${SWITCH_GUTTER}em);
64
- }
65
- `;
66
- const Switch = /*#__PURE__*/ (0, _react.forwardRef)(function Switch(props, ref) {
67
- const { rootProps, Inputs, label } = (0, _useToggle.useToggle)(props, ref);
68
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_Checkbox.CheckboxRoot, {
69
- ...rootProps,
70
- children: [
71
- Inputs,
72
- /*#__PURE__*/ (0, _jsxruntime.jsx)(SwitchTrack, {
73
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(SwitchHandle, {})
74
- }),
75
- label && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Checkbox.CheckboxLabel, {
76
- children: label
77
- })
78
- ]
79
- });
80
- });
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- const _export_star = require("@swc/helpers/_/_export_star");
6
- _export_star._(require("./Switch"), exports);
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- TextareaNative: function() {
13
- return TextareaNative;
14
- },
15
- Textarea: function() {
16
- return Textarea;
17
- }
18
- });
19
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
20
- const _jsxruntime = require("react/jsx-runtime");
21
- const _react = require("react");
22
- const _styledcomponents = /*#__PURE__*/ _interop_require_default._(require("styled-components"));
23
- const _Label = require("../Label/Label");
24
- const _styles = require("../styles");
25
- const TextareaNative = _styledcomponents.default.textarea`
26
- ${_styles.inputBase}
27
- ${_styles.inputFocus}
28
- resize: vertical;
29
- `;
30
- const Textarea = /*#__PURE__*/ (0, _react.forwardRef)(function Textarea({ register, name, label, ...props }, ref) {
31
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
32
- children: [
33
- label && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Label.Label, {
34
- children: label
35
- }),
36
- /*#__PURE__*/ (0, _jsxruntime.jsx)(TextareaNative, {
37
- ...register ? register(name) : {
38
- name,
39
- ref
40
- },
41
- ...props
42
- })
43
- ]
44
- });
45
- });
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "TextareaRich", {
6
- enumerable: true,
7
- get: function() {
8
- return TextareaRich;
9
- }
10
- });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _jsxruntime = require("react/jsx-runtime");
13
- const _react = require("react");
14
- const _styledcomponents = /*#__PURE__*/ _interop_require_default._(require("styled-components"));
15
- const _Editor = require("../../Editor");
16
- const _Label = require("../Label/Label");
17
- const _helpers = require("../helpers");
18
- const Root = _styledcomponents.default.div`
19
- .ProseMirror {
20
- max-height: 160px;
21
- overflow: auto;
22
- }
23
- .EditorContent {
24
- position: relative;
25
- &:after {
26
- position: absolute;
27
- content: "";
28
- bottom: 0;
29
- left: 0;
30
- right: 16px; /* scrollbar width? */
31
- height: 3em;
32
- background: linear-gradient(0deg, white, white 33%, transparent);
33
- pointer-events: none;
34
- }
35
- }
36
- `;
37
- const TextareaRich = /*#__PURE__*/ (0, _react.forwardRef)(function TextareaRich({ register, setValue, name, label, defaultValue = "", onChange, ...props }, ref) {
38
- if (register) register(name);
39
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(Root, {
40
- children: [
41
- label && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Label.Label, {
42
- children: label
43
- }),
44
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_Editor.Editor, {
45
- options: {
46
- // element: <TextareaAutosize />,
47
- content: defaultValue,
48
- onUpdate: (onChange || setValue) && name ? ({ editor })=>{
49
- const value = editor.getHTML();
50
- if (setValue) setValue(name, value);
51
- (0, _helpers.triggerOnChange)(onChange, name, value);
52
- } : undefined
53
- },
54
- ...props
55
- })
56
- ]
57
- });
58
- });
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- const _export_star = require("@swc/helpers/_/_export_star");
6
- _export_star._(require("./Textarea"), exports);
7
- _export_star._(require("./TextareaRich"), exports);
@@ -1,99 +0,0 @@
1
- // /**
2
- // * @file
3
- // *
4
- // * About accessibility:
5
- // * - minimum target size of 44px https://www.w3.org/TR/WCAG21/#target-size
6
- // *
7
- // * @see tests on tailwind playground:
8
- // * - https://play.tailwindcss.com/RVldIcmZa5
9
- // */
10
- // import { type FormControlState } from "../FormControl";
11
- // import { FormControlStatefulElement } from "../FormControlStatefulElement";
12
- // export type ToggleProps = React.ComponentProps<"span">;
13
- // export const Toggle = ({ className = "", ...props }: ToggleProps) => {
14
- // return (
15
- // <span
16
- // className={`relative my-0 -mx-1 inline-flex h-8 w-8 items-center justify-center p-1 ${className}`}
17
- // {...props}
18
- // />
19
- // );
20
- // };
21
- // export type ToggleLabelProps = React.ComponentProps<"span">;
22
- // export const ToggleLabel = ({ className = "", ...props }: ToggleLabelProps) => {
23
- // return (
24
- // <span
25
- // className={`text-grey-200 ml-3 select-none ${className}`}
26
- // {...props}
27
- // />
28
- // );
29
- // };
30
- // export type ToggleLabelSubProps = React.ComponentProps<"small">;
31
- // export const ToggleLabelSub = ({
32
- // className = "",
33
- // ...props
34
- // }: ToggleLabelSubProps) => {
35
- // return (
36
- // <span
37
- // className={`text-xs opacity-70 ${className}`}
38
- // {...props}
39
- // />
40
- // );
41
- // };
42
- // export type ToggleIndicatorProps = FormControlState & {
43
- // className?: string;
44
- // };
45
- // export const ToggleIndicator = ({
46
- // className,
47
- // ...props
48
- // }: ToggleIndicatorProps) => {
49
- // return (
50
- // <FormControlStatefulElement
51
- // as="span"
52
- // className={`relative flex h-[24px] w-[24px] rounded-md border border-solid ${className}`}
53
- // {...props}
54
- // />
55
- // );
56
- // };
57
- // export type ToggleIndicatorFgProps = React.ComponentProps<"svg">;
58
- // export const ToggleIndicatorFg = ({
59
- // className = "",
60
- // ...props
61
- // }: ToggleIndicatorFgProps) => {
62
- // return (
63
- // <svg
64
- // className={`on-toggle-checked:scale-100 absolute left-0 h-full w-full scale-0 transition-transform ${className}`}
65
- // {...props}
66
- // />
67
- // );
68
- // };
69
- // export type ToggleIndicatorSquaredProps = ToggleIndicatorProps;
70
- // export const ToggleIndicatorSquared = (props: ToggleIndicatorSquaredProps) => {
71
- // return (
72
- // <ToggleIndicator {...props}>
73
- // <ToggleIndicatorFg viewBox="0 0 24 24">
74
- // <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" />
75
- // </ToggleIndicatorFg>
76
- // </ToggleIndicator>
77
- // );
78
- // };
79
- // export type ToggleIndicatorRoundedProps = ToggleIndicatorProps & {
80
- // /** @default 6 */
81
- // r?: number;
82
- // };
83
- // export const ToggleIndicatorRounded = ({
84
- // r = 6,
85
- // ...props
86
- // }: ToggleIndicatorRoundedProps) => {
87
- // return (
88
- // <ToggleIndicator {...props}>
89
- // <ToggleIndicatorFg viewBox="0 0 24 24">
90
- // <circle
91
- // r={r}
92
- // cx="12"
93
- // cy="12"
94
- // />
95
- // </ToggleIndicatorFg>
96
- // </ToggleIndicator>
97
- // );
98
- // };
99
- "use strict";
@@ -1,175 +0,0 @@
1
- /**
2
- * @file
3
- *
4
- * About accessibility:
5
- * - minimum target size of 44px https://www.w3.org/TR/WCAG21/#target-size
6
- */ "use strict";
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- function _export(target, all) {
11
- for(var name in all)Object.defineProperty(target, name, {
12
- enumerable: true,
13
- get: all[name]
14
- });
15
- }
16
- _export(exports, {
17
- toggleBase: function() {
18
- return toggleBase;
19
- },
20
- toggleIndicatorBg: function() {
21
- return toggleIndicatorBg;
22
- },
23
- toggleIndicatorBgShape: function() {
24
- return toggleIndicatorBgShape;
25
- },
26
- toggleIndicatorFg: function() {
27
- return toggleIndicatorFg;
28
- },
29
- Toggle: function() {
30
- return Toggle;
31
- },
32
- ToggleLabel: function() {
33
- return ToggleLabel;
34
- },
35
- ToggleLabelSub: function() {
36
- return ToggleLabelSub;
37
- },
38
- ToggleIndicatorHolder: function() {
39
- return ToggleIndicatorHolder;
40
- },
41
- ToggleIndicatorBgSquare: function() {
42
- return ToggleIndicatorBgSquare;
43
- },
44
- ToggleIndicatorBgCircle: function() {
45
- return ToggleIndicatorBgCircle;
46
- },
47
- ToggleIndicatorFg: function() {
48
- return ToggleIndicatorFg;
49
- },
50
- ToggleIndicatorSquared: function() {
51
- return ToggleIndicatorSquared;
52
- },
53
- ToggleIndicatorRounded: function() {
54
- return ToggleIndicatorRounded;
55
- }
56
- });
57
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
58
- const _jsxruntime = require("react/jsx-runtime");
59
- const _react = require("react");
60
- const _styledcomponents = /*#__PURE__*/ _interop_require_default._(require("styled-components"));
61
- const _styled = require("../../styles/styled");
62
- const toggleBase = `
63
- border: 1px solid var(--forms-border-color);
64
- `;
65
- const toggleIndicatorBg = `
66
- display: inline-block;
67
- flex-shrink: 0;
68
- width: 100%;
69
- height: 100%;
70
- `;
71
- const toggleIndicatorBgShape = `
72
- ${toggleIndicatorBg}
73
- fill: none;
74
- stroke-width: 2px;
75
- stroke: var(--forms-border-color);
76
- `;
77
- const toggleIndicatorFg = `
78
- position: absolute;
79
- left: 0;
80
- width: 100%;
81
- height: 100%;
82
- fill: currentcolor;
83
- `;
84
- const Toggle = _styledcomponents.default.span`
85
- position: relative;
86
- display: inline-flex;
87
- align-items: center;
88
- justify-content: center;
89
- width: 2em;
90
- height: 2em;
91
- margin: 0 -0.3em; /* rtl */
92
- padding: 0.3em;
93
- `;
94
- const ToggleLabel = _styledcomponents.default.span`
95
- margin-left: 0.6em; /* rtl */
96
- `;
97
- const ToggleLabelSub = _styledcomponents.default.small`
98
- opacity: 0.7;
99
- font-size: 0.7em;
100
- `;
101
- const ToggleIndicatorHolder = _styledcomponents.default.span`
102
- position: relative;
103
- display: flex;
104
-
105
- input:focus ~ & {
106
- ${_styled.stateFocus}
107
- }
108
- `;
109
- const ToggleIndicatorBgSquare = _styledcomponents.default.svg`
110
- ${toggleIndicatorBgShape}
111
- `;
112
- const ToggleIndicatorBgCircle = _styledcomponents.default.svg`
113
- ${toggleIndicatorBgShape}
114
- `;
115
- const ToggleIndicatorFg = _styledcomponents.default.svg`
116
- ${toggleIndicatorFg}
117
- transform: scale(0);
118
- transition: transform 0.18s ease;
119
-
120
- input:checked + ${ToggleIndicatorHolder} & {
121
- transform: scale(1);
122
- }
123
- `;
124
- const ToggleIndicatorSquared = (props)=>{
125
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(ToggleIndicatorHolder, {
126
- children: [
127
- /*#__PURE__*/ (0, _jsxruntime.jsx)(ToggleIndicatorBgSquare, {
128
- viewBox: "0 0 24 24",
129
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)("rect", {
130
- width: "24",
131
- height: "24"
132
- })
133
- }),
134
- /*#__PURE__*/ (0, _jsxruntime.jsx)(ToggleIndicatorFg, {
135
- viewBox: "0 0 24 24",
136
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)("path", {
137
- d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"
138
- })
139
- })
140
- ]
141
- });
142
- };
143
- const ToggleIndicatorRounded = ({ r = 6 })=>{
144
- const id = (0, _react.useId)();
145
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(ToggleIndicatorHolder, {
146
- children: [
147
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(ToggleIndicatorBgCircle, {
148
- viewBox: "0 0 24 24",
149
- children: [
150
- /*#__PURE__*/ (0, _jsxruntime.jsx)("circle", {
151
- cy: "12",
152
- cx: "12",
153
- r: "12",
154
- id: `r_${id}`,
155
- clipPath: `url(#c_${id})`
156
- }),
157
- /*#__PURE__*/ (0, _jsxruntime.jsx)("clipPath", {
158
- id: `c_${id}`,
159
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)("use", {
160
- xlinkHref: `#r_${id}`
161
- })
162
- })
163
- ]
164
- }),
165
- /*#__PURE__*/ (0, _jsxruntime.jsx)(ToggleIndicatorFg, {
166
- viewBox: "0 0 24 24",
167
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)("circle", {
168
- r: r,
169
- cx: "12",
170
- cy: "12"
171
- })
172
- })
173
- ]
174
- });
175
- };
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- const _export_star = require("@swc/helpers/_/_export_star");
6
- _export_star._(require("./Toggle"), exports);
@@ -1,202 +0,0 @@
1
- // import React, { useCallback, useId, useMemo } from "react";
2
- // import type { Option } from "@koine/react";
3
- // import type { FormControlElementProps } from "../FormControl";
4
- // export type UseToggleProps = FormControlElementProps<React.FC> & {
5
- // // defaultChecked?: boolean;
6
- // value?: boolean;
7
- // valueTrue?: string;
8
- // valueFalse?: string;
9
- // options?: Option[];
10
- // };
11
- // /**
12
- // * This hook is meant to power Checkboxes, Switches and checkbox-like Radios
13
- // * components, it works in fact in two modes:
14
- // *
15
- // * 1: behaviour as standard checkbox
16
- // * yup validation would simply look like:
17
- // *
18
- // * ```ts
19
- // * privacy: boolean().required(),
20
- // * ```
21
- // *
22
- // * 1b: to make the checkbox required (either with `true` or `false`):
23
- // * ```
24
- // * privacy: boolean().oneOf([true]).required()
25
- // * ```
26
- // *
27
- // * 2: beahviour as two radio for checkbox with custom true/false values as
28
- // * strings yup validation would look like:
29
- // *
30
- // * ```ts
31
- // * newsletter: string().oneOf(["yes", "no"]).required(),
32
- // * // add `.nullable()` if you do not provide a string `defaultValue`
33
- // *
34
- // * // to do not make it required and avoid triggering an error when the input is
35
- // * // untouched you need to set the default value of the input in the form
36
- // * // initialization's `defaultValues` as such:
37
- // *
38
- // * useForm({ defaultValues: { newsletter: "no" }})
39
- // * ```
40
- // *
41
- // * To enable this mode either pass the props `valueTrue` and `valueFalse` or
42
- // * an array of options with the shape of `Option`
43
- // */
44
- // export function useToggle(
45
- // props: UseToggleProps,
46
- // ref: React.ForwardedRef<HTMLInputElement>
47
- // ) {
48
- // const {
49
- // actions,
50
- // form: { watch, register },
51
- // name,
52
- // state,
53
- // strings: { label },
54
- // options,
55
- // value: propValue,
56
- // ...restProps
57
- // } = props;
58
- // let {
59
- // valueTrue,
60
- // valueFalse,
61
- // // defaultChecked,
62
- // // defaultValue,
63
- // // eslint-disable-next-line prefer-const
64
- // // ...remainingInputProps
65
- // } = restProps;
66
- // // use options data convention to pass on the true/false values
67
- // if (options) {
68
- // valueTrue = options
69
- // .filter((opt) => opt.value === "true")[0]
70
- // .label.toString();
71
- // valueFalse = options
72
- // .filter((opt) => opt.value === "false")[0]
73
- // .label.toString();
74
- // }
75
- // const id = useId();
76
- // const idTrue = `${id}-true`;
77
- // const idFalse = `${id}-false`;
78
- // const isRadio = !!(valueTrue && valueFalse);
79
- // // // manage default values for both toggle modes
80
- // // defaultChecked = isUndefined(defaultChecked) ? false : defaultChecked;
81
- // // // TODO: maybe throw an error if the defaultValue that arrives here is not
82
- // // // a valid value
83
- // // defaultValue =
84
- // // defaultValue === valueTrue || defaultValue === valueFalse
85
- // // ? defaultValue
86
- // // : valueFalse;
87
- // // get the value either from the uncontrolled watched input or from the given
88
- // // prop to control the component
89
- // let value = watch(name);
90
- // if (propValue) {
91
- // value = propValue;
92
- // }
93
- // /**
94
- // * Accessibility.
95
- // *
96
- // * Fake the spacebar keyboard behaviour on the radio mode of the checkbox.
97
- // * Without this *only* the arrow keys would change the checkbox state
98
- // */
99
- // const handleKeyDown: React.KeyboardEventHandler<HTMLInputElement> =
100
- // useCallback(
101
- // (event) => {
102
- // if (event.key === " ") {
103
- // event.preventDefault();
104
- // event.stopPropagation();
105
- // const firstInput = event.target as HTMLInputElement;
106
- // const next = firstInput.nextElementSibling as HTMLInputElement;
107
- // const prev = firstInput.previousElementSibling as HTMLInputElement;
108
- // const secondInput = next?.tagName === "INPUT" ? next : prev;
109
- // let target = firstInput;
110
- // if (firstInput.checked) {
111
- // target = secondInput;
112
- // } else {
113
- // if (!secondInput.checked) {
114
- // target =
115
- // firstInput.value === valueTrue ? firstInput : secondInput;
116
- // }
117
- // }
118
- // if (target) target.click();
119
- // }
120
- // },
121
- // [valueTrue]
122
- // );
123
- // // collect all the return values that are dependent on the current value
124
- // // of the input
125
- // const valueDependentProps = useMemo(
126
- // () => ({
127
- // rootProps: {
128
- // htmlFor: isRadio
129
- // ? !value || value === valueFalse
130
- // ? idTrue
131
- // : idFalse
132
- // : id,
133
- // },
134
- // label: label ? label : value,
135
- // value,
136
- // }),
137
- // [value, valueFalse, isRadio, id, idTrue, idFalse, label]
138
- // );
139
- // const Inputs = useMemo(
140
- // () =>
141
- // isRadio ? (
142
- // <>
143
- // <input
144
- // className="peer sr-only"
145
- // id={idFalse}
146
- // {...register(name, {
147
- // onBlur: () => actions.setFocused(false),
148
- // })}
149
- // onFocus={() => actions.setFocused(true)}
150
- // // {...remainingInputProps}
151
- // onKeyDown={handleKeyDown}
152
- // type="radio"
153
- // value={valueFalse}
154
- // // defaultChecked={defaultValue === valueFalse}
155
- // />
156
- // <input
157
- // className="peer sr-only"
158
- // id={idTrue}
159
- // {...register(name, {
160
- // onBlur: () => actions.setFocused(false),
161
- // })}
162
- // onFocus={() => actions.setFocused(true)}
163
- // // {...remainingInputProps}
164
- // onKeyDown={handleKeyDown}
165
- // type="radio"
166
- // value={valueTrue}
167
- // // defaultChecked={defaultValue === valueTrue}
168
- // />
169
- // </>
170
- // ) : (
171
- // <input
172
- // className="peer sr-only"
173
- // id={id}
174
- // type="checkbox"
175
- // {...register(name, { onBlur: () => actions.setFocused(false) })}
176
- // onFocus={() => actions.setFocused(true)}
177
- // // {...remainingInputProps}
178
- // // defaultChecked={defaultChecked}
179
- // />
180
- // ),
181
- // [
182
- // name,
183
- // actions,
184
- // // remainingInputProps,
185
- // handleKeyDown,
186
- // isRadio,
187
- // idFalse,
188
- // idTrue,
189
- // valueFalse,
190
- // valueTrue,
191
- // id,
192
- // // defaultChecked,
193
- // // defaultValue,
194
- // ]
195
- // );
196
- // // console.log("useToggle: render", value);
197
- // return {
198
- // ...valueDependentProps,
199
- // Inputs,
200
- // };
201
- // }
202
- "use strict";