@koine/react 1.1.8 → 1.1.10

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 (82) hide show
  1. package/Autocomplete/AutocompleteDownshift.js +1 -1
  2. package/Autocomplete/AutocompleteDownshiftMultiselect.js +1 -1
  3. package/Autocomplete/AutocompleteMui.js +1 -1
  4. package/Autocomplete/AutocompleteReach.js +1 -1
  5. package/Autocomplete/helpers.js +2 -1
  6. package/Breadcrumbs/Breadcrumbs.js +1 -1
  7. package/Calendar/calendar-api-google.js +3 -1
  8. package/Details/Details.d.ts +1 -1
  9. package/Dialog/DialogMui.d.ts +2 -2
  10. package/Dialog/tw/bare.d.ts +6 -6
  11. package/Dialog/tw/elegant.d.ts +6 -6
  12. package/Dialog/tw/framer.d.ts +2 -2
  13. package/Dialog/tw/framerMaterial.d.ts +4 -4
  14. package/Dialog/tw/material.d.ts +6 -6
  15. package/Form/Form.d.ts +1 -1
  16. package/Form/Form.js +1 -1
  17. package/Forms/Checkbox/Checkbox.d.ts +1 -1
  18. package/Forms/Field/FieldControl.js +1 -1
  19. package/Forms/Input/Input.d.ts +1 -1
  20. package/Forms/Password/Password.d.ts +1 -1
  21. package/Forms/Radio/Radio.d.ts +1 -1
  22. package/Forms/Switch/Switch.d.ts +1 -1
  23. package/Forms/antispam.d.ts +1 -1
  24. package/Forms/antispam.js +3 -1
  25. package/Forms/helpers.js +2 -1
  26. package/Header/useHeader.d.ts +1 -1
  27. package/Header/useHeader.js +1 -0
  28. package/Menu/MenuMui.js +1 -1
  29. package/MenuItem/MenuItemMui.js +1 -1
  30. package/Pagination/PaginationNav.js +1 -1
  31. package/Spacing/Spacing.js +1 -1
  32. package/Tabs/TabsMui.d.ts +2 -2
  33. package/Tabs/tw/material.d.ts +6 -6
  34. package/helpers/classed.d.ts +7 -2
  35. package/helpers/classed.js +7 -2
  36. package/helpers/createUseMediaQueryWidth.d.ts +1 -1
  37. package/helpers/createUseMediaQueryWidth.js +5 -3
  38. package/hooks/useFixedOffset.js +6 -3
  39. package/hooks/useInterval.js +1 -1
  40. package/hooks/useIsomorphicLayoutEffect.js +1 -1
  41. package/hooks/useKeyUp.js +1 -1
  42. package/hooks/useMeasure.js +6 -2
  43. package/hooks/useNavigateAway.js +1 -1
  44. package/hooks/useScrollPosition.js +3 -3
  45. package/hooks/useScrollThreshold.js +2 -2
  46. package/hooks/useScrollTo.js +2 -2
  47. package/hooks/useSmoothScroll.js +4 -3
  48. package/hooks/useWindowSize.d.ts +1 -1
  49. package/hooks/useWindowSize.js +2 -1
  50. package/m/MotionProvider.d.ts +1 -1
  51. package/node/Autocomplete/AutocompleteDownshift.js +1 -1
  52. package/node/Autocomplete/AutocompleteDownshiftMultiselect.js +1 -1
  53. package/node/Autocomplete/AutocompleteMui.js +6 -6
  54. package/node/Autocomplete/AutocompleteReach.js +1 -1
  55. package/node/Autocomplete/helpers.js +6 -4
  56. package/node/Breadcrumbs/Breadcrumbs.js +2 -2
  57. package/node/Calendar/calendar-api-google.js +9 -7
  58. package/node/Form/Form.js +1 -1
  59. package/node/Forms/Field/FieldControl.js +2 -2
  60. package/node/Forms/antispam.js +7 -4
  61. package/node/Forms/helpers.js +5 -3
  62. package/node/Header/useHeader.js +1 -0
  63. package/node/Menu/MenuMui.js +2 -2
  64. package/node/MenuItem/MenuItemMui.js +2 -2
  65. package/node/Pagination/PaginationNav.js +4 -4
  66. package/node/Spacing/Spacing.js +2 -2
  67. package/node/helpers/classed.js +7 -2
  68. package/node/helpers/createUseMediaQueryWidth.js +11 -8
  69. package/node/hooks/useFixedOffset.js +13 -9
  70. package/node/hooks/useInterval.js +2 -2
  71. package/node/hooks/useIsomorphicLayoutEffect.js +3 -2
  72. package/node/hooks/useKeyUp.js +2 -2
  73. package/node/hooks/useMeasure.js +12 -8
  74. package/node/hooks/useNavigateAway.js +3 -2
  75. package/node/hooks/useScrollPosition.js +8 -7
  76. package/node/hooks/useScrollThreshold.js +5 -4
  77. package/node/hooks/useScrollTo.js +5 -4
  78. package/node/hooks/useSmoothScroll.js +10 -8
  79. package/node/hooks/useWindowSize.js +5 -3
  80. package/node/styles/theme--vanilla.js +10 -7
  81. package/package.json +8 -5
  82. package/styles/theme--vanilla.js +5 -2
@@ -8,8 +8,7 @@ type ClassedFinalProps<Props, Component> = Component extends React.ReactHTML ? R
8
8
  * This utility allows to extend a component a là `styled-components` but for
9
9
  * a className based styling solution like Tailwind,
10
10
  *
11
- * It also plays nicely with tailwind intellisense @see:
12
- *
11
+ * It also plays nicely with tailwind intellisense:
13
12
  * - https://github.com/tailwindlabs/tailwindcss-intellisense#tailwindcssclassattributes
14
13
  *
15
14
  * For references about tagged functions:
@@ -17,6 +16,12 @@ type ClassedFinalProps<Props, Component> = Component extends React.ReactHTML ? R
17
16
  * - https://makersden.io/blog/reverse-engineering-styled-components
18
17
  * - https://typesafe.blog/article/the-logic-behind-javascript-tag-functions
19
18
  * - https://flaming.codes/posts/typescript-and-javascript-tagged-template-strings
19
+ *
20
+ * Similar projects:
21
+ * - https://reactjsexample.com/style-radix-ui-components-with-tailwindcss/
22
+ *
23
+ * Discussions and Q/A:
24
+ * - https://stackoverflow.com/q/73055695/1938970
20
25
  */
21
26
  export declare function classed<Props, Component extends React.ElementType = any>(component: Component): (strings: TemplateStringsArray, ...args: string[] | ((props: Props) => string)[]) => React.ForwardRefExoticComponent<React.PropsWithoutRef<ClassedFinalProps<Props, Component>> & React.RefAttributes<Component>>;
22
27
  export default classed;
@@ -4,8 +4,7 @@ import { createElement, forwardRef } from "react";
4
4
  * This utility allows to extend a component a là `styled-components` but for
5
5
  * a className based styling solution like Tailwind,
6
6
  *
7
- * It also plays nicely with tailwind intellisense @see:
8
- *
7
+ * It also plays nicely with tailwind intellisense:
9
8
  * - https://github.com/tailwindlabs/tailwindcss-intellisense#tailwindcssclassattributes
10
9
  *
11
10
  * For references about tagged functions:
@@ -13,6 +12,12 @@ import { createElement, forwardRef } from "react";
13
12
  * - https://makersden.io/blog/reverse-engineering-styled-components
14
13
  * - https://typesafe.blog/article/the-logic-behind-javascript-tag-functions
15
14
  * - https://flaming.codes/posts/typescript-and-javascript-tagged-template-strings
15
+ *
16
+ * Similar projects:
17
+ * - https://reactjsexample.com/style-radix-ui-components-with-tailwindcss/
18
+ *
19
+ * Discussions and Q/A:
20
+ * - https://stackoverflow.com/q/73055695/1938970
16
21
  */
17
22
  export function classed(component) {
18
23
  // @ts-expect-error nevermind for now...
@@ -1,4 +1,4 @@
1
- import { type GetMediaQueryWidthResolversBreakpoints } from "@koine/utils";
1
+ import { type GetMediaQueryWidthResolversBreakpoints } from "@koine/utils/getMediaQueryWidthResolvers";
2
2
  type _MediaQuerWidthDefExplicit<TBreakpoint extends string> = `min-${TBreakpoint}` | `max-${TBreakpoint}` | `up-${TBreakpoint}` | `down-${TBreakpoint}` | `between-${TBreakpoint}_${TBreakpoint}` | `only-${TBreakpoint}`;
3
3
  export type MediaQuerWidthDef<TBreakpoint extends string> = `${TBreakpoint}` | _MediaQuerWidthDefExplicit<TBreakpoint>;
4
4
  export type MediaQueryWidth<TBreakpoint extends string> = `@${MediaQuerWidthDef<TBreakpoint>}`;
@@ -1,6 +1,7 @@
1
1
  import { useState } from "react";
2
- import { isUndefined, getMediaQueryWidthResolvers, } from "@koine/utils";
3
- import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect";
2
+ import isUndefined from "@koine/utils/isUndefined";
3
+ import getMediaQueryWidthResolvers from "@koine/utils/getMediaQueryWidthResolvers";
4
+ import useIsomorphicLayoutEffect from "../hooks/useIsomorphicLayoutEffect";
4
5
  /**
5
6
  * Use `null` instead of `false` as default value, @see https://observablehq.com/@werehamster/avoiding-hydration-mismatch-when-using-react-hooks
6
7
  *
@@ -54,7 +55,8 @@ export default createUseMediaQueryWidth;
54
55
  //// without creator it would be:
55
56
  //// ---------------------------------------------------------------------------
56
57
  // import { useState, useIsomorphicLayoutEffect, useMemo } from "react";
57
- // import { isBrowser, type Split } from "@koine/utils";
58
+ // import type { Split } from "@koine/utils";
59
+ // import isBrowser from "@koine/utils/isBrowser";
58
60
  // import { breakpoints as themeBreakpoints } from "@/config/theme/breakpoints";
59
61
  // import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect"
60
62
  // type Breakpoint = "xs" | "sm" | "md" | "lg" | "xl";
@@ -1,7 +1,10 @@
1
1
  import { useRef } from "react";
2
- import { injectCss, calculateFixedOffset, listenResizeDebounced, $each, } from "@koine/dom";
3
- import { debounce } from "@koine/utils";
4
- import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
2
+ import injectCss from "@koine/dom/injectCss";
3
+ import calculateFixedOffset from "@koine/dom/calculateFixedOffset";
4
+ import listenResizeDebounced from "@koine/dom/listenResizeDebounced";
5
+ import $each from "@koine/dom/$each";
6
+ import debounce from "@koine/utils/debounce";
7
+ import useIsomorphicLayoutEffect from "./useIsomorphicLayoutEffect";
5
8
  var inject = function (value) {
6
9
  injectCss("useFixedOffset", "html{scroll-padding-top: ".concat(value, "px}"));
7
10
  };
@@ -1,6 +1,6 @@
1
1
  import { __spreadArray } from "tslib";
2
2
  import { useEffect, useRef } from "react";
3
- import { noop } from "@koine/utils";
3
+ import noop from "@koine/utils/noop";
4
4
  /**
5
5
  * @borrows [dan abramov](https://overreacted.io/making-setinterval-declarative-with-react-hooks/)
6
6
  *
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useLayoutEffect } from "react";
2
- import { isBrowser } from "@koine/utils";
2
+ import isBrowser from "@koine/utils/isBrowser";
3
3
  /**
4
4
  * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useFirstMountState.ts)
5
5
  */
package/hooks/useKeyUp.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { __spreadArray } from "tslib";
2
2
  import { useEffect } from "react";
3
- import { on } from "@koine/dom";
3
+ import on from "@koine/dom/on";
4
4
  export function useKeyUp(callback, deps) {
5
5
  if (deps === void 0) { deps = []; }
6
6
  useEffect(function () {
@@ -1,7 +1,11 @@
1
1
  import { __spreadArray } from "tslib";
2
2
  import { useEffect, useState, useRef, useMemo } from "react";
3
- import { debounce, noop } from "@koine/utils";
4
- import { listenResizeDebounced, listenScrollDebounced, on, off, } from "@koine/dom";
3
+ import debounce from "@koine/utils/debounce";
4
+ import noop from "@koine/utils/noop";
5
+ import listenResizeDebounced from "@koine/dom/listenResizeDebounced";
6
+ import listenScrollDebounced from "@koine/dom/listenScrollDebounced";
7
+ import on from "@koine/dom/on";
8
+ import off from "@koine/dom/off";
5
9
  var observer;
6
10
  // Returns a list of scroll offsets
7
11
  function findScrollContainers(element) {
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useRef } from "react";
2
- import { on } from "@koine/dom";
2
+ import on from "@koine/dom/on";
3
3
  // type UseNavigateAwayPagehideHandler = (event: PageTransitionEvent) => unknown;
4
4
  /**
5
5
  * @resources
@@ -1,7 +1,7 @@
1
1
  import { useRef } from "react";
2
- import { isBrowser } from "@koine/utils";
3
- import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
4
- import { listenScroll } from "@koine/dom";
2
+ import isBrowser from "@koine/utils/isBrowser";
3
+ import listenScroll from "@koine/dom/listenScroll";
4
+ import useIsomorphicLayoutEffect from "./useIsomorphicLayoutEffect";
5
5
  var zeroPosition = { x: 0, y: 0 };
6
6
  var getClientRect = function (element) {
7
7
  return element === null || element === void 0 ? void 0 : element.getBoundingClientRect();
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useState } from "react";
2
- import { noop } from "@koine/utils";
3
- import { listenScroll } from "@koine/dom";
2
+ import noop from "@koine/utils/noop";
3
+ import listenScroll from "@koine/dom/listenScroll";
4
4
  export var useScrollThreshold = function (threshold, callback) {
5
5
  var _a = useState(false), isBelow = _a[0], setIsBelow = _a[1];
6
6
  var handler = useCallback(function () {
@@ -1,5 +1,5 @@
1
- import { isBrowser } from "@koine/utils";
2
- import { useHeader } from "../Header/useHeader";
1
+ import isBrowser from "@koine/utils/isBrowser";
2
+ import useHeader from "../Header/useHeader";
3
3
  export function useScrollTo(id, offset) {
4
4
  if (id === void 0) { id = ""; }
5
5
  if (offset === void 0) { offset = 0; }
@@ -1,7 +1,8 @@
1
1
  import { useCallback } from "react";
2
- import { isNumber } from "@koine/utils";
3
- import { getOffsetTopSlim, scrollTo } from "@koine/dom";
4
- import { useFixedOffset } from "./useFixedOffset";
2
+ import isNumber from "@koine/utils/isNumber";
3
+ import getOffsetTopSlim from "@koine/dom/getOffsetTopSlim";
4
+ import scrollTo from "@koine/dom/scrollTo";
5
+ import useFixedOffset from "./useFixedOffset";
5
6
  /**
6
7
  *
7
8
  * @param disregardAutomaticFixedOffset When the `to` scroll argument is a DOM
@@ -1,4 +1,4 @@
1
- import { debounce } from "@koine/utils";
1
+ import debounce from "@koine/utils/debounce";
2
2
  /**
3
3
  * # Use `window` size
4
4
  *
@@ -1,5 +1,6 @@
1
1
  import { useEffect, useState } from "react";
2
- import { listenResize, listenResizeDebounced } from "@koine/dom";
2
+ import listenResize from "@koine/dom/listenResize";
3
+ import listenResizeDebounced from "@koine/dom/listenResizeDebounced";
3
4
  /**
4
5
  * # Use `window` size
5
6
  *
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { LazyProps } from "framer-motion";
2
+ import { type LazyProps } from "framer-motion";
3
3
  export type MotionProviderFeatures = LazyProps["features"];
4
4
  export type MotionProviderProps = LazyProps & React.PropsWithChildren<{}>;
5
5
  /**
@@ -13,7 +13,7 @@ exports.Autocomplete = null;
13
13
  // CSSProperties,
14
14
  // } from "react";
15
15
  // import { useCombobox } from "downshift";
16
- // import { SetRequired } from "@koine/utils";
16
+ // import type { SetRequired } from "@koine/utils";
17
17
  // // import debounce from "lodash.debounce";
18
18
  // import {
19
19
  // AutocompleteRoot,
@@ -14,7 +14,7 @@ exports.Autocomplete = null;
14
14
  // ComponentPropsWithRef,
15
15
  // CSSProperties,
16
16
  // } from "react";
17
- // import { SetRequired } from "@koine/utils";
17
+ // import type { SetRequired } from "@koine/utils";
18
18
  // import {
19
19
  // useCombobox,
20
20
  // useMultipleSelection,
@@ -5,7 +5,7 @@ var tslib_1 = require("tslib");
5
5
  var jsx_runtime_1 = require("react/jsx-runtime");
6
6
  var react_1 = require("react");
7
7
  var AutocompleteUnstyled_1 = require("@mui/base/AutocompleteUnstyled");
8
- var utils_1 = require("@koine/utils");
8
+ var isString_1 = tslib_1.__importDefault(require("@koine/utils/isString"));
9
9
  var helpers_1 = require("../Forms/helpers");
10
10
  var helpers_2 = require("./helpers");
11
11
  var components_1 = require("./components");
@@ -135,13 +135,13 @@ var Autocomplete = function (_a) {
135
135
  },
136
136
  // support both freeSolo free text and full option structure
137
137
  isOptionEqualToValue: function (option, value) {
138
- var optValue = (0, utils_1.isString)(option) ? option : option.value;
139
- var valValue = (0, utils_1.isString)(value) ? value : value.value;
138
+ var optValue = (0, isString_1.default)(option) ? option : option.value;
139
+ var valValue = (0, isString_1.default)(value) ? value : value.value;
140
140
  return optValue === valValue;
141
141
  },
142
142
  getOptionLabel: function (option) {
143
143
  // @ts-expect-error TODO: I don't get this error
144
- return (0, utils_1.isString)(option) ? option : option.label || "";
144
+ return (0, isString_1.default)(option) ? option : option.label || "";
145
145
  },
146
146
  }), getRootProps = _e.getRootProps, getInputLabelProps = _e.getInputLabelProps, getInputProps = _e.getInputProps, getTagProps = _e.getTagProps, getListboxProps = _e.getListboxProps, getOptionProps = _e.getOptionProps, getPopupIndicatorProps = _e.getPopupIndicatorProps, groupedOptions = _e.groupedOptions, stateValue = _e.value, setAnchorEl = _e.setAnchorEl, popupOpen = _e.popupOpen, focused = _e.focused;
147
147
  var value = typeof controlledValue !== "undefined" ? controlledValue : stateValue;
@@ -171,10 +171,10 @@ var Autocomplete = function (_a) {
171
171
  return ((0, jsx_runtime_1.jsxs)(components_1.AutocompleteRoot, { children: [label && ((0, jsx_runtime_1.jsx)(components_1.AutocompleteLabel, tslib_1.__assign({}, getInputLabelProps(), { children: label }))), (0, jsx_runtime_1.jsxs)(components_1.AutocompleteWrap, tslib_1.__assign({}, getRootProps(), { "data-focus": focused }, { children: [(0, jsx_runtime_1.jsxs)(components_1.AutocompleteInner, tslib_1.__assign({ ref: setAnchorEl }, { children: [multiple &&
172
172
  value.map(function (valueItem, index) {
173
173
  var _a = getTagProps({ index: index }), onDelete = _a.onDelete, key = _a.key, tagProps = tslib_1.__rest(_a, ["onDelete", "key"]);
174
- return ((0, jsx_runtime_1.jsxs)(components_1.AutocompleteItem, tslib_1.__assign({}, tagProps, { children: [(0, jsx_runtime_1.jsx)(components_1.AutocompleteItemLabel, { children: (0, utils_1.isString)(valueItem)
174
+ return ((0, jsx_runtime_1.jsxs)(components_1.AutocompleteItem, tslib_1.__assign({}, tagProps, { children: [(0, jsx_runtime_1.jsx)(components_1.AutocompleteItemLabel, { children: (0, isString_1.default)(valueItem)
175
175
  ? valueItem
176
176
  : valueItem.Label || valueItem.label }), (0, jsx_runtime_1.jsx)(components_1.AutocompleteItemRemove, tslib_1.__assign({ onClick: onDelete }, { children: "\u2715" }))] }), key));
177
- }), (0, jsx_runtime_1.jsx)(components_1.AutocompleteInput, tslib_1.__assign({}, inputProps(), { placeholder: placeholder }))] })), !!options.length && ((0, jsx_runtime_1.jsx)(components_1.AutocompleteInputArrow, tslib_1.__assign({}, getPopupIndicatorProps(), { isOpen: popupOpen }))), loading && (0, jsx_runtime_1.jsx)(styles_1.InputProgress, {})] })), groupedOptions.length ? ((0, jsx_runtime_1.jsx)(components_1.AutocompleteMenu, tslib_1.__assign({}, getListboxProps(), { children: groupedOptions.map(function (option, index) { return ((0, jsx_runtime_1.jsx)(components_1.AutocompleteMenuItem, tslib_1.__assign({}, getOptionProps({ option: option, index: index }), { children: (0, utils_1.isString)(option) ? option : option.Label || option.label }), index)); }) }))) : null, children] }));
177
+ }), (0, jsx_runtime_1.jsx)(components_1.AutocompleteInput, tslib_1.__assign({}, inputProps(), { placeholder: placeholder }))] })), !!options.length && ((0, jsx_runtime_1.jsx)(components_1.AutocompleteInputArrow, tslib_1.__assign({}, getPopupIndicatorProps(), { isOpen: popupOpen }))), loading && (0, jsx_runtime_1.jsx)(styles_1.InputProgress, {})] })), groupedOptions.length ? ((0, jsx_runtime_1.jsx)(components_1.AutocompleteMenu, tslib_1.__assign({}, getListboxProps(), { children: groupedOptions.map(function (option, index) { return ((0, jsx_runtime_1.jsx)(components_1.AutocompleteMenuItem, tslib_1.__assign({}, getOptionProps({ option: option, index: index }), { children: (0, isString_1.default)(option) ? option : option.Label || option.label }), index)); }) }))) : null, children] }));
178
178
  // });
179
179
  };
180
180
  exports.Autocomplete = Autocomplete;
@@ -27,7 +27,7 @@ exports.Autocomplete = null;
27
27
  // AutocompleteLabel,
28
28
  // } from "./components";
29
29
  // import type { Option } from "../types";
30
- // import { SetRequired } from "@koine/utils";
30
+ // import type { SetRequired } from "@koine/utils";
31
31
  // export type AutocompleteOption =
32
32
  // | null
33
33
  // | (Option & {
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normaliseAutocompleteValue = void 0;
4
- var utils_1 = require("@koine/utils");
4
+ var tslib_1 = require("tslib");
5
+ var isString_1 = tslib_1.__importDefault(require("@koine/utils/isString"));
6
+ var isArray_1 = tslib_1.__importDefault(require("@koine/utils/isArray"));
5
7
  // export function normaliseAutocompleteValue(
6
8
  // value?: AutocompleteValue,
7
9
  // asArray?: true
@@ -18,12 +20,12 @@ function normaliseAutocompleteValue(value, asArray) {
18
20
  if (!value) {
19
21
  return asArray ? [""] : "";
20
22
  }
21
- if ((0, utils_1.isString)(value)) {
23
+ if ((0, isString_1.default)(value)) {
22
24
  return asArray ? [value] : value;
23
25
  }
24
- if ((0, utils_1.isArray)(value)) {
26
+ if ((0, isArray_1.default)(value)) {
25
27
  var values = value.map(function (valueItem) {
26
- return (0, utils_1.isString)(valueItem) ? valueItem : valueItem.value;
28
+ return (0, isString_1.default)(valueItem) ? valueItem : valueItem.value;
27
29
  });
28
30
  return asArray ? values : values.join(",");
29
31
  }
@@ -6,7 +6,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
6
6
  var styled_components_1 = tslib_1.__importStar(require("styled-components"));
7
7
  var framer_motion_1 = require("framer-motion");
8
8
  var md_1 = require("react-icons/md");
9
- var utils_1 = require("@koine/utils");
9
+ var titleCase_1 = tslib_1.__importDefault(require("@koine/utils/titleCase"));
10
10
  var media_1 = require("../styles/media");
11
11
  var LINK_GUTTER_X = 10;
12
12
  var Root = styled_components_1.default.nav(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n display: flex;\n position: relative;\n"], ["\n display: flex;\n position: relative;\n"])));
@@ -25,7 +25,7 @@ var KoineBreadcrumbs = function (_a) {
25
25
  opacity: 1,
26
26
  x: 0,
27
27
  transition: { delay: idx * 0.2 },
28
- } }, { children: [item.url && ((0, jsx_runtime_1.jsx)(ItemLink, tslib_1.__assign({ as: Link, href: item.url }, { children: (0, utils_1.titleCase)(item.title) }))), !item.url && (0, jsx_runtime_1.jsx)(ItemCurrent, { children: (0, utils_1.titleCase)(item.title) }), idx < items.length - 1 && (0, jsx_runtime_1.jsx)(ItemSeparator, {})] }), idx)); }) }) })));
28
+ } }, { children: [item.url && ((0, jsx_runtime_1.jsx)(ItemLink, tslib_1.__assign({ as: Link, href: item.url }, { children: (0, titleCase_1.default)(item.title) }))), !item.url && (0, jsx_runtime_1.jsx)(ItemCurrent, { children: (0, titleCase_1.default)(item.title) }), idx < items.length - 1 && (0, jsx_runtime_1.jsx)(ItemSeparator, {})] }), idx)); }) }) })));
29
29
  };
30
30
  exports.KoineBreadcrumbs = KoineBreadcrumbs;
31
31
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
@@ -2,10 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCalendarsEventsFromGoogle = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var utils_1 = require("@koine/utils");
5
+ var arrayToLookup_1 = tslib_1.__importDefault(require("@koine/utils/arrayToLookup"));
6
+ var isString_1 = tslib_1.__importDefault(require("@koine/utils/isString"));
7
+ var isUndefined_1 = tslib_1.__importDefault(require("@koine/utils/isUndefined"));
6
8
  var differenceInDays_1 = tslib_1.__importDefault(require("date-fns/differenceInDays"));
7
9
  var subDays_1 = tslib_1.__importDefault(require("date-fns/subDays"));
8
- var utils_2 = require("./utils");
10
+ var utils_1 = require("./utils");
9
11
  var baseURL = "https://www.googleapis.com/calendar/v3/calendars/";
10
12
  function getCalendarsEventsFromGoogle(_a) {
11
13
  var calendars = _a.calendars, options = tslib_1.__rest(_a, ["calendars"]);
@@ -23,7 +25,7 @@ function getCalendarsEventsFromGoogle(_a) {
23
25
  case 0: return [4 /*yield*/, getCalendarEventsFromGoogle(tslib_1.__assign({ calendar: calendar }, options))];
24
26
  case 1:
25
27
  events = _a.sent();
26
- (0, utils_2.addCalendarEvents)(events, allEvents);
28
+ (0, utils_1.addCalendarEvents)(events, allEvents);
27
29
  return [2 /*return*/];
28
30
  }
29
31
  });
@@ -87,7 +89,7 @@ function transformCalendarEventFromGoogle(event, calendar) {
87
89
  var start = new Date(event.start.date || event.start.dateTime);
88
90
  var end = new Date(event.end.date || event.end.dateTime);
89
91
  var color = calendar.color;
90
- var allDay = (0, utils_1.isUndefined)(event.end.dateTime) && (0, utils_1.isString)(event.end.date);
92
+ var allDay = (0, isUndefined_1.default)(event.end.dateTime) && (0, isString_1.default)(event.end.date);
91
93
  var location = event.location || "";
92
94
  var description = event.description || ""; // FIXME: he.decode(event.description || '');
93
95
  var uid = created.getTime() + "" + start.getTime();
@@ -98,16 +100,16 @@ function transformCalendarEventFromGoogle(event, calendar) {
98
100
  end.setHours(23, 59, 59);
99
101
  }
100
102
  var days = getDays();
101
- var daysMap = (0, utils_1.arrayToLookup)(days);
103
+ var daysMap = (0, arrayToLookup_1.default)(days);
102
104
  var multi = days.length > 1;
103
105
  function getDays() {
104
106
  var from = new Date(start);
105
107
  var to = new Date(end);
106
- var days = [(0, utils_2.getEventTimestamp)(from)];
108
+ var days = [(0, utils_1.getEventTimestamp)(from)];
107
109
  while ((0, differenceInDays_1.default)(to, from)) {
108
110
  // console.log(title, differenceInDays(to, from))
109
111
  from.setDate(from.getDate() + 1);
110
- days.push((0, utils_2.getEventTimestamp)(from));
112
+ days.push((0, utils_1.getEventTimestamp)(from));
111
113
  }
112
114
  return days;
113
115
  }
package/node/Form/Form.js CHANGED
@@ -4,7 +4,7 @@ exports.KoineForm = exports.Form = exports.Fail = exports.Ok = exports.Collapsab
4
4
  var tslib_1 = require("tslib");
5
5
  var jsx_runtime_1 = require("react/jsx-runtime");
6
6
  var react_1 = require("react");
7
- // import { type MotionProps } from "framer-motion";
7
+ // import type { MotionProps } from "framer-motion";
8
8
  var helpers_1 = require("../helpers");
9
9
  exports.Root = "form";
10
10
  exports.Overlay = "div";
@@ -5,7 +5,7 @@ var tslib_1 = require("tslib");
5
5
  var jsx_runtime_1 = require("react/jsx-runtime");
6
6
  var react_1 = require("react");
7
7
  var react_hook_form_1 = require("react-hook-form");
8
- var utils_1 = require("@koine/utils");
8
+ var decode_1 = tslib_1.__importDefault(require("@koine/utils/decode"));
9
9
  var Field_1 = require("./Field");
10
10
  var FieldHint_1 = require("./FieldHint");
11
11
  var styles_1 = require("../styles");
@@ -21,7 +21,7 @@ var styles_1 = require("../styles");
21
21
  */
22
22
  var FieldControl = function (_a) {
23
23
  var control = _a.control, register = _a.register, setValue = _a.setValue, maybeEncodedName = _a.name, label = _a.label, placeholder = _a.placeholder, hint = _a.hint, t = _a.t, _b = _a.showError, showError = _b === void 0 ? true : _b, children = _a.children, encode = _a.encode, props = tslib_1.__rest(_a, ["control", "register", "setValue", "name", "label", "placeholder", "hint", "t", "showError", "children", "encode"]);
24
- var name = encode ? (0, utils_1.decode)(maybeEncodedName) : maybeEncodedName;
24
+ var name = encode ? (0, decode_1.default)(maybeEncodedName) : maybeEncodedName;
25
25
  var errors = (0, react_hook_form_1.useFormState)({ name: name, control: control }).errors;
26
26
  var error = showError && errors[name] ? errors[name] : null;
27
27
  var FormFieldContent = (0, react_1.useMemo)(function () {
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decodeForm = exports.encodeForm = void 0;
4
+ var tslib_1 = require("tslib");
4
5
  var yup_1 = require("@kuus/yup");
5
- var utils_1 = require("@koine/utils");
6
+ var encode_1 = tslib_1.__importDefault(require("@koine/utils/encode"));
7
+ var decode_1 = tslib_1.__importDefault(require("@koine/utils/decode"));
8
+ var isUndefined_1 = tslib_1.__importDefault(require("@koine/utils/isUndefined"));
6
9
  /**
7
10
  * Encode form
8
11
  *
@@ -19,7 +22,7 @@ function encodeForm(validationRules) {
19
22
  var encodedNames = {};
20
23
  for (var name_1 in validationRules) {
21
24
  if (!name_1.startsWith("_")) {
22
- var encodedName = (0, utils_1.encode)(name_1);
25
+ var encodedName = (0, encode_1.default)(name_1);
23
26
  encoded[encodedName] = validationRules[name_1];
24
27
  encodedNames[name_1] = encodedName;
25
28
  }
@@ -42,7 +45,7 @@ exports.encodeForm = encodeForm;
42
45
  function decodeForm(formData) {
43
46
  var json = {};
44
47
  for (var encodedName in formData) {
45
- var decodedName = (0, utils_1.decode)(encodedName);
48
+ var decodedName = (0, decode_1.default)(encodedName);
46
49
  // always add underscore prefixed names as they are treated as internal
47
50
  // private inputs outside of the honeypot system, normalise them here removing
48
51
  // the underscore prefix
@@ -51,7 +54,7 @@ function decodeForm(formData) {
51
54
  json[encodedName.substring(1)] = formData[encodedName];
52
55
  }
53
56
  // if the decoded `name` is empty and the encoded `name` is defined honeypot passed
54
- else if (!(0, utils_1.isUndefined)(formData[encodedName]) &&
57
+ else if (!(0, isUndefined_1.default)(formData[encodedName]) &&
55
58
  formData[decodedName] === "") {
56
59
  // @ts-expect-error nevermind
57
60
  json[decodedName] = formData[encodedName];
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.triggerChange = exports.triggerOnChange = exports.defaultOptionsFilterFn = exports.normaliseOptions = void 0;
4
- var utils_1 = require("@koine/utils");
4
+ var tslib_1 = require("tslib");
5
+ var isString_1 = tslib_1.__importDefault(require("@koine/utils/isString"));
6
+ var matchSorter_1 = tslib_1.__importDefault(require("@koine/utils/matchSorter"));
5
7
  var normaliseOptions = function (options) {
6
8
  if (options === void 0) { options = []; }
7
9
  return options.map(function (option) {
8
- return (0, utils_1.isString)(option)
10
+ return (0, isString_1.default)(option)
9
11
  ? {
10
12
  label: option,
11
13
  value: option,
@@ -18,7 +20,7 @@ function defaultOptionsFilterFn(options, inputValue) {
18
20
  if (!inputValue) {
19
21
  return options;
20
22
  }
21
- return (0, utils_1.matchSorter)(options, inputValue, { keys: ["value", "label"] });
23
+ return (0, matchSorter_1.default)(options, inputValue, { keys: ["value", "label"] });
22
24
  }
23
25
  exports.defaultOptionsFilterFn = defaultOptionsFilterFn;
24
26
  /**
@@ -32,3 +32,4 @@ var useHeader = function () {
32
32
  ];
33
33
  };
34
34
  exports.useHeader = useHeader;
35
+ exports.default = exports.useHeader;
@@ -10,7 +10,7 @@ var MenuUnstyled_1 = require("@mui/base/MenuUnstyled");
10
10
  var ModalUnstyled_1 = tslib_1.__importDefault(require("@mui/base/ModalUnstyled"));
11
11
  var ClickAwayListener_1 = tslib_1.__importDefault(require("@mui/base/ClickAwayListener"));
12
12
  var react_popper_1 = require("react-popper");
13
- var clsx_1 = require("@koine/utils/clsx");
13
+ var clsx_1 = tslib_1.__importDefault(require("@koine/utils/clsx"));
14
14
  var MenuRoot = framer_motion_1.motion.div;
15
15
  var MenuBackdrop = function () { return (0, jsx_runtime_1.jsx)("div", { className: "fixed inset-0" }); };
16
16
  exports.Menu = (0, react_1.forwardRef)(function Menu(props, ref) {
@@ -73,6 +73,6 @@ exports.Menu = (0, react_1.forwardRef)(function Menu(props, ref) {
73
73
  opacity: 1,
74
74
  }, exit: {
75
75
  opacity: 0,
76
- }, className: (0, clsx_1.clsx)(className), style: styles["popper"] }, htmlAttributes, getListboxProps(), { "aria-labelledby": id }, { children: (0, jsx_runtime_1.jsx)(MenuUnstyled_1.MenuUnstyledContext.Provider, tslib_1.__assign({ value: contextValue }, { children: renderChildren })) })) })) }) }))) })] }));
76
+ }, className: (0, clsx_1.default)(className), style: styles["popper"] }, htmlAttributes, getListboxProps(), { "aria-labelledby": id }, { children: (0, jsx_runtime_1.jsx)(MenuUnstyled_1.MenuUnstyledContext.Provider, tslib_1.__assign({ value: contextValue }, { children: renderChildren })) })) })) }) }))) })] }));
77
77
  });
78
78
  exports.default = exports.Menu;
@@ -6,13 +6,13 @@ var jsx_runtime_1 = require("react/jsx-runtime");
6
6
  var react_1 = require("react");
7
7
  var MenuItemUnstyled_1 = require("@mui/base/MenuItemUnstyled");
8
8
  // import { useMenuItem } from "./useMenuItem";
9
- var clsx_1 = require("@koine/utils/clsx");
9
+ var clsx_1 = tslib_1.__importDefault(require("@koine/utils/clsx"));
10
10
  exports.MenuItem = (0, react_1.forwardRef)(function MenuItem(props, ref) {
11
11
  var _a = props.as, As = _a === void 0 ? "button" : _a, children = props.children, className = props.className, disabledProp = props.disabled, other = tslib_1.__rest(props, ["as", "children", "className", "disabled"]);
12
12
  var _b = (0, MenuItemUnstyled_1.useMenuItem)({
13
13
  ref: ref,
14
14
  disabled: disabledProp,
15
15
  }), getRootProps = _b.getRootProps, disabled = _b.disabled, focusVisible = _b.focusVisible;
16
- return ((0, jsx_runtime_1.jsx)(As, tslib_1.__assign({ className: (0, clsx_1.clsx)(focusVisible && "", disabled && "", className) }, getRootProps(other), { children: children })));
16
+ return ((0, jsx_runtime_1.jsx)(As, tslib_1.__assign({ className: (0, clsx_1.default)(focusVisible && "", disabled && "", className) }, getRootProps(other), { children: children })));
17
17
  });
18
18
  exports.default = exports.MenuItem;
@@ -5,7 +5,7 @@ var tslib_1 = require("tslib");
5
5
  var jsx_runtime_1 = require("react/jsx-runtime");
6
6
  var styled_components_1 = tslib_1.__importDefault(require("styled-components"));
7
7
  var cg_1 = require("react-icons/cg");
8
- var utils_1 = require("@koine/utils");
8
+ var ensureInt_1 = tslib_1.__importDefault(require("@koine/utils/ensureInt"));
9
9
  var Root = styled_components_1.default.nav(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px 0 40px;\n font-weight: 600;\n\n & a {\n text-decoration: none;\n }\n"], ["\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px 0 40px;\n font-weight: 600;\n\n & a {\n text-decoration: none;\n }\n"])));
10
10
  var item = "\n display: block;\n padding: 5px 10px;\n";
11
11
  var ItemCurrent = styled_components_1.default.span(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n ", "\n background: var(--accent400);\n border-radius: 2px;\n"], ["\n ", "\n background: var(--accent400);\n border-radius: 2px;\n"])), item);
@@ -24,9 +24,9 @@ var ItemNext = styled_components_1.default.a(templateObject_6 || (templateObject
24
24
  */
25
25
  var KoinePaginationNav = function (_a) {
26
26
  var total = _a.total, perPage = _a.perPage, currentPage = _a.currentPage, baseUrl = _a.baseUrl, _b = _a.showOffset, showOffset = _b === void 0 ? 2 : _b, _c = _a.currentUrl, currentUrl = _c === void 0 ? "/" : _c, _d = _a.Link, Link = _d === void 0 ? "a" : _d;
27
- total = (0, utils_1.ensureInt)(total);
28
- currentPage = (0, utils_1.ensureInt)(currentPage);
29
- perPage = (0, utils_1.ensureInt)(perPage);
27
+ total = (0, ensureInt_1.default)(total);
28
+ currentPage = (0, ensureInt_1.default)(currentPage);
29
+ perPage = (0, ensureInt_1.default)(perPage);
30
30
  // page 0 means 1
31
31
  currentPage = currentPage || 1;
32
32
  baseUrl = baseUrl || currentUrl;
@@ -4,12 +4,12 @@ exports.Spacing = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var jsx_runtime_1 = require("react/jsx-runtime");
6
6
  var styled_components_1 = tslib_1.__importDefault(require("styled-components"));
7
- var utils_1 = require("@koine/utils");
7
+ var isUndefined_1 = tslib_1.__importDefault(require("@koine/utils/isUndefined"));
8
8
  var spacing_1 = require("../styles/spacing");
9
9
  var Root = styled_components_1.default.div(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ", "\n ", "\n"], ["\n ", "\n ", "\n"])), function (p) { return p.$top && spacing_1.spacingTop.call.apply(spacing_1.spacingTop, tslib_1.__spreadArray([p.theme], p.$top, false)); }, function (p) { return p.$bottom && spacing_1.spacingBottom.call.apply(spacing_1.spacingBottom, tslib_1.__spreadArray([p.theme], p.$bottom, false)); });
10
10
  var extractDirectionArgs = function (raw) {
11
11
  var _a = raw.split(":"), size = _a[0], factor = _a[1], property = _a[2], devices = _a[3];
12
- var factorArg = (0, utils_1.isUndefined)(factor) ? undefined : parseFloat(factor);
12
+ var factorArg = (0, isUndefined_1.default)(factor) ? undefined : parseFloat(factor);
13
13
  var devicesArg = devices === null || devices === void 0 ? void 0 : devices.split(",");
14
14
  return [size, factorArg, property, devicesArg];
15
15
  };
@@ -7,8 +7,7 @@ var react_1 = require("react");
7
7
  * This utility allows to extend a component a là `styled-components` but for
8
8
  * a className based styling solution like Tailwind,
9
9
  *
10
- * It also plays nicely with tailwind intellisense @see:
11
- *
10
+ * It also plays nicely with tailwind intellisense:
12
11
  * - https://github.com/tailwindlabs/tailwindcss-intellisense#tailwindcssclassattributes
13
12
  *
14
13
  * For references about tagged functions:
@@ -16,6 +15,12 @@ var react_1 = require("react");
16
15
  * - https://makersden.io/blog/reverse-engineering-styled-components
17
16
  * - https://typesafe.blog/article/the-logic-behind-javascript-tag-functions
18
17
  * - https://flaming.codes/posts/typescript-and-javascript-tagged-template-strings
18
+ *
19
+ * Similar projects:
20
+ * - https://reactjsexample.com/style-radix-ui-components-with-tailwindcss/
21
+ *
22
+ * Discussions and Q/A:
23
+ * - https://stackoverflow.com/q/73055695/1938970
19
24
  */
20
25
  function classed(component) {
21
26
  // @ts-expect-error nevermind for now...