paris 0.17.10 → 0.18.1

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 (81) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +139 -150
  3. package/src/helpers/renderEnhancer.tsx +4 -5
  4. package/src/helpers/useResizeObserver.ts +17 -23
  5. package/src/pages/_document.tsx +1 -3
  6. package/src/pages/index.tsx +8 -24
  7. package/src/stories/Pagination.mdx +1 -1
  8. package/src/stories/Tokens.mdx +1 -1
  9. package/src/stories/Welcome.mdx +1 -1
  10. package/src/stories/accordion/Accordion.stories.ts +1 -1
  11. package/src/stories/accordion/Accordion.tsx +14 -35
  12. package/src/stories/accordionselect/AccordionSelect.stories.ts +2 -5
  13. package/src/stories/accordionselect/AccordionSelect.tsx +26 -50
  14. package/src/stories/avatar/Avatar.stories.ts +1 -1
  15. package/src/stories/avatar/Avatar.tsx +14 -13
  16. package/src/stories/button/Button.stories.ts +18 -15
  17. package/src/stories/button/Button.tsx +44 -48
  18. package/src/stories/callout/Callout.stories.ts +3 -7
  19. package/src/stories/callout/Callout.tsx +4 -8
  20. package/src/stories/card/Card.stories.ts +1 -1
  21. package/src/stories/card/Card.tsx +4 -11
  22. package/src/stories/cardbutton/CardButton.stories.tsx +1 -1
  23. package/src/stories/cardbutton/CardButton.tsx +16 -18
  24. package/src/stories/checkbox/Checkbox.stories.ts +1 -1
  25. package/src/stories/checkbox/Checkbox.tsx +37 -49
  26. package/src/stories/combobox/Combobox.stories.ts +65 -71
  27. package/src/stories/combobox/Combobox.tsx +80 -89
  28. package/src/stories/dialog/Dialog.stories.tsx +2 -2
  29. package/src/stories/dialog/Dialog.tsx +45 -68
  30. package/src/stories/drawer/Drawer.stories.tsx +63 -105
  31. package/src/stories/drawer/Drawer.tsx +93 -90
  32. package/src/stories/field/Field.stories.ts +1 -1
  33. package/src/stories/field/Field.tsx +25 -30
  34. package/src/stories/icon/Ellipsis.tsx +4 -1
  35. package/src/stories/icon/Icon.stories.ts +2 -2
  36. package/src/stories/icon/Icon.tsx +16 -26
  37. package/src/stories/icon/Info.tsx +4 -1
  38. package/src/stories/icon/Spinner.tsx +4 -2
  39. package/src/stories/icon/index.ts +6 -6
  40. package/src/stories/informationaltooltip/InformationalTooltip.stories.tsx +12 -11
  41. package/src/stories/informationaltooltip/InformationalTooltip.tsx +23 -28
  42. package/src/stories/input/Input.stories.ts +14 -15
  43. package/src/stories/input/Input.tsx +119 -95
  44. package/src/stories/markdown/Markdown.module.scss +384 -0
  45. package/src/stories/markdown/Markdown.stories.ts +203 -0
  46. package/src/stories/markdown/Markdown.tsx +293 -0
  47. package/src/stories/markdown/index.ts +1 -0
  48. package/src/stories/menu/Menu.stories.tsx +4 -10
  49. package/src/stories/menu/Menu.tsx +22 -16
  50. package/src/stories/pagination/usePagination.ts +8 -8
  51. package/src/stories/popover/Popover.stories.ts +2 -2
  52. package/src/stories/popover/Popover.tsx +4 -10
  53. package/src/stories/select/Select.stories.ts +10 -10
  54. package/src/stories/select/Select.tsx +268 -240
  55. package/src/stories/styledlink/StyledLink.stories.ts +1 -1
  56. package/src/stories/styledlink/StyledLink.tsx +11 -17
  57. package/src/stories/table/Table.stories.ts +1 -1
  58. package/src/stories/table/Table.tsx +55 -65
  59. package/src/stories/tabs/Tabs.module.scss +10 -68
  60. package/src/stories/tabs/Tabs.stories.tsx +83 -4
  61. package/src/stories/tabs/Tabs.tsx +15 -27
  62. package/src/stories/tag/Tag.stories.ts +1 -4
  63. package/src/stories/tag/Tag.tsx +9 -17
  64. package/src/stories/text/Text.stories.ts +1 -1
  65. package/src/stories/text/Text.tsx +49 -31
  66. package/src/stories/text/Typography.module.css +120 -120
  67. package/src/stories/textarea/TextArea.stories.ts +2 -5
  68. package/src/stories/textarea/TextArea.tsx +91 -84
  69. package/src/stories/theme/index.ts +1 -1
  70. package/src/stories/theme/themes.ts +423 -424
  71. package/src/stories/theme/tokens.ts +3 -3
  72. package/src/stories/theme/tw-preflight.css +4 -3
  73. package/src/stories/tilt/Tilt.stories.tsx +3 -6
  74. package/src/stories/tilt/Tilt.tsx +160 -126
  75. package/src/stories/toast/Toast.stories.tsx +2 -2
  76. package/src/stories/toast/Toast.tsx +3 -6
  77. package/src/stories/utility/RemoveFromDOM.tsx +9 -13
  78. package/src/stories/utility/TextWhenString.tsx +3 -16
  79. package/src/stories/utility/VisuallyHidden.tsx +10 -17
  80. package/src/styles/Home.module.css +185 -195
  81. package/src/styles/globals.css +0 -2
@@ -135,10 +135,10 @@ export const ColorsNew = {
135
135
  } as const;
136
136
 
137
137
  export type TokensT = {
138
- colors: typeof Colors,
138
+ colors: typeof Colors;
139
139
  new: {
140
- colors: typeof ColorsNew,
141
- },
140
+ colors: typeof ColorsNew;
141
+ };
142
142
  };
143
143
 
144
144
  export const Tokens: TokensT = {
@@ -15,7 +15,7 @@
15
15
  border-width: 0; /* 2 */
16
16
  border-style: solid; /* 2 */
17
17
  border-color: var(--pte-new-colors-borderMedium); /* 2 */
18
-
18
+
19
19
  -webkit-tap-highlight-color: transparent;
20
20
  }
21
21
 
@@ -109,7 +109,8 @@ code,
109
109
  kbd,
110
110
  samp,
111
111
  pre {
112
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; /* 1 */
112
+ font-family:
113
+ ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace; /* 1 */
113
114
  font-size: 1em; /* 2 */
114
115
  }
115
116
 
@@ -326,7 +327,7 @@ Set the default cursor for buttons.
326
327
  */
327
328
 
328
329
  button,
329
- [role="button"] {
330
+ [role='button'] {
330
331
  cursor: default;
331
332
  }
332
333
 
@@ -1,8 +1,8 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
1
+ import type { Meta, StoryObj } from '@storybook/nextjs-vite';
2
2
  import type { CSSProperties } from 'react';
3
- import { Tilt } from './Tilt';
4
3
  import { Text } from '../text';
5
4
  import { pvar } from '../theme';
5
+ import { Tilt } from './Tilt';
6
6
 
7
7
  const meta: Meta<typeof Tilt> = {
8
8
  title: 'Surfaces/Tilt',
@@ -34,10 +34,7 @@ export const Default: Story = {
34
34
  } as CSSProperties;
35
35
 
36
36
  return (
37
- <Tilt
38
- {...args}
39
- style={tiltStyle}
40
- >
37
+ <Tilt {...args} style={tiltStyle}>
41
38
  {children}
42
39
  </Tilt>
43
40
  );
@@ -1,19 +1,8 @@
1
1
  'use client';
2
2
 
3
- import {
4
- useCallback,
5
- useEffect,
6
- useRef,
7
- useState,
8
- } from 'react';
9
- import type {
10
- CSSProperties,
11
- FC,
12
- MouseEvent as ReactMouseEvent,
13
- ReactNode,
14
- TouchEvent as ReactTouchEvent,
15
- } from 'react';
16
3
  import { clsx } from 'clsx';
4
+ import type { CSSProperties, FC, MouseEvent as ReactMouseEvent, ReactNode, TouchEvent as ReactTouchEvent } from 'react';
5
+ import { useCallback, useEffect, useRef, useState } from 'react';
17
6
  import styles from './Tilt.module.scss';
18
7
 
19
8
  type GlarePosition = 'top' | 'right' | 'bottom' | 'left' | 'all';
@@ -98,14 +87,23 @@ function computeGlareOpacity(
98
87
  const g = reverse ? -1 : 1;
99
88
  let raw = 0;
100
89
  switch (position) {
101
- case 'top': raw = -xPct * g; break;
102
- case 'right': raw = yPct * g; break;
103
- case 'left': raw = -yPct * g; break;
104
- case 'all': raw = Math.hypot(xPct, yPct); break;
105
- case 'bottom':
106
- default: raw = xPct * g; break;
90
+ case 'top':
91
+ raw = -xPct * g;
92
+ break;
93
+ case 'right':
94
+ raw = yPct * g;
95
+ break;
96
+ case 'left':
97
+ raw = -yPct * g;
98
+ break;
99
+ case 'all':
100
+ raw = Math.hypot(xPct, yPct);
101
+ break;
102
+ default:
103
+ raw = xPct * g;
104
+ break;
107
105
  }
108
- return clamp(raw, 0, 100) * maxOpacity / 100;
106
+ return (clamp(raw, 0, 100) * maxOpacity) / 100;
109
107
  }
110
108
 
111
109
  /**
@@ -165,9 +163,12 @@ export const Tilt: FC<TiltProps> = ({
165
163
  const isManual = effectiveManualX !== null || effectiveManualY !== null;
166
164
 
167
165
  // Cancel any pending rAF on unmount
168
- useEffect(() => () => {
169
- if (rafID.current !== null) cancelAnimationFrame(rafID.current);
170
- }, []);
166
+ useEffect(
167
+ () => () => {
168
+ if (rafID.current !== null) cancelAnimationFrame(rafID.current);
169
+ },
170
+ [],
171
+ );
171
172
 
172
173
  const flushToState = useCallback(() => {
173
174
  if (!pendingRef.current) return;
@@ -176,103 +177,137 @@ export const Tilt: FC<TiltProps> = ({
176
177
  setTilt(next);
177
178
  }, []);
178
179
 
179
- const scheduleUpdate = useCallback((next: TiltState) => {
180
- pendingRef.current = next;
181
- if (rafID.current !== null) cancelAnimationFrame(rafID.current);
182
- rafID.current = requestAnimationFrame(flushToState);
183
- }, [flushToState]);
184
-
185
- const computeTilt = useCallback((pageX: number, pageY: number): TiltState => {
186
- const rect = rectRef.current;
187
- if (!rect) return { ...INITIAL_STATE, currentScale: effectiveScale };
188
-
189
- const xPct = clamp(((pageX - rect.left) / rect.width) * 200 - 100, -100, 100);
190
- const yPct = clamp(((pageY - rect.top) / rect.height) * 200 - 100, -100, 100);
191
-
192
- const angleX = (effectiveManualX !== null) ? effectiveManualX : (yPct * effectiveMaxX / 100);
193
- const angleY = (effectiveManualY !== null) ? effectiveManualY : (xPct * effectiveMaxY / 100 * -1);
194
-
195
- const glareAngle = xPct ? Math.atan2(yPct, -xPct) * (180 / Math.PI) : 0;
196
- const glareOpacity = effectiveGlare
197
- ? computeGlareOpacity(xPct, yPct, glarePosition, glareReverse, effectiveGlareMax)
198
- : 0;
199
-
200
- return {
201
- tiltAngleX: clamp(angleX, -90, 90),
202
- tiltAngleY: clamp(angleY, -90, 90),
203
- currentScale: effectiveScale,
204
- glareAngle,
205
- glareOpacity,
206
- transitioning: false,
207
- };
208
- }, [effectiveScale, effectiveMaxX, effectiveMaxY, effectiveManualX, effectiveManualY, effectiveGlare, effectiveGlareMax, glarePosition, glareReverse]);
209
-
210
- const handleMouseEnter = useCallback((e: ReactMouseEvent<HTMLDivElement>) => {
211
- if (!containerRef.current) return;
212
- rectRef.current = containerRef.current.getBoundingClientRect();
213
-
214
- const next = computeTilt(e.pageX, e.pageY);
215
- setTilt({ ...next, transitioning: true });
216
- onEnter?.({ event: e });
217
- }, [computeTilt, onEnter]);
218
-
219
- const handleMouseMove = useCallback((e: ReactMouseEvent<HTMLDivElement>) => {
220
- if (!containerRef.current || !rectRef.current) return;
221
- if (effectiveManualX !== null || effectiveManualY !== null) return;
222
-
223
- const next = computeTilt(e.pageX, e.pageY);
224
- scheduleUpdate(next);
225
-
226
- if (onMove) {
227
- onMove({
228
- tiltAngleX: next.tiltAngleX,
229
- tiltAngleY: next.tiltAngleY,
230
- tiltAngleXPercentage: effectiveMaxX ? (next.tiltAngleX / effectiveMaxX) * 100 : 0,
231
- tiltAngleYPercentage: effectiveMaxY ? (next.tiltAngleY / effectiveMaxY) * 100 : 0,
232
- glareAngle: next.glareAngle,
233
- glareOpacity: next.glareOpacity,
234
- });
235
- }
236
- }, [computeTilt, scheduleUpdate, onMove, effectiveManualX, effectiveManualY, effectiveMaxX, effectiveMaxY]);
180
+ const scheduleUpdate = useCallback(
181
+ (next: TiltState) => {
182
+ pendingRef.current = next;
183
+ if (rafID.current !== null) cancelAnimationFrame(rafID.current);
184
+ rafID.current = requestAnimationFrame(flushToState);
185
+ },
186
+ [flushToState],
187
+ );
188
+
189
+ const computeTilt = useCallback(
190
+ (pageX: number, pageY: number): TiltState => {
191
+ const rect = rectRef.current;
192
+ if (!rect) return { ...INITIAL_STATE, currentScale: effectiveScale };
193
+
194
+ const xPct = clamp(((pageX - rect.left) / rect.width) * 200 - 100, -100, 100);
195
+ const yPct = clamp(((pageY - rect.top) / rect.height) * 200 - 100, -100, 100);
196
+
197
+ const angleX = effectiveManualX !== null ? effectiveManualX : (yPct * effectiveMaxX) / 100;
198
+ const angleY = effectiveManualY !== null ? effectiveManualY : ((xPct * effectiveMaxY) / 100) * -1;
199
+
200
+ const glareAngle = xPct ? Math.atan2(yPct, -xPct) * (180 / Math.PI) : 0;
201
+ const glareOpacity = effectiveGlare
202
+ ? computeGlareOpacity(xPct, yPct, glarePosition, glareReverse, effectiveGlareMax)
203
+ : 0;
204
+
205
+ return {
206
+ tiltAngleX: clamp(angleX, -90, 90),
207
+ tiltAngleY: clamp(angleY, -90, 90),
208
+ currentScale: effectiveScale,
209
+ glareAngle,
210
+ glareOpacity,
211
+ transitioning: false,
212
+ };
213
+ },
214
+ [
215
+ effectiveScale,
216
+ effectiveMaxX,
217
+ effectiveMaxY,
218
+ effectiveManualX,
219
+ effectiveManualY,
220
+ effectiveGlare,
221
+ effectiveGlareMax,
222
+ glarePosition,
223
+ glareReverse,
224
+ ],
225
+ );
237
226
 
238
- const handleMouseLeave = useCallback((e: ReactMouseEvent<HTMLDivElement>) => {
239
- if (!containerRef.current) return;
240
- rectRef.current = null;
227
+ const handleMouseEnter = useCallback(
228
+ (e: ReactMouseEvent<HTMLDivElement>) => {
229
+ if (!containerRef.current) return;
230
+ rectRef.current = containerRef.current.getBoundingClientRect();
241
231
 
242
- if (reset) {
243
- setTilt({ ...INITIAL_STATE, transitioning: true });
244
- }
245
- onLeave?.({ event: e });
246
- }, [reset, onLeave]);
247
-
248
- const handleTouchStart = useCallback((e: ReactTouchEvent<HTMLDivElement>) => {
249
- if (!containerRef.current || !e.touches[0]) return;
250
- rectRef.current = containerRef.current.getBoundingClientRect();
251
-
252
- const touch = e.touches[0];
253
- const next = computeTilt(touch.pageX, touch.pageY);
254
- setTilt({ ...next, transitioning: true });
255
- onEnter?.({ event: e });
256
- }, [computeTilt, onEnter]);
257
-
258
- const handleTouchMove = useCallback((e: ReactTouchEvent<HTMLDivElement>) => {
259
- if (!containerRef.current || !rectRef.current || !e.touches[0]) return;
260
- if (effectiveManualX !== null || effectiveManualY !== null) return;
261
-
262
- const touch = e.touches[0];
263
- const next = computeTilt(touch.pageX, touch.pageY);
264
- scheduleUpdate(next);
265
- }, [computeTilt, scheduleUpdate, effectiveManualX, effectiveManualY]);
266
-
267
- const handleTouchEnd = useCallback((e: ReactTouchEvent<HTMLDivElement>) => {
268
- if (!containerRef.current) return;
269
- rectRef.current = null;
270
-
271
- if (reset) {
272
- setTilt({ ...INITIAL_STATE, transitioning: true });
273
- }
274
- onLeave?.({ event: e });
275
- }, [reset, onLeave]);
232
+ const next = computeTilt(e.pageX, e.pageY);
233
+ setTilt({ ...next, transitioning: true });
234
+ onEnter?.({ event: e });
235
+ },
236
+ [computeTilt, onEnter],
237
+ );
238
+
239
+ const handleMouseMove = useCallback(
240
+ (e: ReactMouseEvent<HTMLDivElement>) => {
241
+ if (!containerRef.current || !rectRef.current) return;
242
+ if (effectiveManualX !== null || effectiveManualY !== null) return;
243
+
244
+ const next = computeTilt(e.pageX, e.pageY);
245
+ scheduleUpdate(next);
246
+
247
+ if (onMove) {
248
+ onMove({
249
+ tiltAngleX: next.tiltAngleX,
250
+ tiltAngleY: next.tiltAngleY,
251
+ tiltAngleXPercentage: effectiveMaxX ? (next.tiltAngleX / effectiveMaxX) * 100 : 0,
252
+ tiltAngleYPercentage: effectiveMaxY ? (next.tiltAngleY / effectiveMaxY) * 100 : 0,
253
+ glareAngle: next.glareAngle,
254
+ glareOpacity: next.glareOpacity,
255
+ });
256
+ }
257
+ },
258
+ [computeTilt, scheduleUpdate, onMove, effectiveManualX, effectiveManualY, effectiveMaxX, effectiveMaxY],
259
+ );
260
+
261
+ const handleMouseLeave = useCallback(
262
+ (e: ReactMouseEvent<HTMLDivElement>) => {
263
+ if (!containerRef.current) return;
264
+ rectRef.current = null;
265
+
266
+ if (reset) {
267
+ setTilt({ ...INITIAL_STATE, transitioning: true });
268
+ }
269
+ onLeave?.({ event: e });
270
+ },
271
+ [reset, onLeave],
272
+ );
273
+
274
+ const handleTouchStart = useCallback(
275
+ (e: ReactTouchEvent<HTMLDivElement>) => {
276
+ if (!containerRef.current || !e.touches[0]) return;
277
+ rectRef.current = containerRef.current.getBoundingClientRect();
278
+
279
+ const touch = e.touches[0];
280
+ const next = computeTilt(touch.pageX, touch.pageY);
281
+ setTilt({ ...next, transitioning: true });
282
+ onEnter?.({ event: e });
283
+ },
284
+ [computeTilt, onEnter],
285
+ );
286
+
287
+ const handleTouchMove = useCallback(
288
+ (e: ReactTouchEvent<HTMLDivElement>) => {
289
+ if (!containerRef.current || !rectRef.current || !e.touches[0]) return;
290
+ if (effectiveManualX !== null || effectiveManualY !== null) return;
291
+
292
+ const touch = e.touches[0];
293
+ const next = computeTilt(touch.pageX, touch.pageY);
294
+ scheduleUpdate(next);
295
+ },
296
+ [computeTilt, scheduleUpdate, effectiveManualX, effectiveManualY],
297
+ );
298
+
299
+ const handleTouchEnd = useCallback(
300
+ (e: ReactTouchEvent<HTMLDivElement>) => {
301
+ if (!containerRef.current) return;
302
+ rectRef.current = null;
303
+
304
+ if (reset) {
305
+ setTilt({ ...INITIAL_STATE, transitioning: true });
306
+ }
307
+ onLeave?.({ event: e });
308
+ },
309
+ [reset, onLeave],
310
+ );
276
311
 
277
312
  // Compute glare element size (diagonal of container)
278
313
  const [glareSize, setGlareSize] = useState(0);
@@ -297,9 +332,8 @@ export const Tilt: FC<TiltProps> = ({
297
332
 
298
333
  const transform = `perspective(${perspective}px) rotateX(${finalAngleX}deg) rotateY(${finalAngleY}deg) scale3d(${finalScale},${finalScale},${finalScale})`;
299
334
 
300
- const transition = tilt.transitioning || isManual
301
- ? `transform ${transitionSpeed}ms ${transitionEasing}`
302
- : undefined;
335
+ const transition =
336
+ tilt.transitioning || isManual ? `transform ${transitionSpeed}ms ${transitionEasing}` : undefined;
303
337
 
304
338
  return (
305
339
  <div
@@ -315,15 +349,15 @@ export const Tilt: FC<TiltProps> = ({
315
349
  ...style,
316
350
  transform,
317
351
  transition,
318
- willChange: tilt.transitioning || finalScale !== 1 || finalAngleX !== 0 || finalAngleY !== 0 ? 'transform' : undefined,
352
+ willChange:
353
+ tilt.transitioning || finalScale !== 1 || finalAngleX !== 0 || finalAngleY !== 0
354
+ ? 'transform'
355
+ : undefined,
319
356
  }}
320
357
  >
321
358
  {children}
322
359
  {effectiveGlare && (
323
- <div
324
- className={styles.glareWrapper}
325
- style={{ borderRadius: computedGlareBorderRadius }}
326
- >
360
+ <div className={styles.glareWrapper} style={{ borderRadius: computedGlareBorderRadius }}>
327
361
  <div
328
362
  className={styles.glare}
329
363
  style={{
@@ -1,7 +1,7 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { toast, Toast } from './Toast';
1
+ import type { Meta, StoryObj } from '@storybook/nextjs-vite';
3
2
  import { Button } from '../button';
4
3
  import { ChevronRight, Icon } from '../icon';
4
+ import { Toast, toast } from './Toast';
5
5
 
6
6
  const meta: Meta<typeof Toast> = {
7
7
  title: 'Surfaces/Toast',
@@ -1,9 +1,9 @@
1
+ import { clsx } from 'clsx';
1
2
  import type { FC } from 'react';
2
3
  import type { ToasterProps } from 'react-hot-toast';
3
4
  import { Toaster } from 'react-hot-toast';
4
- import { clsx } from 'clsx';
5
- import styles from './Toast.module.scss';
6
5
  import typography from '../text/Typography.module.css';
6
+ import styles from './Toast.module.scss';
7
7
 
8
8
  export type ToastProps = ToasterProps;
9
9
 
@@ -34,10 +34,7 @@ export type ToastProps = ToasterProps;
34
34
  * ```
35
35
  * @constructor
36
36
  */
37
- export const Toast: FC<ToastProps> = ({
38
- toastOptions,
39
- ...props
40
- }) => (
37
+ export const Toast: FC<ToastProps> = ({ toastOptions, ...props }) => (
41
38
  <Toaster
42
39
  {...props}
43
40
  toastOptions={{
@@ -4,16 +4,12 @@ import { memo } from 'react';
4
4
  /**
5
5
  * A memoized component that conditionally removes its children from the DOM if the `when` prop is `true`.
6
6
  */
7
- export const RemoveFromDOM = memo<PropsWithChildren<{
8
- /**
9
- * An optional condition that determines whether the children should be removed from the DOM. If `true`, the children will be removed.
10
- * @default true
11
- */
12
- when: boolean;
13
- }>>(
14
- ({ when, children }) => (when ? (<></>) : (
15
- <>
16
- {children}
17
- </>
18
- )),
19
- );
7
+ export const RemoveFromDOM = memo<
8
+ PropsWithChildren<{
9
+ /**
10
+ * An optional condition that determines whether the children should be removed from the DOM. If `true`, the children will be removed.
11
+ * @default true
12
+ */
13
+ when: boolean;
14
+ }>
15
+ >(({ when, children }) => (when ? <></> : children));
@@ -6,23 +6,10 @@ import { Text } from '../text';
6
6
  /**
7
7
  * A memoized component that renders its children as a {@link Text} component if `children` is just a string.
8
8
  */
9
- export const TextWhenString = memo<PropsWithChildren<TextProps<TextElement>>>(({
10
- children,
11
- ...props
12
- }) => {
9
+ export const TextWhenString = memo<PropsWithChildren<TextProps<TextElement>>>(({ children, ...props }) => {
13
10
  if (typeof children === 'string' || typeof children === 'number') {
14
- return (
15
- <Text
16
- {...props}
17
- >
18
- {children}
19
- </Text>
20
- );
11
+ return <Text {...props}>{children}</Text>;
21
12
  }
22
13
 
23
- return (
24
- <>
25
- {children}
26
- </>
27
- );
14
+ return <>{children}</>;
28
15
  });
@@ -1,25 +1,18 @@
1
+ import { VisuallyHidden as AriaVisuallyHidden } from '@ariakit/react';
1
2
  import type { PropsWithChildren } from 'react';
2
3
  import { memo } from 'react';
3
- import { VisuallyHidden as AriaVisuallyHidden } from '@ariakit/react';
4
4
 
5
5
  /**
6
6
  * A memoized component that visually hides its children, but keeps them accessible to screen readers.
7
7
  *
8
8
  * Specify the `when` prop to conditionally render the children normally.
9
9
  */
10
- export const VisuallyHidden = memo<PropsWithChildren<{
11
- /**
12
- * An optional condition that determines whether the children should be hidden. If `false`, the children will be rendered normally.
13
- * @default true
14
- */
15
- when?: boolean;
16
- }>>(({
17
- when = true,
18
- children,
19
- }) => (when ? (
20
- <AriaVisuallyHidden>
21
- {children}
22
- </AriaVisuallyHidden>
23
- ) : (
24
- <>{children}</>
25
- )));
10
+ export const VisuallyHidden = memo<
11
+ PropsWithChildren<{
12
+ /**
13
+ * An optional condition that determines whether the children should be hidden. If `false`, the children will be rendered normally.
14
+ * @default true
15
+ */
16
+ when?: boolean;
17
+ }>
18
+ >(({ when = true, children }) => (when ? <AriaVisuallyHidden>{children}</AriaVisuallyHidden> : children));