@onereach/ui-components-common 19.3.0-beta.5083.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/dist/assets/index.d.ts +2 -0
  2. package/dist/assets.js +5 -0
  3. package/dist/directives/dropdown-close.d.ts +4 -0
  4. package/dist/directives/dropdown-open.d.ts +4 -0
  5. package/dist/directives/index.d.ts +2 -0
  6. package/dist/directives.js +5 -0
  7. package/dist/dom-CwV-xS38.js +95 -0
  8. package/dist/dropdown-open-k6cFnrqA.js +20 -0
  9. package/dist/extractCssVarName-IHa2pGlF.js +160 -0
  10. package/dist/helpers/getItemByValue.d.ts +2 -0
  11. package/dist/helpers/getItemsByValue.d.ts +2 -0
  12. package/dist/helpers/index.d.ts +3 -0
  13. package/dist/helpers/searchItemsByLabel.d.ts +2 -0
  14. package/dist/helpers.js +6 -0
  15. package/dist/hooks/index.d.ts +15 -0
  16. package/dist/hooks/useControlAttributes.d.ts +7 -0
  17. package/dist/hooks/useDateFormat.d.ts +4 -0
  18. package/dist/hooks/useDateMask.d.ts +4 -0
  19. package/dist/hooks/useElevation.d.ts +3 -0
  20. package/dist/hooks/useIdAttribute.d.ts +3 -0
  21. package/dist/hooks/useLocale.d.ts +4 -0
  22. package/dist/hooks/useOverflow.d.ts +11 -0
  23. package/dist/hooks/usePopoverState.d.ts +12 -0
  24. package/dist/hooks/useProxyModelValue.d.ts +8 -0
  25. package/dist/hooks/useResponsive/index.d.ts +1 -0
  26. package/dist/hooks/useResponsive/useResponsive.d.ts +6 -0
  27. package/dist/hooks/useTheme.d.ts +3 -0
  28. package/dist/hooks/useTimeFormat.d.ts +4 -0
  29. package/dist/hooks/useTimeMask.d.ts +4 -0
  30. package/dist/hooks/useToggle.d.ts +8 -0
  31. package/dist/hooks/useValidationAttributes.d.ts +11 -0
  32. package/dist/hooks.js +18 -0
  33. package/dist/index.d.ts +6 -0
  34. package/dist/index.js +138 -0
  35. package/dist/isUndefined-B5qXrATz.js +4 -0
  36. package/dist/isVisible-BuGrjvTY.js +4 -0
  37. package/dist/searchItemsByLabel-BhinsABA.js +13 -0
  38. package/dist/tokens/DATE_FORMAT.d.ts +3 -0
  39. package/dist/tokens/LOCALE.d.ts +3 -0
  40. package/dist/tokens/TIME_FORMAT.d.ts +3 -0
  41. package/dist/tokens/index.d.ts +3 -0
  42. package/dist/types/DataModel.d.ts +6 -0
  43. package/dist/types/DateFormat.d.ts +5 -0
  44. package/dist/types/FilterFunction.d.ts +1 -0
  45. package/dist/types/FormatFunction.d.ts +2 -0
  46. package/dist/types/Group.d.ts +5 -0
  47. package/dist/types/GroupFunction.d.ts +1 -0
  48. package/dist/types/Id.d.ts +1 -0
  49. package/dist/types/Item.d.ts +5 -0
  50. package/dist/types/Locale.d.ts +1 -0
  51. package/dist/types/ModelValue.d.ts +1 -0
  52. package/dist/types/SearchFunction.d.ts +1 -0
  53. package/dist/types/TimeFormat.d.ts +5 -0
  54. package/dist/types/index.d.ts +12 -0
  55. package/dist/types.js +5 -0
  56. package/dist/useValidationAttributes-DxhcSj_h.js +217 -0
  57. package/dist/utils/constants/color.d.ts +14 -0
  58. package/dist/utils/constants/key-codes.d.ts +14 -0
  59. package/dist/utils/constants/poper.d.ts +8 -0
  60. package/dist/utils/constants/regex.d.ts +42 -0
  61. package/dist/utils/exclude.d.ts +4 -0
  62. package/dist/utils/extractCssVarName.d.ts +1 -0
  63. package/dist/utils/functions/color.d.ts +23 -0
  64. package/dist/utils/functions/dom.d.ts +30 -0
  65. package/dist/utils/functions/flattenDeep.d.ts +2 -0
  66. package/dist/utils/functions/hash.d.ts +2 -0
  67. package/dist/utils/functions/px-to-rem.d.ts +1 -0
  68. package/dist/utils/functions/text.d.ts +1 -0
  69. package/dist/utils/include.d.ts +4 -0
  70. package/dist/utils/index.d.ts +26 -0
  71. package/dist/utils/isAncestor.d.ts +4 -0
  72. package/dist/utils/isArray.d.ts +4 -0
  73. package/dist/utils/isDescendant.d.ts +4 -0
  74. package/dist/utils/isEmpty.d.ts +4 -0
  75. package/dist/utils/isEqual.d.ts +4 -0
  76. package/dist/utils/isNil.d.ts +4 -0
  77. package/dist/utils/isNull.d.ts +4 -0
  78. package/dist/utils/isNumber.d.ts +4 -0
  79. package/dist/utils/isObject.d.ts +4 -0
  80. package/dist/utils/isString.d.ts +4 -0
  81. package/dist/utils/isUndefined.d.ts +4 -0
  82. package/dist/utils/isVisible.d.ts +1 -0
  83. package/dist/utils/toArray.d.ts +4 -0
  84. package/dist/utils.js +109 -0
  85. package/package.json +77 -0
  86. package/src/assets/error.png +0 -0
  87. package/src/assets/index.ts +2 -0
  88. package/src/assets/success.png +0 -0
  89. package/src/directives/dropdown-close.ts +14 -0
  90. package/src/directives/dropdown-open.ts +21 -0
  91. package/src/directives/index.ts +2 -0
  92. package/src/helpers/getItemByValue.ts +12 -0
  93. package/src/helpers/getItemsByValue.ts +6 -0
  94. package/src/helpers/index.ts +3 -0
  95. package/src/helpers/searchItemsByLabel.ts +5 -0
  96. package/src/hooks/index.ts +15 -0
  97. package/src/hooks/useControlAttributes.ts +19 -0
  98. package/src/hooks/useDateFormat.ts +13 -0
  99. package/src/hooks/useDateMask.ts +54 -0
  100. package/src/hooks/useElevation.ts +32 -0
  101. package/src/hooks/useIdAttribute.ts +11 -0
  102. package/src/hooks/useLocale.ts +13 -0
  103. package/src/hooks/useOverflow.ts +83 -0
  104. package/src/hooks/usePopoverState.ts +67 -0
  105. package/src/hooks/useProxyModelValue.ts +50 -0
  106. package/src/hooks/useResponsive/index.ts +1 -0
  107. package/src/hooks/useResponsive/useResponsive.ts +58 -0
  108. package/src/hooks/useTheme.ts +8 -0
  109. package/src/hooks/useTimeFormat.ts +13 -0
  110. package/src/hooks/useTimeMask.ts +41 -0
  111. package/src/hooks/useToggle.ts +32 -0
  112. package/src/hooks/useValidationAttributes.ts +25 -0
  113. package/src/index.ts +6 -0
  114. package/src/tokens/DATE_FORMAT.ts +4 -0
  115. package/src/tokens/LOCALE.ts +4 -0
  116. package/src/tokens/TIME_FORMAT.ts +4 -0
  117. package/src/tokens/index.ts +3 -0
  118. package/src/types/DataModel.ts +3 -0
  119. package/src/types/DateFormat.ts +5 -0
  120. package/src/types/FilterFunction.ts +1 -0
  121. package/src/types/FormatFunction.ts +3 -0
  122. package/src/types/Group.ts +6 -0
  123. package/src/types/GroupFunction.ts +1 -0
  124. package/src/types/Id.ts +1 -0
  125. package/src/types/Item.ts +5 -0
  126. package/src/types/Locale.ts +1 -0
  127. package/src/types/ModelValue.ts +1 -0
  128. package/src/types/SearchFunction.ts +1 -0
  129. package/src/types/TimeFormat.ts +5 -0
  130. package/src/types/index.ts +12 -0
  131. package/src/utils/constants/color.ts +14 -0
  132. package/src/utils/constants/key-codes.ts +14 -0
  133. package/src/utils/constants/poper.ts +8 -0
  134. package/src/utils/constants/regex.ts +57 -0
  135. package/src/utils/exclude.ts +6 -0
  136. package/src/utils/extractCssVarName.ts +5 -0
  137. package/src/utils/functions/color.ts +55 -0
  138. package/src/utils/functions/dom.ts +206 -0
  139. package/src/utils/functions/flattenDeep.ts +5 -0
  140. package/src/utils/functions/hash.ts +10 -0
  141. package/src/utils/functions/px-to-rem.ts +2 -0
  142. package/src/utils/functions/text.ts +8 -0
  143. package/src/utils/include.ts +6 -0
  144. package/src/utils/index.ts +28 -0
  145. package/src/utils/isAncestor.ts +16 -0
  146. package/src/utils/isArray.ts +6 -0
  147. package/src/utils/isDescendant.ts +16 -0
  148. package/src/utils/isEmpty.ts +24 -0
  149. package/src/utils/isEqual.ts +23 -0
  150. package/src/utils/isNil.ts +8 -0
  151. package/src/utils/isNull.ts +6 -0
  152. package/src/utils/isNumber.ts +6 -0
  153. package/src/utils/isObject.ts +6 -0
  154. package/src/utils/isString.ts +6 -0
  155. package/src/utils/isUndefined.ts +6 -0
  156. package/src/utils/isVisible.ts +3 -0
  157. package/src/utils/toArray.ts +16 -0
@@ -0,0 +1,206 @@
1
+ import get from 'lodash/get';
2
+ import isElement from 'lodash/isElement';
3
+
4
+ const WINDOW = typeof window !== 'undefined' ? window : null;
5
+
6
+ export const MutationObs: MutationObserver =
7
+ WINDOW?.MutationObserver
8
+ || (WINDOW as any)?.WebKitMutationObserver
9
+ || (WINDOW as any)?.MozMutationObserver
10
+ || null;
11
+
12
+ export const requestAF = (
13
+ WINDOW?.requestAnimationFrame ||
14
+ (WINDOW as any)?.webkitRequestAnimationFrame ||
15
+ (WINDOW as any)?.mozRequestAnimationFrame ||
16
+ (WINDOW as any)?.msRequestAnimationFrame ||
17
+ (WINDOW as any)?.oRequestAnimationFrame ||
18
+ // Fallback, but not a true polyfill
19
+ // Only needed for Opera Mini
20
+ ((cb: () => void) => setTimeout(cb, 16))
21
+ ).bind(WINDOW);
22
+
23
+ // eslint-disable-next-line no-unsafe-optional-chaining
24
+ export const cancelAF = (WINDOW?.cancelAnimationFrame || (WINDOW as any)?.mozCancelAnimationFrame).bind(WINDOW);
25
+
26
+ // Remove a node from DOM
27
+ export const removeNode = (el: HTMLElement): void => { el && el.parentNode && el.parentNode.removeChild(el); };
28
+
29
+ // Cause/wait-for an element to reflow its content (adjusting its height/width)
30
+ export const reflow = (el: HTMLElement): number | null => {
31
+ // Requesting an elements offsetHeight will trigger a reflow of the element content
32
+ return get(el, ['offsetHeight'], null);
33
+ };
34
+
35
+ // Select all elements matching selector. Returns `[]` if none found
36
+ export const selectAll = (selector: string, root?: HTMLElement | undefined): Element[] =>
37
+ [...(root && isElement(root) ? root : document).querySelectorAll(selector)];
38
+
39
+ // Select a single element, returns `null` if not found
40
+ export const select = (selector: string, root?: HTMLElement | undefined): Element | null =>
41
+ (root && isElement(root) ? root : document).querySelector(selector) || null;
42
+
43
+ // Returns true if the parent element contains the child element
44
+ export const contains = (parent: HTMLElement, child: HTMLElement): boolean =>
45
+ parent && typeof parent.contains === 'function' ? parent.contains(child) : false;
46
+
47
+ // Get an element given an ID
48
+ export const getById = (id: string): HTMLElement | null =>
49
+ document.getElementById(/^#/.test(id) ? id.slice(1) : id) || null;
50
+
51
+ // Add a class to an element
52
+ export const addClass = (el: HTMLElement, className: string): void => {
53
+ // We are checking for `el.classList` existence here since IE 11
54
+ // returns `undefined` for some elements (e.g. SVG elements)
55
+ if (className && isElement(el) && el.classList) {
56
+ el.classList.add(className);
57
+ }
58
+ };
59
+
60
+ // Remove a class from an element
61
+ export const removeClass = (el: HTMLElement, className: string): void => {
62
+ // We are checking for `el.classList` existence here since IE 11
63
+ // returns `undefined` for some elements (e.g. SVG elements)
64
+ if (className && isElement(el) && el.classList) el.classList.remove(className);
65
+ };
66
+
67
+ // Test if an element has a class
68
+ export const hasClass = (el: HTMLElement, className: string): boolean => {
69
+ // We are checking for `el.classList` existence here since IE 11
70
+ // returns `undefined` for some elements (e.g. SVG elements)
71
+ if (className && isElement(el) && el.classList) return el.classList.contains(className);
72
+
73
+ return false;
74
+ };
75
+
76
+ // Set an attribute on an element
77
+ export const setAttr = (el: HTMLElement, attr: string, value: any): void => {
78
+ if (attr && isElement(el)) {
79
+ el.setAttribute(attr, value);
80
+ }
81
+ };
82
+
83
+ // Remove an attribute from an element
84
+ export const removeAttr = (el: HTMLElement, attr: string): void => {
85
+ if (attr && isElement(el)) {
86
+ el.removeAttribute(attr);
87
+ }
88
+ };
89
+
90
+ // Get an attribute value from an element
91
+ export const getAttr = (el: HTMLElement, attr: string): string | null =>
92
+ (attr && isElement(el) ? el.getAttribute(attr) : null);
93
+
94
+ // Determine if an attribute exists on an element
95
+ // Returns `true` or `false`, or `null` if element not found
96
+ export const hasAttr = (el: HTMLElement, attr: string): boolean | null =>
97
+ (attr && isElement(el) ? el.hasAttribute(attr) : null);
98
+
99
+ // Set an style property on an element
100
+ export const setStyle = (el: HTMLElement, prop: any, value: any): void => {
101
+ if (prop && isElement(el)) {
102
+ el.style[prop] = value;
103
+ }
104
+ };
105
+
106
+ // Remove an style property from an element
107
+ export const removeStyle = (el: HTMLElement, prop: any): void => {
108
+ if (prop && isElement(el)) {
109
+ el.style[prop] = '';
110
+ }
111
+ };
112
+
113
+ // Get an style property value from an element
114
+ // Returns `null` if not found
115
+ export const getStyle = (el: HTMLElement, prop: any): string | null =>
116
+ (prop && isElement(el) ? el.style[prop] || null : null);
117
+
118
+ // Return the Bounding Client Rect of an element
119
+ export const getBCR = (el: HTMLElement): DOMRect | null => (isElement(el) ? el.getBoundingClientRect() : null);
120
+
121
+ // Get computed style object for an element
122
+ export const getCS = (el: HTMLElement): CSSStyleDeclaration | Record<string, string> =>
123
+ get(WINDOW, 'getComputedStyle', null) && isElement(el)
124
+ ? getComputedStyle(el)
125
+ : {};
126
+
127
+ // Return an element's offset with respect to document element
128
+ export const offset = (el: HTMLElement): { top: number; left: number; } => {
129
+ const _offset = {
130
+ top: 0,
131
+ left: 0,
132
+ };
133
+
134
+ if (!isElement(el) || el.getClientRects().length === 0) {
135
+ return _offset;
136
+ }
137
+
138
+ const bcr = getBCR(el);
139
+ if (bcr) {
140
+ const win = el.ownerDocument.defaultView;
141
+
142
+ _offset.top = bcr.top + get(win, 'pageYOffset', 0);
143
+ _offset.left = bcr.left + get(win, 'pageXOffset', 0);
144
+ }
145
+
146
+ return _offset;
147
+ };
148
+
149
+ // Return an element's offset with respect to to its offsetParent
150
+ export const position = (el: HTMLElement): { top: number; left: number; } => {
151
+ let _offset = {
152
+ top: 0,
153
+ left: 0,
154
+ };
155
+
156
+ if (!isElement(el)) {
157
+ return _offset;
158
+ }
159
+
160
+ let parentOffset = {
161
+ top: 0,
162
+ left: 0,
163
+ };
164
+
165
+ const elStyles = getCS(el);
166
+
167
+ if (elStyles.position === 'fixed') {
168
+ _offset = getBCR(el) || _offset;
169
+ } else {
170
+ _offset = offset(el);
171
+ const doc = el.ownerDocument;
172
+ let offsetParent: (Node & ParentNode) | null = el.offsetParent || doc.documentElement;
173
+ while (
174
+ offsetParent &&
175
+ (offsetParent === doc.body || offsetParent === doc.documentElement) &&
176
+ getCS(offsetParent as HTMLElement).position === 'static'
177
+ ) {
178
+ offsetParent = offsetParent.parentNode;
179
+ }
180
+ if (offsetParent && offsetParent !== el && offsetParent.nodeType === Node.ELEMENT_NODE) {
181
+ parentOffset = offset(offsetParent as HTMLElement);
182
+
183
+ const offsetParentStyles = getCS(offsetParent as HTMLElement);
184
+ parentOffset.top += parseFloat(offsetParentStyles.borderTopWidth as string);
185
+ parentOffset.left += parseFloat(offsetParentStyles.borderLeftWidth as string);
186
+ }
187
+ }
188
+
189
+ return {
190
+ top: _offset.top - parentOffset.top - parseFloat(elStyles.marginTop as string),
191
+ left: _offset.left - parentOffset.left - parseFloat(elStyles.marginLeft as string),
192
+ };
193
+ };
194
+
195
+ export const getMaxZIndex = (element: HTMLElement | null): number => {
196
+ let maxZIndex = 0;
197
+ while (element) {
198
+ const cs = getCS(element);
199
+ const zIndex = cs.zIndex;
200
+ if (zIndex !== 'auto') {
201
+ maxZIndex = +zIndex > maxZIndex ? +zIndex : maxZIndex;
202
+ }
203
+ element = element.parentElement;
204
+ }
205
+ return maxZIndex;
206
+ };
@@ -0,0 +1,5 @@
1
+ export function flattenDeep(arr: any[] = []): any[] {
2
+ return arr.flatMap((subArray) => Array.isArray(subArray) ? flattenDeep(subArray) : subArray);
3
+ }
4
+
5
+ export default flattenDeep;
@@ -0,0 +1,10 @@
1
+ export function getHashOfString(str: string): number {
2
+ return Math.abs(
3
+ str.split('')
4
+ .reduce((hash, char) => char.charCodeAt(0) + ((hash << 5) - hash), 0),
5
+ );
6
+ }
7
+
8
+ export function normalize(hash: number, min: number, max: number): number {
9
+ return Math.floor((hash % (max - min)) + min);
10
+ }
@@ -0,0 +1,2 @@
1
+ export const pxToRem = (value: number): string =>
2
+ value === 0 ? '0' : `${value / 16}rem`;
@@ -0,0 +1,8 @@
1
+ import { RX_ABBREVIATION_FROM_STRING } from '../constants/regex';
2
+
3
+ export function getAbbreviation(text: string | null, limit?: number): string {
4
+ if (typeof text != 'string' || !text) return '';
5
+ return ((text.match(RX_ABBREVIATION_FROM_STRING) ?? []) as string[])
6
+ .reduce((previous: string, next: string) => previous + ((+next === 0 || parseInt(next)) ? parseInt(next) : next[0] || ''), '')
7
+ .toUpperCase().substring(0, limit);
8
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns a copy of the `items` array, including the `value`.
3
+ */
4
+ export const include = <T>(value: T, items: T[]): typeof items => {
5
+ return items.concat(value);
6
+ };
@@ -0,0 +1,28 @@
1
+ export * from './constants/color';
2
+ export * from './constants/key-codes';
3
+ export * from './constants/poper';
4
+ export * from './constants/regex';
5
+ export * from './exclude';
6
+
7
+ export * from './functions/color';
8
+ export * from './functions/dom';
9
+ export * from './functions/flattenDeep';
10
+ export * from './functions/hash';
11
+ export * from './functions/px-to-rem';
12
+ export * from './functions/text';
13
+
14
+ export * from './include';
15
+ export * from './isAncestor';
16
+ export * from './isArray';
17
+ export * from './isDescendant';
18
+ export * from './isEmpty';
19
+ export * from './isEqual';
20
+ export * from './isNil';
21
+ export * from './isNull';
22
+ export * from './isNumber';
23
+ export * from './isObject';
24
+ export * from './isString';
25
+ export * from './isUndefined';
26
+ export * from './isVisible';
27
+ export * from './toArray';
28
+ export * from './extractCssVarName';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Determines whether the element `a` is an ancestor of the element `b`.
3
+ */
4
+ export const isAncestor = (a: Element, b: Element): boolean => {
5
+ const { parentElement } = b;
6
+
7
+ if (!parentElement) {
8
+ return false;
9
+ }
10
+
11
+ if (a === parentElement) {
12
+ return true;
13
+ }
14
+
15
+ return isAncestor(a, parentElement);
16
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Determines whether the `value` is an array literal.
3
+ */
4
+ export const isArray = (value: unknown): value is Array<unknown> => {
5
+ return Array.isArray(value);
6
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Determines whether the element `a` is a descendant of the element `b`.
3
+ */
4
+ export const isDescendant = (a: Element, b: Element): boolean => {
5
+ const { parentElement } = a;
6
+
7
+ if (!parentElement) {
8
+ return false;
9
+ }
10
+
11
+ if (b === parentElement) {
12
+ return true;
13
+ }
14
+
15
+ return isDescendant(parentElement, b);
16
+ };
@@ -0,0 +1,24 @@
1
+ import { isArray, isNil, isObject, isString } from '.';
2
+
3
+ /**
4
+ * Determines whether the `value` is an empty object, an empty array, a zero-length string, `null`, or `undefined`.
5
+ */
6
+ export const isEmpty = (value: unknown): boolean => {
7
+ if (isNil(value)) {
8
+ return true;
9
+ }
10
+
11
+ if (isString(value)) {
12
+ return value.length === 0;
13
+ }
14
+
15
+ if (isArray(value)) {
16
+ return value.length === 0;
17
+ }
18
+
19
+ if (isObject(value)) {
20
+ return Object.keys(value).length === 0;
21
+ }
22
+
23
+ return false;
24
+ };
@@ -0,0 +1,23 @@
1
+ import { isArray, isObject } from '.';
2
+
3
+ /**
4
+ * Determines whether `a` and `b` are the same value (makes shallow comparison of arrays and objects).
5
+ */
6
+ export const isEqual = (a: unknown, b: unknown): boolean => {
7
+ if (Object.is(a, b)) {
8
+ return true;
9
+ }
10
+
11
+ if (isArray(a) && isArray(b)) {
12
+ return a.length === b.length && a.every((item, index) => item === b[index]);
13
+ }
14
+
15
+ if (isObject(a) && isObject(b)) {
16
+ const aKeys = Object.keys(a);
17
+ const bKeys = Object.keys(b);
18
+
19
+ return isEqual(aKeys, bKeys) && aKeys.every((key) => a[key] === b[key]);
20
+ }
21
+
22
+ return false;
23
+ };
@@ -0,0 +1,8 @@
1
+ import { isNull, isUndefined } from '.';
2
+
3
+ /**
4
+ * Determines whether the `value` is `null` or `undefined`.
5
+ */
6
+ export const isNil = (value: unknown): value is null | undefined => {
7
+ return isNull(value) || isUndefined(value);
8
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Determines whether the `value` is `null`.
3
+ */
4
+ export const isNull = (value: unknown): value is null => {
5
+ return value === null;
6
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Determines whether the `value` is a number.
3
+ */
4
+ export const isNumber = (value: unknown): value is number => {
5
+ return typeof value === 'number';
6
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Determines whether the `value` is an object literal.
3
+ */
4
+ export const isObject = (value: unknown): value is Record<PropertyKey, unknown> => {
5
+ return typeof value === 'object' && value?.constructor === Object;
6
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Determines whether the `value` is a string.
3
+ */
4
+ export const isString = (value: unknown): value is string => {
5
+ return typeof value === 'string';
6
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Determines whether the `value` is `undefined`.
3
+ */
4
+ export const isUndefined = (value: unknown): value is undefined => {
5
+ return value === undefined;
6
+ };
@@ -0,0 +1,3 @@
1
+ export const isVisible = (element: Element): boolean => {
2
+ return element.getClientRects().length > 0;
3
+ };
@@ -0,0 +1,16 @@
1
+ import { isArray, isNil } from '.';
2
+
3
+ /**
4
+ * Converts the `value` to an array literal.
5
+ */
6
+ export const toArray = <T>(value: T | T[]): T[] => {
7
+ if (isNil(value)) {
8
+ return [];
9
+ }
10
+
11
+ if (isArray(value)) {
12
+ return value;
13
+ }
14
+
15
+ return [value];
16
+ };