@react-md/core 6.2.1 → 6.3.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.
- package/dist/_base.scss +1 -1
- package/dist/app-bar/styles.d.ts +0 -2
- package/dist/app-bar/styles.js.map +1 -1
- package/dist/autocomplete/types.d.ts +12 -0
- package/dist/autocomplete/types.js.map +1 -1
- package/dist/avatar/Avatar.d.ts +0 -10
- package/dist/avatar/Avatar.js.map +1 -1
- package/dist/avatar/styles.d.ts +10 -0
- package/dist/avatar/styles.js.map +1 -1
- package/dist/badge/Badge.d.ts +11 -0
- package/dist/badge/Badge.js.map +1 -1
- package/dist/badge/styles.d.ts +0 -8
- package/dist/badge/styles.js.map +1 -1
- package/dist/box/_box.scss +8 -8
- package/dist/box/styles.d.ts +9 -0
- package/dist/box/styles.js.map +1 -1
- package/dist/button/_button.scss +4 -0
- package/dist/button/styles.d.ts +5 -1
- package/dist/button/styles.js.map +1 -1
- package/dist/card/Card.d.ts +0 -7
- package/dist/card/Card.js.map +1 -1
- package/dist/card/styles.d.ts +6 -0
- package/dist/card/styles.js +8 -8
- package/dist/card/styles.js.map +1 -1
- package/dist/chip/Chip.d.ts +6 -13
- package/dist/chip/Chip.js.map +1 -1
- package/dist/chip/styles.d.ts +26 -1
- package/dist/chip/styles.js.map +1 -1
- package/dist/datetime/NativeDateField.d.ts +24 -0
- package/dist/datetime/NativeDateField.js +63 -0
- package/dist/datetime/NativeDateField.js.map +1 -0
- package/dist/datetime/NativeTimeField.d.ts +26 -0
- package/dist/datetime/NativeTimeField.js +63 -0
- package/dist/datetime/NativeTimeField.js.map +1 -0
- package/dist/datetime/useDateField.d.ts +120 -0
- package/dist/datetime/useDateField.js +35 -0
- package/dist/datetime/useDateField.js.map +1 -0
- package/dist/datetime/useTimeField.d.ts +124 -0
- package/dist/datetime/useTimeField.js +65 -0
- package/dist/datetime/useTimeField.js.map +1 -0
- package/dist/datetime/utils.d.ts +34 -0
- package/dist/datetime/utils.js +27 -0
- package/dist/datetime/utils.js.map +1 -0
- package/dist/dialog/styles.d.ts +5 -2
- package/dist/dialog/styles.js.map +1 -1
- package/dist/divider/styles.d.ts +1 -1
- package/dist/divider/styles.js.map +1 -1
- package/dist/draggable/utils.d.ts +3 -6
- package/dist/draggable/utils.js.map +1 -1
- package/dist/error-boundary/ErrorBoundary.js.map +1 -1
- package/dist/expansion-panel/ExpansionList.js +1 -1
- package/dist/expansion-panel/ExpansionList.js.map +1 -1
- package/dist/expansion-panel/useExpansionList.d.ts +2 -7
- package/dist/expansion-panel/useExpansionList.js.map +1 -1
- package/dist/files/validation.js.map +1 -1
- package/dist/form/FormMessage.js +3 -1
- package/dist/form/FormMessage.js.map +1 -1
- package/dist/form/FormMessageContainer.d.ts +2 -1
- package/dist/form/FormMessageContainer.js +3 -2
- package/dist/form/FormMessageContainer.js.map +1 -1
- package/dist/form/FormMessageCounter.d.ts +3 -2
- package/dist/form/FormMessageCounter.js +5 -2
- package/dist/form/FormMessageCounter.js.map +1 -1
- package/dist/form/InputToggle.js.map +1 -1
- package/dist/form/Label.d.ts +0 -10
- package/dist/form/Label.js.map +1 -1
- package/dist/form/Listbox.d.ts +3 -10
- package/dist/form/Listbox.js +8 -27
- package/dist/form/Listbox.js.map +1 -1
- package/dist/form/ListboxProvider.d.ts +17 -0
- package/dist/form/ListboxProvider.js +33 -1
- package/dist/form/ListboxProvider.js.map +1 -1
- package/dist/form/NativeSelect.js +1 -0
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/Slider.d.ts +4 -0
- package/dist/form/Slider.js.map +1 -1
- package/dist/form/Switch.js.map +1 -1
- package/dist/form/TextArea.js +1 -0
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextField.js +1 -0
- package/dist/form/TextField.js.map +1 -1
- package/dist/form/TextFieldContainer.d.ts +0 -13
- package/dist/form/TextFieldContainer.js.map +1 -1
- package/dist/form/_form-message.scss +13 -0
- package/dist/form/_select.scss +5 -1
- package/dist/form/_text-area.scss +2 -1
- package/dist/form/_text-field.scss +13 -3
- package/dist/form/formMessageContainerStyles.d.ts +7 -0
- package/dist/form/formMessageContainerStyles.js +4 -2
- package/dist/form/formMessageContainerStyles.js.map +1 -1
- package/dist/form/sliderUtils.d.ts +3 -7
- package/dist/form/sliderUtils.js.map +1 -1
- package/dist/form/types.d.ts +33 -0
- package/dist/form/types.js.map +1 -1
- package/dist/form/useCombobox.d.ts +6 -2
- package/dist/form/useCombobox.js +8 -9
- package/dist/form/useCombobox.js.map +1 -1
- package/dist/form/useFormReset.d.ts +4 -1
- package/dist/form/useFormReset.js +9 -4
- package/dist/form/useFormReset.js.map +1 -1
- package/dist/form/useNumberField.d.ts +5 -5
- package/dist/form/useNumberField.js +10 -2
- package/dist/form/useNumberField.js.map +1 -1
- package/dist/form/useSelectCombobox.js +2 -2
- package/dist/form/useSelectCombobox.js.map +1 -1
- package/dist/form/useTextField.d.ts +76 -59
- package/dist/form/useTextField.js +7 -1
- package/dist/form/useTextField.js.map +1 -1
- package/dist/interaction/types.d.ts +5 -1
- package/dist/interaction/types.js.map +1 -1
- package/dist/interaction/utils.d.ts +14 -0
- package/dist/interaction/utils.js +23 -12
- package/dist/interaction/utils.js.map +1 -1
- package/dist/link/Link.d.ts +0 -7
- package/dist/link/Link.js.map +1 -1
- package/dist/link/styles.d.ts +7 -0
- package/dist/link/styles.js.map +1 -1
- package/dist/list/List.d.ts +5 -20
- package/dist/list/List.js.map +1 -1
- package/dist/list/ListItem.d.ts +4 -38
- package/dist/list/ListItem.js.map +1 -1
- package/dist/list/listItemStyles.d.ts +24 -2
- package/dist/list/listItemStyles.js.map +1 -1
- package/dist/list/listStyles.d.ts +17 -2
- package/dist/list/listStyles.js.map +1 -1
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuBar.js +1 -1
- package/dist/menu/MenuBar.js.map +1 -1
- package/dist/menu/MenuItemTextField.d.ts +1 -2
- package/dist/menu/MenuItemTextField.js.map +1 -1
- package/dist/menu/MenuWidget.js +3 -2
- package/dist/menu/MenuWidget.js.map +1 -1
- package/dist/movement/constants.d.ts +10 -0
- package/dist/movement/constants.js +20 -4
- package/dist/movement/constants.js.map +1 -1
- package/dist/movement/types.d.ts +59 -10
- package/dist/movement/types.js.map +1 -1
- package/dist/movement/useKeyboardMovementProvider.d.ts +5 -1
- package/dist/movement/useKeyboardMovementProvider.js +171 -73
- package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
- package/dist/navigation/NavItem.d.ts +4 -1
- package/dist/navigation/NavItem.js.map +1 -1
- package/dist/navigation/navItemStyles.d.ts +7 -0
- package/dist/navigation/navItemStyles.js.map +1 -1
- package/dist/overlay/Overlay.d.ts +4 -23
- package/dist/overlay/Overlay.js.map +1 -1
- package/dist/overlay/styles.d.ts +26 -8
- package/dist/overlay/styles.js.map +1 -1
- package/dist/progress/LinearProgress.d.ts +4 -9
- package/dist/progress/LinearProgress.js.map +1 -1
- package/dist/progress/circularProgressStyles.d.ts +6 -0
- package/dist/progress/circularProgressStyles.js.map +1 -1
- package/dist/progress/linearProgressStyles.d.ts +20 -5
- package/dist/progress/linearProgressStyles.js.map +1 -1
- package/dist/progress/types.d.ts +0 -9
- package/dist/progress/types.js.map +1 -1
- package/dist/segmented-button/SegmentedButton.d.ts +7 -12
- package/dist/segmented-button/SegmentedButton.js.map +1 -1
- package/dist/segmented-button/segmentedButtonStyles.d.ts +26 -3
- package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
- package/dist/sheet/Sheet.d.ts +0 -12
- package/dist/sheet/Sheet.js.map +1 -1
- package/dist/sheet/styles.d.ts +12 -0
- package/dist/sheet/styles.js.map +1 -1
- package/dist/snackbar/Toast.d.ts +2 -13
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/snackbar/ToastManager.js.map +1 -1
- package/dist/snackbar/toastStyles.d.ts +17 -2
- package/dist/snackbar/toastStyles.js.map +1 -1
- package/dist/tabs/Tab.d.ts +2 -41
- package/dist/tabs/Tab.js.map +1 -1
- package/dist/tabs/tabStyles.d.ts +45 -4
- package/dist/tabs/tabStyles.js.map +1 -1
- package/dist/tabs/useTabList.js +1 -1
- package/dist/tabs/useTabList.js.map +1 -1
- package/dist/test-utils/drag.d.ts +6 -9
- package/dist/test-utils/mocks/IntersectionObserver.js.map +1 -1
- package/dist/test-utils/mocks/ResizeObserver.js.map +1 -1
- package/dist/test-utils/utils/createFileList.js.map +1 -1
- package/dist/theme/_theme.scss +0 -1
- package/dist/theme/getDerivedTheme.d.ts +0 -24
- package/dist/theme/getDerivedTheme.js.map +1 -1
- package/dist/theme/types.d.ts +25 -0
- package/dist/theme/types.js.map +1 -1
- package/dist/tooltip/Tooltip.d.ts +4 -32
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/styles.d.ts +38 -1
- package/dist/tooltip/styles.js +1 -1
- package/dist/tooltip/styles.js.map +1 -1
- package/dist/transition/SkeletonPlaceholder.d.ts +0 -7
- package/dist/transition/SkeletonPlaceholder.js.map +1 -1
- package/dist/transition/Slide.js.map +1 -1
- package/dist/transition/skeletonPlaceholderUtils.d.ts +7 -0
- package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
- package/dist/transition/useCarousel.d.ts +2 -2
- package/dist/transition/useCarousel.js.map +1 -1
- package/dist/transition/useMaxWidthTransition.d.ts +14 -2
- package/dist/transition/useMaxWidthTransition.js.map +1 -1
- package/dist/transition/useSlideTransition.d.ts +5 -0
- package/dist/transition/useSlideTransition.js.map +1 -1
- package/dist/tree/Tree.d.ts +5 -9
- package/dist/tree/Tree.js +1 -1
- package/dist/tree/Tree.js.map +1 -1
- package/dist/tree/styles.d.ts +9 -1
- package/dist/tree/styles.js.map +1 -1
- package/dist/tree/useTreeMovement.d.ts +2 -1
- package/dist/tree/useTreeMovement.js +2 -1
- package/dist/tree/useTreeMovement.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.js.map +1 -1
- package/dist/typography/Mark.d.ts +4 -1
- package/dist/typography/Mark.js.map +1 -1
- package/dist/typography/TextContainer.d.ts +0 -6
- package/dist/typography/TextContainer.js.map +1 -1
- package/dist/typography/markStyles.d.ts +5 -0
- package/dist/typography/markStyles.js.map +1 -1
- package/dist/typography/textContainerStyles.d.ts +6 -0
- package/dist/typography/textContainerStyles.js.map +1 -1
- package/dist/typography/typographyStyles.d.ts +9 -0
- package/dist/typography/typographyStyles.js.map +1 -1
- package/dist/useResizeObserver.js.map +1 -1
- package/dist/utils/getMiddleOfRange.d.ts +2 -3
- package/dist/utils/getMiddleOfRange.js.map +1 -1
- package/dist/utils/getPercentage.d.ts +2 -9
- package/dist/utils/getPercentage.js +1 -1
- package/dist/utils/getPercentage.js.map +1 -1
- package/dist/utils/getRangeSteps.d.ts +2 -3
- package/dist/utils/getRangeSteps.js +0 -3
- package/dist/utils/getRangeSteps.js.map +1 -1
- package/dist/utils/nearest.d.ts +2 -3
- package/dist/utils/nearest.js +0 -3
- package/dist/utils/nearest.js.map +1 -1
- package/dist/utils/trigonometry.d.ts +31 -0
- package/dist/utils/trigonometry.js +25 -0
- package/dist/utils/trigonometry.js.map +1 -0
- package/dist/window-splitter/WindowSplitter.d.ts +5 -19
- package/dist/window-splitter/WindowSplitter.js.map +1 -1
- package/dist/window-splitter/styles.d.ts +27 -3
- package/dist/window-splitter/styles.js.map +1 -1
- package/dist/window-splitter/useWindowSplitter.d.ts +1 -1
- package/dist/window-splitter/useWindowSplitter.js.map +1 -1
- package/package.json +8 -8
- package/src/app-bar/styles.ts +0 -2
- package/src/autocomplete/types.ts +17 -0
- package/src/avatar/Avatar.tsx +0 -11
- package/src/avatar/styles.ts +11 -0
- package/src/badge/Badge.tsx +12 -0
- package/src/badge/styles.ts +0 -9
- package/src/box/styles.ts +9 -0
- package/src/button/styles.ts +5 -1
- package/src/card/Card.tsx +0 -8
- package/src/card/styles.ts +15 -8
- package/src/chip/Chip.tsx +9 -15
- package/src/chip/styles.ts +29 -1
- package/src/datetime/NativeDateField.tsx +92 -0
- package/src/datetime/NativeTimeField.tsx +94 -0
- package/src/datetime/useDateField.ts +193 -0
- package/src/datetime/useTimeField.ts +233 -0
- package/src/datetime/utils.ts +48 -0
- package/src/dialog/styles.ts +5 -2
- package/src/divider/styles.ts +1 -1
- package/src/draggable/utils.ts +3 -6
- package/src/expansion-panel/ExpansionList.tsx +2 -1
- package/src/expansion-panel/useExpansionList.ts +6 -12
- package/src/form/FormMessage.tsx +4 -0
- package/src/form/FormMessageContainer.tsx +8 -4
- package/src/form/FormMessageCounter.tsx +17 -6
- package/src/form/InputToggle.tsx +2 -0
- package/src/form/Label.tsx +0 -11
- package/src/form/Listbox.tsx +18 -46
- package/src/form/ListboxProvider.ts +61 -1
- package/src/form/NativeSelect.tsx +1 -0
- package/src/form/Slider.tsx +6 -0
- package/src/form/Switch.tsx +2 -0
- package/src/form/TextArea.tsx +3 -0
- package/src/form/TextField.tsx +1 -0
- package/src/form/TextFieldContainer.tsx +0 -14
- package/src/form/formMessageContainerStyles.ts +10 -2
- package/src/form/sliderUtils.ts +3 -7
- package/src/form/types.ts +44 -0
- package/src/form/useCombobox.ts +15 -10
- package/src/form/useFormReset.ts +12 -5
- package/src/form/useNumberField.ts +17 -14
- package/src/form/useSelectCombobox.ts +2 -2
- package/src/form/useTextField.ts +102 -69
- package/src/interaction/types.ts +5 -1
- package/src/interaction/utils.ts +18 -20
- package/src/link/Link.tsx +0 -8
- package/src/link/styles.ts +8 -0
- package/src/list/List.tsx +7 -24
- package/src/list/ListItem.tsx +7 -43
- package/src/list/listItemStyles.ts +26 -2
- package/src/list/listStyles.ts +18 -2
- package/src/menu/Menu.tsx +2 -0
- package/src/menu/MenuBar.tsx +1 -1
- package/src/menu/MenuItemTextField.tsx +1 -3
- package/src/menu/MenuWidget.tsx +4 -2
- package/src/movement/constants.ts +26 -4
- package/src/movement/types.ts +84 -19
- package/src/movement/useKeyboardMovementProvider.ts +209 -95
- package/src/navigation/NavItem.tsx +6 -2
- package/src/navigation/navItemStyles.ts +8 -0
- package/src/overlay/Overlay.tsx +4 -26
- package/src/overlay/styles.ts +29 -10
- package/src/progress/LinearProgress.tsx +8 -10
- package/src/progress/circularProgressStyles.ts +7 -0
- package/src/progress/linearProgressStyles.ts +22 -5
- package/src/progress/types.ts +0 -10
- package/src/segmented-button/SegmentedButton.tsx +14 -15
- package/src/segmented-button/segmentedButtonStyles.ts +28 -3
- package/src/sheet/Sheet.tsx +0 -13
- package/src/sheet/styles.ts +13 -0
- package/src/snackbar/Toast.tsx +2 -15
- package/src/snackbar/toastStyles.ts +20 -2
- package/src/tabs/Tab.tsx +4 -49
- package/src/tabs/tabStyles.ts +52 -4
- package/src/tabs/useTabList.ts +1 -1
- package/src/test-utils/drag.ts +8 -12
- package/src/theme/getDerivedTheme.ts +0 -26
- package/src/theme/types.ts +26 -0
- package/src/tooltip/Tooltip.tsx +4 -36
- package/src/tooltip/styles.ts +43 -2
- package/src/transition/SkeletonPlaceholder.tsx +0 -8
- package/src/transition/Slide.tsx +2 -0
- package/src/transition/skeletonPlaceholderUtils.ts +8 -0
- package/src/transition/useCarousel.ts +2 -2
- package/src/transition/useMaxWidthTransition.ts +17 -2
- package/src/transition/useSlideTransition.ts +8 -0
- package/src/tree/Tree.tsx +6 -11
- package/src/tree/styles.ts +10 -1
- package/src/tree/useTreeMovement.ts +4 -0
- package/src/types.ts +16 -0
- package/src/typography/Mark.tsx +6 -2
- package/src/typography/TextContainer.tsx +0 -7
- package/src/typography/markStyles.ts +6 -0
- package/src/typography/textContainerStyles.ts +7 -0
- package/src/typography/typographyStyles.ts +10 -0
- package/src/utils/getMiddleOfRange.ts +2 -3
- package/src/utils/getPercentage.ts +3 -11
- package/src/utils/getRangeSteps.ts +3 -3
- package/src/utils/nearest.ts +3 -3
- package/src/utils/trigonometry.ts +46 -0
- package/src/window-splitter/WindowSplitter.tsx +9 -22
- package/src/window-splitter/styles.ts +31 -3
- package/src/window-splitter/useWindowSplitter.ts +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useResizeObserver.ts"],"sourcesContent":["\"use client\";\n\nimport { type Ref, type RefCallback, useEffect } from \"react\";\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useElementSize } from \"./useElementSize.js\";\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n/**\n * @since 6.0.0\n */\nexport type ResizeObserverEntryCallback = (entry: ResizeObserverEntry) => void;\n\n/** @internal */\ntype Unsubscribe = () => void;\n\n/** @internal */\ninterface TargetSize {\n height: number;\n width: number;\n scrollHeight: number;\n scrollWidth: number;\n}\n\n/** @internal */\ninterface TargetSubscription {\n onUpdate: ResizeObserverEntryCallback;\n disableHeight: boolean;\n disableWidth: boolean;\n\n size?: TargetSize;\n}\n\n/** @internal */\ninterface SubscribeOptions {\n element: Element;\n onUpdate: ResizeObserverEntryCallback;\n disableHeight: boolean;\n disableWidth: boolean;\n}\n\n/**\n * @internal\n * @since 6.0.0 This was added to help with testing. The\n * `subscriptions` and `sharedObserver` used to be module-level variables but\n * moving to a class makes it easier to mock. Checkout the\n * `src/tests-utils/ResizeObserver.ts`\n */\nexport class ResizeObserverManager {\n frame: number;\n subscriptions: Map<Element, Set<TargetSubscription>>;\n\n /**\n * Why is there a single shared observer instead of multiple and a\n * \"subscription\" model?\n *\n * Note: Probably a bit of a premature optimization right now...\n *\n * @see https://github.com/WICG/resize-observer/issues/59\n * @internal\n */\n sharedObserver: ResizeObserver | undefined;\n\n constructor() {\n this.frame = 0;\n this.subscriptions = new Map();\n }\n\n subscribe = (options: SubscribeOptions): Unsubscribe => {\n const { element, onUpdate, disableHeight, disableWidth } = options;\n\n // lazy initialize the observer\n const observer =\n this.sharedObserver ||\n new ResizeObserver((entries) => {\n // this prevents the `ResizeObserver loop limit exceeded`\n window.cancelAnimationFrame(this.frame);\n this.frame = window.requestAnimationFrame(() => {\n this.handleResizeEntries(entries);\n });\n });\n this.sharedObserver = observer;\n\n const updates = this.subscriptions.get(element) || new Set();\n const subscription: TargetSubscription = {\n onUpdate,\n disableHeight,\n disableWidth,\n };\n updates.add(subscription);\n if (!this.subscriptions.has(element)) {\n this.subscriptions.set(element, updates);\n }\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n updates.delete(subscription);\n };\n };\n\n handleResizeEntries = (entries: ResizeObserverEntry[]): void => {\n for (const entry of entries) {\n const targetSubscriptions = this.subscriptions.get(entry.target);\n // shouldn't really happen\n /* c8 ignore start */\n if (!targetSubscriptions) {\n continue;\n }\n /* c8 ignore stop */\n\n const entries = targetSubscriptions.values();\n for (const subscription of entries) {\n const { height, width } = entry.contentRect;\n const { scrollHeight, scrollWidth } = entry.target;\n const { onUpdate, size, disableHeight, disableWidth } = subscription;\n const isHeightChange =\n !disableHeight &&\n (!size ||\n size.height !== height ||\n size.scrollHeight !== scrollHeight);\n const isWidthChange =\n !disableWidth &&\n (!size || size.width !== width || size.scrollWidth !== scrollWidth);\n\n subscription.size = {\n height,\n width,\n scrollHeight,\n scrollWidth,\n };\n if (isHeightChange || isWidthChange) {\n onUpdate(entry);\n }\n }\n }\n };\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport const resizeObserverManager = new ResizeObserverManager();\n\n/**\n * @since 2.3.0\n * @since 6.0.0 Renamed from `UseResizeObserverOptions` and added\n * `onUpdate`/`disabled` options.\n */\nexport interface ResizeObserverHookOptions<E extends HTMLElement> {\n /**\n * An optional ref to merge with the ref returned by this hook.\n */\n ref?: Ref<E>;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * ResizeObserver each render.**\n *\n * This function will be called whenever the target element resizes.\n *\n * @see {@link useResizeObserver} for an example.\n */\n onUpdate: ResizeObserverEntryCallback;\n\n /**\n * Set this to `true` to prevent observing the element's size changes. This is\n * equivalent to not attaching the returned ref to any element.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * Set this to `true` if the {@link onUpdate} should not be fired for height\n * changes.\n *\n * @defaultValue `false`\n */\n disableHeight?: boolean;\n\n /**\n * Set this to `true` if the {@link onUpdate} should not be fired for width\n * changes.\n *\n * @defaultValue `false`\n */\n disableWidth?: boolean;\n}\n\n/**\n * The resize observer is used to track the size changes of a specific element.\n * For most cases you can use the {@link useElementSize} instead, but this hook\n * can be used for more complex behavior with the {@link ResizeObserverEntry}.\n *\n * @example Simple Example\n * ```tsx\n * import { useResizeObserver } from \"@react-md/core/useResizeObserver\";\n * import { useCallback, useState, type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const elementRef = useResizeObserver({\n * onUpdate: useCallback((entry) => {\n * const element = entry.target;\n * const { height, width } = entry.contentRect;\n * const { inlineSize, blockSize } = entry.borderBoxSize[0];\n * // do something\n * }, []),\n * });\n *\n * return <div ref={elementRef}>{...whatever...}</div>\n * }\n * ```\n *\n * @since 2.3.0\n * @since 6.0.0 The API was updated to match the `useIntersectionObserver`\n * implementation -- accepts only a single object parameter and returns a\n * {@link RefCallback} instead of `[nodeRef, refCallback]`\n */\nexport function useResizeObserver<E extends HTMLElement>(\n options: ResizeObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n onUpdate,\n disabled,\n disableHeight = false,\n disableWidth = false,\n } = options;\n\n const [targetNodeRef, refCallback] = useEnsuredRef(ref);\n useEffect(() => {\n const element = targetNodeRef.current;\n if (disabled || (disableHeight && disableWidth) || !element) {\n return;\n }\n\n const unsubscribe = resizeObserverManager.subscribe({\n element,\n onUpdate,\n disableHeight,\n disableWidth,\n });\n\n return () => {\n unsubscribe();\n };\n }, [disableHeight, disableWidth, disabled, onUpdate, targetNodeRef]);\n\n return refCallback;\n}\n"],"names":["useEffect","useEnsuredRef","ResizeObserverManager","
|
|
1
|
+
{"version":3,"sources":["../src/useResizeObserver.ts"],"sourcesContent":["\"use client\";\n\nimport { type Ref, type RefCallback, useEffect } from \"react\";\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useElementSize } from \"./useElementSize.js\";\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n/**\n * @since 6.0.0\n */\nexport type ResizeObserverEntryCallback = (entry: ResizeObserverEntry) => void;\n\n/** @internal */\ntype Unsubscribe = () => void;\n\n/** @internal */\ninterface TargetSize {\n height: number;\n width: number;\n scrollHeight: number;\n scrollWidth: number;\n}\n\n/** @internal */\ninterface TargetSubscription {\n onUpdate: ResizeObserverEntryCallback;\n disableHeight: boolean;\n disableWidth: boolean;\n\n size?: TargetSize;\n}\n\n/** @internal */\ninterface SubscribeOptions {\n element: Element;\n onUpdate: ResizeObserverEntryCallback;\n disableHeight: boolean;\n disableWidth: boolean;\n}\n\n/**\n * @internal\n * @since 6.0.0 This was added to help with testing. The\n * `subscriptions` and `sharedObserver` used to be module-level variables but\n * moving to a class makes it easier to mock. Checkout the\n * `src/tests-utils/ResizeObserver.ts`\n */\nexport class ResizeObserverManager {\n frame: number;\n subscriptions: Map<Element, Set<TargetSubscription>>;\n\n /**\n * Why is there a single shared observer instead of multiple and a\n * \"subscription\" model?\n *\n * Note: Probably a bit of a premature optimization right now...\n *\n * @see https://github.com/WICG/resize-observer/issues/59\n * @internal\n */\n sharedObserver: ResizeObserver | undefined;\n\n constructor() {\n this.frame = 0;\n this.subscriptions = new Map();\n }\n\n subscribe = (options: SubscribeOptions): Unsubscribe => {\n const { element, onUpdate, disableHeight, disableWidth } = options;\n\n // lazy initialize the observer\n const observer =\n this.sharedObserver ||\n new ResizeObserver((entries) => {\n // this prevents the `ResizeObserver loop limit exceeded`\n window.cancelAnimationFrame(this.frame);\n this.frame = window.requestAnimationFrame(() => {\n this.handleResizeEntries(entries);\n });\n });\n this.sharedObserver = observer;\n\n const updates = this.subscriptions.get(element) || new Set();\n const subscription: TargetSubscription = {\n onUpdate,\n disableHeight,\n disableWidth,\n };\n updates.add(subscription);\n if (!this.subscriptions.has(element)) {\n this.subscriptions.set(element, updates);\n }\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n updates.delete(subscription);\n };\n };\n\n handleResizeEntries = (entries: ResizeObserverEntry[]): void => {\n for (const entry of entries) {\n const targetSubscriptions = this.subscriptions.get(entry.target);\n // shouldn't really happen\n /* c8 ignore start */\n if (!targetSubscriptions) {\n continue;\n }\n /* c8 ignore stop */\n\n const entries = targetSubscriptions.values();\n for (const subscription of entries) {\n const { height, width } = entry.contentRect;\n const { scrollHeight, scrollWidth } = entry.target;\n const { onUpdate, size, disableHeight, disableWidth } = subscription;\n const isHeightChange =\n !disableHeight &&\n (!size ||\n size.height !== height ||\n size.scrollHeight !== scrollHeight);\n const isWidthChange =\n !disableWidth &&\n (!size || size.width !== width || size.scrollWidth !== scrollWidth);\n\n subscription.size = {\n height,\n width,\n scrollHeight,\n scrollWidth,\n };\n if (isHeightChange || isWidthChange) {\n onUpdate(entry);\n }\n }\n }\n };\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport const resizeObserverManager = new ResizeObserverManager();\n\n/**\n * @since 2.3.0\n * @since 6.0.0 Renamed from `UseResizeObserverOptions` and added\n * `onUpdate`/`disabled` options.\n */\nexport interface ResizeObserverHookOptions<E extends HTMLElement> {\n /**\n * An optional ref to merge with the ref returned by this hook.\n */\n ref?: Ref<E>;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * ResizeObserver each render.**\n *\n * This function will be called whenever the target element resizes.\n *\n * @see {@link useResizeObserver} for an example.\n */\n onUpdate: ResizeObserverEntryCallback;\n\n /**\n * Set this to `true` to prevent observing the element's size changes. This is\n * equivalent to not attaching the returned ref to any element.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * Set this to `true` if the {@link onUpdate} should not be fired for height\n * changes.\n *\n * @defaultValue `false`\n */\n disableHeight?: boolean;\n\n /**\n * Set this to `true` if the {@link onUpdate} should not be fired for width\n * changes.\n *\n * @defaultValue `false`\n */\n disableWidth?: boolean;\n}\n\n/**\n * The resize observer is used to track the size changes of a specific element.\n * For most cases you can use the {@link useElementSize} instead, but this hook\n * can be used for more complex behavior with the {@link ResizeObserverEntry}.\n *\n * @example Simple Example\n * ```tsx\n * import { useResizeObserver } from \"@react-md/core/useResizeObserver\";\n * import { useCallback, useState, type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const elementRef = useResizeObserver({\n * onUpdate: useCallback((entry) => {\n * const element = entry.target;\n * const { height, width } = entry.contentRect;\n * const { inlineSize, blockSize } = entry.borderBoxSize[0];\n * // do something\n * }, []),\n * });\n *\n * return <div ref={elementRef}>{...whatever...}</div>\n * }\n * ```\n *\n * @since 2.3.0\n * @since 6.0.0 The API was updated to match the `useIntersectionObserver`\n * implementation -- accepts only a single object parameter and returns a\n * {@link RefCallback} instead of `[nodeRef, refCallback]`\n */\nexport function useResizeObserver<E extends HTMLElement>(\n options: ResizeObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n onUpdate,\n disabled,\n disableHeight = false,\n disableWidth = false,\n } = options;\n\n const [targetNodeRef, refCallback] = useEnsuredRef(ref);\n useEffect(() => {\n const element = targetNodeRef.current;\n if (disabled || (disableHeight && disableWidth) || !element) {\n return;\n }\n\n const unsubscribe = resizeObserverManager.subscribe({\n element,\n onUpdate,\n disableHeight,\n disableWidth,\n });\n\n return () => {\n unsubscribe();\n };\n }, [disableHeight, disableWidth, disabled, onUpdate, targetNodeRef]);\n\n return refCallback;\n}\n"],"names":["useEffect","useEnsuredRef","ResizeObserverManager","frame","subscriptions","sharedObserver","subscribe","options","element","onUpdate","disableHeight","disableWidth","observer","ResizeObserver","entries","window","cancelAnimationFrame","requestAnimationFrame","handleResizeEntries","updates","get","Set","subscription","add","has","set","observe","unobserve","delete","entry","targetSubscriptions","target","values","height","width","contentRect","scrollHeight","scrollWidth","size","isHeightChange","isWidthChange","Map","resizeObserverManager","useResizeObserver","ref","disabled","targetNodeRef","refCallback","current","unsubscribe"],"mappings":"AAAA;;;;;;;;;;;;;;AAEA,SAAqCA,SAAS,QAAQ,QAAQ;AAI9D,SAASC,aAAa,QAAQ,qBAAqB;AAmCnD;;;;;;CAMC,GACD,OAAO,MAAMC;IAeX,aAAc;QAddC,uBAAAA,SAAAA,KAAAA;QACAC,uBAAAA,iBAAAA,KAAAA;QAEA;;;;;;;;GAQC,GACDC,uBAAAA,kBAAAA,KAAAA;QAOAC,uBAAAA,aAAY,CAACC;YACX,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,YAAY,EAAE,GAAGJ;YAE3D,+BAA+B;YAC/B,MAAMK,WACJ,IAAI,CAACP,cAAc,IACnB,IAAIQ,eAAe,CAACC;gBAClB,yDAAyD;gBACzDC,OAAOC,oBAAoB,CAAC,IAAI,CAACb,KAAK;gBACtC,IAAI,CAACA,KAAK,GAAGY,OAAOE,qBAAqB,CAAC;oBACxC,IAAI,CAACC,mBAAmB,CAACJ;gBAC3B;YACF;YACF,IAAI,CAACT,cAAc,GAAGO;YAEtB,MAAMO,UAAU,IAAI,CAACf,aAAa,CAACgB,GAAG,CAACZ,YAAY,IAAIa;YACvD,MAAMC,eAAmC;gBACvCb;gBACAC;gBACAC;YACF;YACAQ,QAAQI,GAAG,CAACD;YACZ,IAAI,CAAC,IAAI,CAAClB,aAAa,CAACoB,GAAG,CAAChB,UAAU;gBACpC,IAAI,CAACJ,aAAa,CAACqB,GAAG,CAACjB,SAASW;YAClC;YAEAP,SAASc,OAAO,CAAClB;YAEjB,OAAO;gBACLI,SAASe,SAAS,CAACnB;gBACnBW,QAAQS,MAAM,CAACN;YACjB;QACF;QAEAJ,uBAAAA,uBAAsB,CAACJ;YACrB,KAAK,MAAMe,SAASf,QAAS;gBAC3B,MAAMgB,sBAAsB,IAAI,CAAC1B,aAAa,CAACgB,GAAG,CAACS,MAAME,MAAM;gBAC/D,0BAA0B;gBAC1B,mBAAmB,GACnB,IAAI,CAACD,qBAAqB;oBACxB;gBACF;gBACA,kBAAkB,GAElB,MAAMhB,UAAUgB,oBAAoBE,MAAM;gBAC1C,KAAK,MAAMV,gBAAgBR,QAAS;oBAClC,MAAM,EAAEmB,MAAM,EAAEC,KAAK,EAAE,GAAGL,MAAMM,WAAW;oBAC3C,MAAM,EAAEC,YAAY,EAAEC,WAAW,EAAE,GAAGR,MAAME,MAAM;oBAClD,MAAM,EAAEtB,QAAQ,EAAE6B,IAAI,EAAE5B,aAAa,EAAEC,YAAY,EAAE,GAAGW;oBACxD,MAAMiB,iBACJ,CAAC7B,iBACA,CAAA,CAAC4B,QACAA,KAAKL,MAAM,KAAKA,UAChBK,KAAKF,YAAY,KAAKA,YAAW;oBACrC,MAAMI,gBACJ,CAAC7B,gBACA,CAAA,CAAC2B,QAAQA,KAAKJ,KAAK,KAAKA,SAASI,KAAKD,WAAW,KAAKA,WAAU;oBAEnEf,aAAagB,IAAI,GAAG;wBAClBL;wBACAC;wBACAE;wBACAC;oBACF;oBACA,IAAIE,kBAAkBC,eAAe;wBACnC/B,SAASoB;oBACX;gBACF;YACF;QACF;QAzEE,IAAI,CAAC1B,KAAK,GAAG;QACb,IAAI,CAACC,aAAa,GAAG,IAAIqC;IAC3B;AAwEF;AAEA;;;CAGC,GACD,OAAO,MAAMC,wBAAwB,IAAIxC,wBAAwB;AAgDjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GACD,OAAO,SAASyC,kBACdpC,OAAqC;IAErC,MAAM,EACJqC,GAAG,EACHnC,QAAQ,EACRoC,QAAQ,EACRnC,gBAAgB,KAAK,EACrBC,eAAe,KAAK,EACrB,GAAGJ;IAEJ,MAAM,CAACuC,eAAeC,YAAY,GAAG9C,cAAc2C;IACnD5C,UAAU;QACR,MAAMQ,UAAUsC,cAAcE,OAAO;QACrC,IAAIH,YAAanC,iBAAiBC,gBAAiB,CAACH,SAAS;YAC3D;QACF;QAEA,MAAMyC,cAAcP,sBAAsBpC,SAAS,CAAC;YAClDE;YACAC;YACAC;YACAC;QACF;QAEA,OAAO;YACLsC;QACF;IACF,GAAG;QAACvC;QAAeC;QAAckC;QAAUpC;QAAUqC;KAAc;IAEnE,OAAOC;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/getMiddleOfRange.ts"],"sourcesContent":["import { getRangeSteps } from \"./getRangeSteps.js\";\nimport { nearest } from \"./nearest.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface GetMiddleOfRangeOptions {\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/getMiddleOfRange.ts"],"sourcesContent":["import { type MinMaxRange } from \"../types.js\";\nimport { getRangeSteps } from \"./getRangeSteps.js\";\nimport { nearest } from \"./nearest.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface GetMiddleOfRangeOptions extends MinMaxRange {\n step: number;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function getMiddleOfRange(options: GetMiddleOfRangeOptions): number {\n const { min, max, step } = options;\n\n return nearest({\n min,\n max,\n steps: getRangeSteps({ min, max, step }),\n value: (max - min) / 2 + min,\n });\n}\n"],"names":["getRangeSteps","nearest","getMiddleOfRange","options","min","max","step","steps","value"],"mappings":"AACA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,OAAO,QAAQ,eAAe;AASvC;;;CAGC,GACD,OAAO,SAASC,iBAAiBC,OAAgC;IAC/D,MAAM,EAAEC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE,GAAGH;IAE3B,OAAOF,QAAQ;QACbG;QACAC;QACAE,OAAOP,cAAc;YAAEI;YAAKC;YAAKC;QAAK;QACtCE,OAAO,AAACH,CAAAA,MAAMD,GAAE,IAAK,IAAIA;IAC3B;AACF"}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
+
import { type MinMaxRange } from "../types.js";
|
|
1
2
|
/** @since 4.0.1 */
|
|
2
|
-
export interface GetPercentageOptions {
|
|
3
|
-
/**
|
|
4
|
-
* The min value allowed.
|
|
5
|
-
*/
|
|
6
|
-
min: number;
|
|
7
|
-
/**
|
|
8
|
-
* The max value allowed.
|
|
9
|
-
*/
|
|
10
|
-
max: number;
|
|
3
|
+
export interface GetPercentageOptions extends MinMaxRange {
|
|
11
4
|
/**
|
|
12
5
|
* The current value
|
|
13
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/getPercentage.ts"],"sourcesContent":["/** @since 4.0.1 */\nexport interface GetPercentageOptions
|
|
1
|
+
{"version":3,"sources":["../../src/utils/getPercentage.ts"],"sourcesContent":["import { type MinMaxRange } from \"../types.js\";\n\n/** @since 4.0.1 */\nexport interface GetPercentageOptions extends MinMaxRange {\n /**\n * The current value\n */\n value: number;\n\n /**\n * Boolean if the min, max, and value options should be validated to make sure\n * they are within the correct range relative to each other.\n *\n * @defaultValue `false`\n */\n validate?: boolean;\n}\n\n/**\n * Gets the current percentage based on the min, max, and current value.\n *\n * @returns the percentage that the `value` is between the `min` and `max`\n * values.\n *\n * @since 4.0.1 uses an object for options instead of multiple arguments.\n * @since 6.0.0 Updated to be included in the public API and `validate`\n * defaults to `false` instead of `true`.\n */\nexport function getPercentage(options: GetPercentageOptions): number {\n const { min, max, value, validate = false } = options;\n if (validate) {\n if (min >= max) {\n throw new RangeError(\n \"A range must have the min value less than the max value\"\n );\n }\n\n if (value > max || value < min) {\n throw new RangeError(\"A value must be between the min and max values\");\n }\n }\n\n const range = max - min;\n const start = value - min;\n const percentage = start / range;\n return Math.max(0, Math.min(Math.abs(percentage), 1));\n}\n"],"names":["getPercentage","options","min","max","value","validate","RangeError","range","start","percentage","Math","abs"],"mappings":"AAkBA;;;;;;;;;CASC,GACD,OAAO,SAASA,cAAcC,OAA6B;IACzD,MAAM,EAAEC,GAAG,EAAEC,GAAG,EAAEC,KAAK,EAAEC,WAAW,KAAK,EAAE,GAAGJ;IAC9C,IAAII,UAAU;QACZ,IAAIH,OAAOC,KAAK;YACd,MAAM,IAAIG,WACR;QAEJ;QAEA,IAAIF,QAAQD,OAAOC,QAAQF,KAAK;YAC9B,MAAM,IAAII,WAAW;QACvB;IACF;IAEA,MAAMC,QAAQJ,MAAMD;IACpB,MAAMM,QAAQJ,QAAQF;IACtB,MAAMO,aAAaD,QAAQD;IAC3B,OAAOG,KAAKP,GAAG,CAAC,GAAGO,KAAKR,GAAG,CAACQ,KAAKC,GAAG,CAACF,aAAa;AACpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/getRangeSteps.ts"],"sourcesContent":["/**\n * @internal\n * @since 6.0.0\n */\nexport interface RangeStepsOptions {\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/getRangeSteps.ts"],"sourcesContent":["import { type MinMaxRange } from \"../types.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface RangeStepsOptions extends MinMaxRange {\n step: number;\n}\n\n/**\n * Gets the number of steps in the allowed range of values.\n *\n * @internal\n * @since 2.5.0\n * @since 6.0.0 Converted to using an object instead of multiple arguments and\n * renamed from `getSteps` to `getRangeSteps`.\n */\nexport function getRangeSteps(options: RangeStepsOptions): number {\n const { min, max, step } = options;\n\n return Math.abs(max - min) / step;\n}\n"],"names":["getRangeSteps","options","min","max","step","Math","abs"],"mappings":"AAUA;;;;;;;CAOC,GACD,OAAO,SAASA,cAAcC,OAA0B;IACtD,MAAM,EAAEC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE,GAAGH;IAE3B,OAAOI,KAAKC,GAAG,CAACH,MAAMD,OAAOE;AAC/B"}
|
package/dist/utils/nearest.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { type MinMaxRange } from "../types.js";
|
|
1
2
|
/**
|
|
2
3
|
* @internal
|
|
3
4
|
* @since 6.0.0
|
|
4
5
|
*/
|
|
5
|
-
export interface NearestOptions {
|
|
6
|
-
min: number;
|
|
7
|
-
max: number;
|
|
6
|
+
export interface NearestOptions extends MinMaxRange {
|
|
8
7
|
steps: number;
|
|
9
8
|
value: number;
|
|
10
9
|
/** @defaultValue `max - min` */
|
package/dist/utils/nearest.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/nearest.ts"],"sourcesContent":["/**\n * @internal\n * @since 6.0.0\n */\nexport interface NearestOptions {\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/nearest.ts"],"sourcesContent":["import { type MinMaxRange } from \"../types.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface NearestOptions extends MinMaxRange {\n steps: number;\n value: number;\n\n /** @defaultValue `max - min` */\n range?: number;\n}\n\n/**\n * Rounds a number to the nearest step within a min/max range.\n *\n * @see https://stackoverflow.com/a/13635455\n * @returns the value rounded to the nearest step in the min/max range\n * @since 2.5.0 Added the `range` param\n * @since 6.0.0 Converted to using an object instead of multiple arguments.\n */\nexport function nearest(options: NearestOptions): number {\n const { min, max, steps, value, range = max - min } = options;\n if (min === max) {\n return max;\n }\n\n const rounded = Math.round(((value - min) * steps) / range) / steps;\n const zeroToOne = Math.min(Math.max(rounded, 0), 1);\n\n // have to calculate the number of allowed decimal places since decimal\n // precision gets weird:\n // 0.28 * 100 === 28.000000000000004\n const step = range / steps;\n const decimals = Number.isInteger(step)\n ? range % steps\n : `${step}`.split(\".\")[1].length;\n\n return Math.min(\n max,\n Math.max(min, parseFloat((zeroToOne * range + min).toFixed(decimals)))\n );\n}\n"],"names":["nearest","options","min","max","steps","value","range","rounded","Math","round","zeroToOne","step","decimals","Number","isInteger","split","length","parseFloat","toFixed"],"mappings":"AAcA;;;;;;;CAOC,GACD,OAAO,SAASA,QAAQC,OAAuB;IAC7C,MAAM,EAAEC,GAAG,EAAEC,GAAG,EAAEC,KAAK,EAAEC,KAAK,EAAEC,QAAQH,MAAMD,GAAG,EAAE,GAAGD;IACtD,IAAIC,QAAQC,KAAK;QACf,OAAOA;IACT;IAEA,MAAMI,UAAUC,KAAKC,KAAK,CAAC,AAAEJ,CAAAA,QAAQH,GAAE,IAAKE,QAASE,SAASF;IAC9D,MAAMM,YAAYF,KAAKN,GAAG,CAACM,KAAKL,GAAG,CAACI,SAAS,IAAI;IAEjD,uEAAuE;IACvE,wBAAwB;IACxB,oCAAoC;IACpC,MAAMI,OAAOL,QAAQF;IACrB,MAAMQ,WAAWC,OAAOC,SAAS,CAACH,QAC9BL,QAAQF,QACR,GAAGO,MAAM,CAACI,KAAK,CAAC,IAAI,CAAC,EAAE,CAACC,MAAM;IAElC,OAAOR,KAAKN,GAAG,CACbC,KACAK,KAAKL,GAAG,CAACD,KAAKe,WAAW,AAACP,CAAAA,YAAYJ,QAAQJ,GAAE,EAAGgB,OAAO,CAACN;AAE/D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Point } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* @since 6.3.0
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare const radiansToDegrees: (radians: number) => number;
|
|
7
|
+
/**
|
|
8
|
+
* @since 6.3.0
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const degreesToRadians: (degrees: number) => number;
|
|
12
|
+
/**
|
|
13
|
+
* @since 6.3.0
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
interface IsPointInCircleOptions {
|
|
17
|
+
point: Point;
|
|
18
|
+
center: Point;
|
|
19
|
+
radius: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @since 6.3.0
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export declare function isPointInCircle(options: IsPointInCircleOptions): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
* @since 6.3.0
|
|
29
|
+
*/
|
|
30
|
+
export declare function calcHypotenuse(point: Point): number;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 6.3.0
|
|
3
|
+
* @internal
|
|
4
|
+
*/ export const radiansToDegrees = (radians)=>radians * 180 / Math.PI;
|
|
5
|
+
/**
|
|
6
|
+
* @since 6.3.0
|
|
7
|
+
* @internal
|
|
8
|
+
*/ export const degreesToRadians = (degrees)=>degrees * Math.PI / 180;
|
|
9
|
+
/**
|
|
10
|
+
* @since 6.3.0
|
|
11
|
+
* @internal
|
|
12
|
+
*/ export function isPointInCircle(options) {
|
|
13
|
+
const { point, center, radius } = options;
|
|
14
|
+
const distance = (center.x - point.x) ** 2 + (center.y - point.y) ** 2;
|
|
15
|
+
return distance <= radius ** 2;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
* @since 6.3.0
|
|
20
|
+
*/ export function calcHypotenuse(point) {
|
|
21
|
+
const { x, y } = point;
|
|
22
|
+
return Math.sqrt(x * x + y * y);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=trigonometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/trigonometry.ts"],"sourcesContent":["import { type Point } from \"../types.js\";\n\n/**\n * @since 6.3.0\n * @internal\n */\nexport const radiansToDegrees = (radians: number): number =>\n (radians * 180) / Math.PI;\n\n/**\n * @since 6.3.0\n * @internal\n */\nexport const degreesToRadians = (degrees: number): number =>\n (degrees * Math.PI) / 180;\n\n/**\n * @since 6.3.0\n * @internal\n */\ninterface IsPointInCircleOptions {\n point: Point;\n center: Point;\n radius: number;\n}\n\n/**\n * @since 6.3.0\n * @internal\n */\nexport function isPointInCircle(options: IsPointInCircleOptions): boolean {\n const { point, center, radius } = options;\n\n const distance = (center.x - point.x) ** 2 + (center.y - point.y) ** 2;\n return distance <= radius ** 2;\n}\n\n/**\n * @internal\n * @since 6.3.0\n */\nexport function calcHypotenuse(point: Point): number {\n const { x, y } = point;\n\n return Math.sqrt(x * x + y * y);\n}\n"],"names":["radiansToDegrees","radians","Math","PI","degreesToRadians","degrees","isPointInCircle","options","point","center","radius","distance","x","y","calcHypotenuse","sqrt"],"mappings":"AAEA;;;CAGC,GACD,OAAO,MAAMA,mBAAmB,CAACC,UAC/B,AAACA,UAAU,MAAOC,KAAKC,EAAE,CAAC;AAE5B;;;CAGC,GACD,OAAO,MAAMC,mBAAmB,CAACC,UAC/B,AAACA,UAAUH,KAAKC,EAAE,GAAI,IAAI;AAY5B;;;CAGC,GACD,OAAO,SAASG,gBAAgBC,OAA+B;IAC7D,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGH;IAElC,MAAMI,WAAW,AAACF,CAAAA,OAAOG,CAAC,GAAGJ,MAAMI,CAAC,AAADA,KAAM,IAAI,AAACH,CAAAA,OAAOI,CAAC,GAAGL,MAAMK,CAAC,AAADA,KAAM;IACrE,OAAOF,YAAYD,UAAU;AAC/B;AAEA;;;CAGC,GACD,OAAO,SAASI,eAAeN,KAAY;IACzC,MAAM,EAAEI,CAAC,EAAEC,CAAC,EAAE,GAAGL;IAEjB,OAAON,KAAKa,IAAI,CAACH,IAAIA,IAAIC,IAAIA;AAC/B"}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import { type ButtonHTMLAttributes } from "react";
|
|
2
2
|
import { type LabelRequiredForA11y } from "../types.js";
|
|
3
|
-
|
|
4
|
-
interface CSSProperties {
|
|
5
|
-
"--rmd-window-splitter-top"?: number | string;
|
|
6
|
-
"--rmd-window-splitter-right"?: number | string;
|
|
7
|
-
"--rmd-window-splitter-bottom"?: number | string;
|
|
8
|
-
"--rmd-window-splitter-left"?: number | string;
|
|
9
|
-
"--rmd-window-splitter-opacity"?: number | string;
|
|
10
|
-
"--rmd-window-splitter-position"?: number | string;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
3
|
+
import { type BaseWindowSplitterClassNameOptions } from "./styles.js";
|
|
13
4
|
/**
|
|
14
|
-
* @since 6.0.0
|
|
15
5
|
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/}
|
|
6
|
+
* @since 6.0.0
|
|
7
|
+
* @since 6.3.1 Extends BaseWindowSplitterClassNameOptions for CSSProperties
|
|
8
|
+
* module augmentation.
|
|
16
9
|
*/
|
|
17
|
-
export interface BaseWindowSplitterProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "children"
|
|
10
|
+
export interface BaseWindowSplitterProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "children">, BaseWindowSplitterClassNameOptions {
|
|
18
11
|
/**
|
|
19
12
|
* This will be provided by the {@link useWindowSplitter} hook.
|
|
20
13
|
*/
|
|
@@ -27,13 +20,6 @@ export interface BaseWindowSplitterProps extends Omit<ButtonHTMLAttributes<HTMLB
|
|
|
27
20
|
* This will be provided by the {@link useWindowSplitter} hook.
|
|
28
21
|
*/
|
|
29
22
|
reversed: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Set this to `true` if the window splitter should use `position: absolute`
|
|
32
|
-
* instead of `position: fixed`.
|
|
33
|
-
*
|
|
34
|
-
* @defaultValue `false`
|
|
35
|
-
*/
|
|
36
|
-
disableFixed?: boolean;
|
|
37
23
|
}
|
|
38
24
|
/**
|
|
39
25
|
* @since 6.0.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/window-splitter/WindowSplitter.tsx"],"sourcesContent":["import { type ButtonHTMLAttributes, forwardRef } from \"react\";\n\nimport { type LabelRequiredForA11y } from \"../types.js\";\nimport { windowSplitter
|
|
1
|
+
{"version":3,"sources":["../../src/window-splitter/WindowSplitter.tsx"],"sourcesContent":["import { type ButtonHTMLAttributes, forwardRef } from \"react\";\n\nimport { type LabelRequiredForA11y } from \"../types.js\";\nimport {\n type BaseWindowSplitterClassNameOptions,\n windowSplitter,\n} from \"./styles.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useWindowSplitter } from \"./useWindowSplitter.js\";\n\n/**\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/}\n * @since 6.0.0\n * @since 6.3.1 Extends BaseWindowSplitterClassNameOptions for CSSProperties\n * module augmentation.\n */\nexport interface BaseWindowSplitterProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"type\" | \"children\">,\n BaseWindowSplitterClassNameOptions {\n /**\n * This will be provided by the {@link useWindowSplitter} hook.\n */\n \"aria-controls\": string;\n\n /**\n * This will be provided by the {@link useWindowSplitter} hook.\n */\n dragging: boolean;\n\n /**\n * This will be provided by the {@link useWindowSplitter} hook.\n */\n reversed: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport type WindowSplitterProps = LabelRequiredForA11y<BaseWindowSplitterProps>;\n\n/**\n * The `WindowSplitter` should be used with the `useWindowSplitter` hook to\n * resize parts of a layout.\n *\n * See the `useResizableLayout` hook if the entire page layout should be\n * resizable.\n *\n * @example Simple Example\n * ```tsx\n * \"use client\";\n * import { WindowSplitter } from \"@react-md/core/window-splitter/WindowSplitter\";\n * import { useWindowSplitter } from \"@react-md/core/window-splitter/useWindowSplitter\";\n * import { useId, type ReactElement } from \"react\";\n *\n * export function Example(): ReactElement {\n * const panelId = useId();\n * const { value, splitterProps } = useWindowSplitter({\n * min: 120,\n * max: 380,\n * });\n *\n * return (\n * <div\n * style={{\n * \"--rmd-window-splitter-position\": `${value}px`,\n * display: \"grid\",\n * gridTemplateColumns: \"var(--rmd-window-splitter-position, 120px) 1fr\",\n * }}\n * >\n * <div>Panel 1</div>\n * <WindowSplitter\n * {...splitterProps}\n * aria-controls={panelId}\n * aria-labelledby={panelId}\n * />\n * <div>Panel 2</div>\n * </div>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/window-splitter | WindowSplitter Demos}\n * @since 6.0.0\n */\nexport const WindowSplitter = forwardRef<\n HTMLButtonElement,\n WindowSplitterProps\n>(function WindowSplitter(props, ref) {\n const {\n role = \"separator\",\n className,\n dragging,\n reversed,\n disableFixed = false,\n ...remaining\n } = props;\n const vertical = props[\"aria-orientation\"] === \"vertical\";\n\n return (\n <button\n {...remaining}\n ref={ref}\n type=\"button\"\n role={role}\n className={windowSplitter({\n className,\n reversed,\n dragging,\n vertical,\n disableFixed,\n })}\n />\n );\n});\n"],"names":["forwardRef","windowSplitter","WindowSplitter","props","ref","role","className","dragging","reversed","disableFixed","remaining","vertical","button","type"],"mappings":";AAAA,SAAoCA,UAAU,QAAQ,QAAQ;AAG9D,SAEEC,cAAc,QACT,cAAc;AAkCrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GACD,OAAO,MAAMC,+BAAiBF,WAG5B,SAASE,eAAeC,KAAK,EAAEC,GAAG;IAClC,MAAM,EACJC,OAAO,WAAW,EAClBC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,eAAe,KAAK,EACpB,GAAGC,WACJ,GAAGP;IACJ,MAAMQ,WAAWR,KAAK,CAAC,mBAAmB,KAAK;IAE/C,qBACE,KAACS;QACE,GAAGF,SAAS;QACbN,KAAKA;QACLS,MAAK;QACLR,MAAMA;QACNC,WAAWL,eAAe;YACxBK;YACAE;YACAD;YACAI;YACAF;QACF;;AAGN,GAAG"}
|
|
@@ -1,12 +1,36 @@
|
|
|
1
|
+
declare module "react" {
|
|
2
|
+
interface CSSProperties {
|
|
3
|
+
"--rmd-window-splitter-size"?: string | number;
|
|
4
|
+
"--rmd-window-splitter-background-size"?: string | number;
|
|
5
|
+
"--rmd-window-splitter-x"?: string | number;
|
|
6
|
+
"--rmd-window-splitter-y"?: string | number;
|
|
7
|
+
"--rmd-window-splitter-z"?: string | number;
|
|
8
|
+
"--rmd-window-splitter-position"?: string | number;
|
|
9
|
+
"--rmd-window-splitter-backgrond-color"?: string;
|
|
10
|
+
"--rmd-window-splitter-opacity"?: string | number;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
1
13
|
/**
|
|
2
|
-
* @since 6.
|
|
14
|
+
* @since 6.3.1
|
|
3
15
|
*/
|
|
4
|
-
export interface
|
|
16
|
+
export interface BaseWindowSplitterClassNameOptions {
|
|
5
17
|
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Set this to `true` if the window splitter should use `position: absolute`
|
|
20
|
+
* instead of `position: fixed`.
|
|
21
|
+
*
|
|
22
|
+
* @defaultValue `false`
|
|
23
|
+
*/
|
|
24
|
+
disableFixed?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @since 6.0.0
|
|
28
|
+
* @since 6.3.1 Extends BaseWindowSplitterClassNameOptions
|
|
29
|
+
*/
|
|
30
|
+
export interface WindowSplitterClassNameOptions extends BaseWindowSplitterClassNameOptions {
|
|
6
31
|
dragging?: boolean;
|
|
7
32
|
reversed?: boolean;
|
|
8
33
|
vertical?: boolean;
|
|
9
|
-
disableFixed?: boolean;
|
|
10
34
|
}
|
|
11
35
|
/**
|
|
12
36
|
* @since 6.0.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/window-splitter/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-window-splitter\");\n\n/**\n * @since 6.
|
|
1
|
+
{"version":3,"sources":["../../src/window-splitter/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-window-splitter\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-window-splitter-size\"?: string | number;\n \"--rmd-window-splitter-background-size\"?: string | number;\n \"--rmd-window-splitter-x\"?: string | number;\n \"--rmd-window-splitter-y\"?: string | number;\n \"--rmd-window-splitter-z\"?: string | number;\n \"--rmd-window-splitter-position\"?: string | number;\n \"--rmd-window-splitter-backgrond-color\"?: string;\n \"--rmd-window-splitter-opacity\"?: string | number;\n }\n}\n\n/**\n * @since 6.3.1\n */\nexport interface BaseWindowSplitterClassNameOptions {\n className?: string;\n\n /**\n * Set this to `true` if the window splitter should use `position: absolute`\n * instead of `position: fixed`.\n *\n * @defaultValue `false`\n */\n disableFixed?: boolean;\n}\n\n/**\n * @since 6.0.0\n * @since 6.3.1 Extends BaseWindowSplitterClassNameOptions\n */\nexport interface WindowSplitterClassNameOptions\n extends BaseWindowSplitterClassNameOptions {\n dragging?: boolean;\n reversed?: boolean;\n vertical?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function windowSplitter(\n options: WindowSplitterClassNameOptions = {}\n): string {\n const {\n vertical = false,\n dragging,\n reversed,\n disableFixed,\n className,\n } = options;\n\n return cnb(\n styles({\n h: !vertical,\n hr: !vertical && reversed,\n v: vertical,\n vr: vertical && reversed,\n a: disableFixed,\n dragging,\n }),\n className\n );\n}\n"],"names":["cnb","bem","styles","windowSplitter","options","vertical","dragging","reversed","disableFixed","className","h","hr","v","vr","a"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAyCnB;;CAEC,GACD,OAAO,SAASE,eACdC,UAA0C,CAAC,CAAC;IAE5C,MAAM,EACJC,WAAW,KAAK,EAChBC,QAAQ,EACRC,QAAQ,EACRC,YAAY,EACZC,SAAS,EACV,GAAGL;IAEJ,OAAOJ,IACLE,OAAO;QACLQ,GAAG,CAACL;QACJM,IAAI,CAACN,YAAYE;QACjBK,GAAGP;QACHQ,IAAIR,YAAYE;QAChBO,GAAGN;QACHF;IACF,IACAG;AAEJ"}
|
|
@@ -23,7 +23,7 @@ export type WindowSplitterOptions<E extends HTMLElement = HTMLButtonElement> = B
|
|
|
23
23
|
/**
|
|
24
24
|
* @since 6.0.0
|
|
25
25
|
*/
|
|
26
|
-
export interface WindowSplitterWidgetProps<E extends HTMLElement> extends Required<DraggableMouseEventHandlers<E>>, Required<DraggableKeyboardEventHandlers<E>> {
|
|
26
|
+
export interface WindowSplitterWidgetProps<E extends HTMLElement = HTMLButtonElement> extends Required<DraggableMouseEventHandlers<E>>, Required<DraggableKeyboardEventHandlers<E>> {
|
|
27
27
|
"aria-orientation": "vertical" | undefined;
|
|
28
28
|
"aria-valuenow": number;
|
|
29
29
|
"aria-valuemin": number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/window-splitter/useWindowSplitter.ts"],"sourcesContent":["\"use client\";\n\nimport { type Ref, type RefCallback } from \"react\";\n\nimport {\n type BaseDraggableOptions,\n type DraggableImplementation,\n type DraggableKeyboardEventHandlers,\n type DraggableMouseEventHandlers,\n type DraggableStateOptions,\n type DraggableTouchEventHandlers,\n useDraggable,\n} from \"../draggable/useDraggable.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface BaseWindowSplitterOptions<\n E extends HTMLElement = HTMLButtonElement,\n> extends Omit<BaseDraggableOptions<E>, keyof DraggableTouchEventHandlers<E>> {\n /**\n * An optional id to use for the window splitter.\n *\n * @defaultValue `\"window-splitter-\" + useId()`\n */\n id?: string;\n\n /**\n * An optional ref for the window splitter element. This will be merged into\n * the {@link WindowSplitterWidgetProps.ref}.\n */\n ref?: Ref<E>;\n}\n\n/**\n * @since 6.0.0\n */\nexport type WindowSplitterOptions<E extends HTMLElement = HTMLButtonElement> =\n BaseWindowSplitterOptions<E> & DraggableStateOptions;\n\n/**\n * @since 6.0.0\n */\nexport interface WindowSplitterWidgetProps
|
|
1
|
+
{"version":3,"sources":["../../src/window-splitter/useWindowSplitter.ts"],"sourcesContent":["\"use client\";\n\nimport { type Ref, type RefCallback } from \"react\";\n\nimport {\n type BaseDraggableOptions,\n type DraggableImplementation,\n type DraggableKeyboardEventHandlers,\n type DraggableMouseEventHandlers,\n type DraggableStateOptions,\n type DraggableTouchEventHandlers,\n useDraggable,\n} from \"../draggable/useDraggable.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface BaseWindowSplitterOptions<\n E extends HTMLElement = HTMLButtonElement,\n> extends Omit<BaseDraggableOptions<E>, keyof DraggableTouchEventHandlers<E>> {\n /**\n * An optional id to use for the window splitter.\n *\n * @defaultValue `\"window-splitter-\" + useId()`\n */\n id?: string;\n\n /**\n * An optional ref for the window splitter element. This will be merged into\n * the {@link WindowSplitterWidgetProps.ref}.\n */\n ref?: Ref<E>;\n}\n\n/**\n * @since 6.0.0\n */\nexport type WindowSplitterOptions<E extends HTMLElement = HTMLButtonElement> =\n BaseWindowSplitterOptions<E> & DraggableStateOptions;\n\n/**\n * @since 6.0.0\n */\nexport interface WindowSplitterWidgetProps<\n E extends HTMLElement = HTMLButtonElement,\n> extends Required<DraggableMouseEventHandlers<E>>,\n Required<DraggableKeyboardEventHandlers<E>> {\n \"aria-orientation\": \"vertical\" | undefined;\n \"aria-valuenow\": number;\n \"aria-valuemin\": number;\n \"aria-valuemax\": number;\n id: string;\n ref: RefCallback<E>;\n role: \"separator\";\n reversed: boolean;\n dragging: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface WindowSplitterImplementation<\n E extends HTMLElement = HTMLButtonElement,\n> extends DraggableImplementation<E> {\n splitterProps: WindowSplitterWidgetProps<E>;\n}\n\n/**\n * Used to control the state for the `WindowSplitter` component.\n *\n * @example Custom Implementation\n * ```tsx\n * import {\n * useWindowSplitter,\n * type WindowSplitterImplementation\n * } from \"@react-md/core/window-splitter/useWindowSplitter\";\n * import { useState } from \"react\";\n *\n * // this is pretty much the `useWindowSplitter` implementation\n * export function useMyCustomWindowSplitter(): WindowSplitterImplementation {\n * const [dragging, setDragging] = useState(false);\n * const [value, setValue] = useState(0);\n * const splitter = useWindowSplitter({\n * min: 0,\n * max: 100,\n * value,\n * setValue,\n * dragging,\n * setDragging,\n * });\n *\n * return {\n * ...splitter,\n * value,\n * setValue,\n * dragging,\n * }\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useWindowSplitter<E extends HTMLElement = HTMLButtonElement>(\n options: WindowSplitterOptions<E>\n): WindowSplitterImplementation<E> {\n const { id: propId, reversed = false, vertical } = options;\n\n const id = useEnsuredId(propId, \"splitter\");\n const draggableImplementation = useDraggable(options);\n const {\n dragging,\n percentage,\n draggableRef,\n mouseEventHandlers,\n keyboardEventHandlers,\n } = draggableImplementation;\n\n return {\n ...draggableImplementation,\n splitterProps: {\n \"aria-orientation\": vertical ? \"vertical\" : undefined,\n \"aria-valuenow\": Math.ceil(percentage * 100),\n \"aria-valuemin\": 0,\n \"aria-valuemax\": 100,\n id,\n ref: draggableRef,\n role: \"separator\",\n dragging,\n reversed,\n ...mouseEventHandlers,\n ...keyboardEventHandlers,\n },\n };\n}\n"],"names":["useDraggable","useEnsuredId","useWindowSplitter","options","id","propId","reversed","vertical","draggableImplementation","dragging","percentage","draggableRef","mouseEventHandlers","keyboardEventHandlers","splitterProps","undefined","Math","ceil","ref","role"],"mappings":"AAAA;AAIA,SAOEA,YAAY,QACP,+BAA+B;AACtC,SAASC,YAAY,QAAQ,qBAAqB;AAuDlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCC,GACD,OAAO,SAASC,kBACdC,OAAiC;IAEjC,MAAM,EAAEC,IAAIC,MAAM,EAAEC,WAAW,KAAK,EAAEC,QAAQ,EAAE,GAAGJ;IAEnD,MAAMC,KAAKH,aAAaI,QAAQ;IAChC,MAAMG,0BAA0BR,aAAaG;IAC7C,MAAM,EACJM,QAAQ,EACRC,UAAU,EACVC,YAAY,EACZC,kBAAkB,EAClBC,qBAAqB,EACtB,GAAGL;IAEJ,OAAO;QACL,GAAGA,uBAAuB;QAC1BM,eAAe;YACb,oBAAoBP,WAAW,aAAaQ;YAC5C,iBAAiBC,KAAKC,IAAI,CAACP,aAAa;YACxC,iBAAiB;YACjB,iBAAiB;YACjBN;YACAc,KAAKP;YACLQ,MAAM;YACNV;YACAH;YACA,GAAGM,kBAAkB;YACrB,GAAGC,qBAAqB;QAC1B;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-md/core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.1",
|
|
4
4
|
"description": "The core components and functionality for react-md.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sass": "./dist/_core.scss",
|
|
@@ -84,19 +84,19 @@
|
|
|
84
84
|
"@microsoft/api-extractor": "^7.52.8",
|
|
85
85
|
"@mlaursen/eslint-config": "^8.0.1",
|
|
86
86
|
"@swc/cli": "^0.6.0",
|
|
87
|
-
"@swc/core": "^1.11
|
|
88
|
-
"@swc/jest": "^0.2.
|
|
87
|
+
"@swc/core": "^1.12.11",
|
|
88
|
+
"@swc/jest": "^0.2.39",
|
|
89
89
|
"@testing-library/dom": "^10.4.0",
|
|
90
90
|
"@testing-library/jest-dom": "^6.6.3",
|
|
91
91
|
"@testing-library/react": "^16.3.0",
|
|
92
92
|
"@testing-library/user-event": "^14.6.1",
|
|
93
93
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
|
94
|
-
"@types/lodash": "^4.17.
|
|
94
|
+
"@types/lodash": "^4.17.20",
|
|
95
95
|
"@types/node": "^22.15.29",
|
|
96
96
|
"@types/react": "^18.3.12",
|
|
97
97
|
"@types/react-dom": "^18.3.1",
|
|
98
98
|
"chokidar": "^4.0.3",
|
|
99
|
-
"eslint": "^9.
|
|
99
|
+
"eslint": "^9.30.1",
|
|
100
100
|
"filesize": "^10.1.6",
|
|
101
101
|
"glob": "11.0.3",
|
|
102
102
|
"jest": "^29.7.0",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"lodash": "^4.17.21",
|
|
106
106
|
"lz-string": "^1.5.0",
|
|
107
107
|
"npm-run-all": "^4.1.5",
|
|
108
|
-
"prettier": "^3.
|
|
109
|
-
"stylelint": "^16.
|
|
108
|
+
"prettier": "^3.6.2",
|
|
109
|
+
"stylelint": "^16.21.1",
|
|
110
110
|
"stylelint-config-prettier-scss": "^1.0.0",
|
|
111
111
|
"stylelint-config-recommended-scss": "^15.0.1",
|
|
112
112
|
"stylelint-order": "^7.0.0",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"ts-node": "^10.9.2",
|
|
116
116
|
"tsx": "^4.20.3",
|
|
117
117
|
"typescript": "^5.8.3",
|
|
118
|
-
"vitest": "^3.2.
|
|
118
|
+
"vitest": "^3.2.4"
|
|
119
119
|
},
|
|
120
120
|
"peerDependencies": {
|
|
121
121
|
"@jest/globals": "^29.7.0",
|
package/src/app-bar/styles.ts
CHANGED
|
@@ -8,8 +8,6 @@ import { bem } from "../utils/bem.js";
|
|
|
8
8
|
declare module "react" {
|
|
9
9
|
interface CSSProperties {
|
|
10
10
|
"--rmd-app-bar-height"?: string | number;
|
|
11
|
-
"--rmd-app-bar-background-color"?: string;
|
|
12
|
-
"--rmd-app-bar-color"?: string;
|
|
13
11
|
"--rmd-app-bar-surface-background-color"?: string;
|
|
14
12
|
"--rmd-app-bar-surface-color"?: string;
|
|
15
13
|
}
|
|
@@ -37,6 +37,23 @@ import {
|
|
|
37
37
|
type UseStateInitializer,
|
|
38
38
|
} from "../types.js";
|
|
39
39
|
|
|
40
|
+
// NOTE: The augmentation appears in this file since both
|
|
41
|
+
// the `Autocomplete` and `autocompleteStyles` import this
|
|
42
|
+
// file. The augmentation only works if a type definition
|
|
43
|
+
// exists in the compiled `*.d.ts`
|
|
44
|
+
declare module "react" {
|
|
45
|
+
interface CSSProperties {
|
|
46
|
+
"--rmd-autocomplete-clear-button-size"?: string;
|
|
47
|
+
"--rmd-autocomplete-dropdown-button-size"?: string;
|
|
48
|
+
"--rmd-autocomplete-circular-progress-size"?: string;
|
|
49
|
+
"--rmd-autocomplete-inline-gap"?: string;
|
|
50
|
+
"--rmd-autocomplete-inline-min-width"?: string;
|
|
51
|
+
"--rmd-autocomplete-addon-gap"?: string;
|
|
52
|
+
"--rmd-autocomplete-gap-count"?: string;
|
|
53
|
+
"--rmd-autocomplete-addon-spacing"?: string;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
40
57
|
/**
|
|
41
58
|
* If a autocomplete value is one of these types, no additional code is required
|
|
42
59
|
* to display a label in the input/chip for the autocomplete once the value has
|
package/src/avatar/Avatar.tsx
CHANGED
|
@@ -8,17 +8,6 @@ import {
|
|
|
8
8
|
import { type PropsWithRef } from "../types.js";
|
|
9
9
|
import { type AvatarClassNameOptions, avatar, avatarImage } from "./styles.js";
|
|
10
10
|
|
|
11
|
-
declare module "react" {
|
|
12
|
-
interface CSSProperties {
|
|
13
|
-
"--rmd-avatar-background-color"?: string;
|
|
14
|
-
"--rmd-avatar-color"?: string;
|
|
15
|
-
"--rmd-avatar-border-color"?: string;
|
|
16
|
-
"--rmd-avatar-border-radius"?: string | number;
|
|
17
|
-
"--rmd-avatar-size"?: string | number;
|
|
18
|
-
"--rmd-avatar-font-size"?: string | number;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
11
|
export type AvatarImgAttributes = ImgHTMLAttributes<HTMLImageElement>;
|
|
23
12
|
|
|
24
13
|
/**
|
package/src/avatar/styles.ts
CHANGED
|
@@ -4,6 +4,17 @@ import { type ThemeColor, cssUtils } from "../cssUtils.js";
|
|
|
4
4
|
import { type OverridableStringUnion } from "../types.js";
|
|
5
5
|
import { bem } from "../utils/bem.js";
|
|
6
6
|
|
|
7
|
+
declare module "react" {
|
|
8
|
+
interface CSSProperties {
|
|
9
|
+
"--rmd-avatar-background-color"?: string;
|
|
10
|
+
"--rmd-avatar-color"?: string;
|
|
11
|
+
"--rmd-avatar-border-color"?: string;
|
|
12
|
+
"--rmd-avatar-border-radius"?: string | number;
|
|
13
|
+
"--rmd-avatar-size"?: string | number;
|
|
14
|
+
"--rmd-avatar-font-size"?: string | number;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
const styles = bem("rmd-avatar");
|
|
8
19
|
|
|
9
20
|
/**
|
package/src/badge/Badge.tsx
CHANGED
|
@@ -2,6 +2,18 @@ import { type HTMLAttributes, type ReactNode, forwardRef } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { type BadgeTheme, badge } from "./styles.js";
|
|
4
4
|
|
|
5
|
+
declare module "react" {
|
|
6
|
+
interface CSSProperties {
|
|
7
|
+
"--rmd-badge-border-radius"?: string | number;
|
|
8
|
+
"--rmd-badge-greyscale-background-color"?: string;
|
|
9
|
+
"--rmd-badge-greyscale-color"?: string;
|
|
10
|
+
"--rmd-badge-size"?: string | number;
|
|
11
|
+
"--rmd-badge-offset"?: string | number;
|
|
12
|
+
"--rmd-badge-offset-top"?: string | number;
|
|
13
|
+
"--rmd-badge-offset-right"?: string | number;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
6
18
|
/** @defaultValue `"greyscale"` */
|
|
7
19
|
theme?: BadgeTheme;
|
package/src/badge/styles.ts
CHANGED
|
@@ -3,15 +3,6 @@ import { cnb } from "cnbuilder";
|
|
|
3
3
|
import { type BackgroundColor, cssUtils } from "../cssUtils.js";
|
|
4
4
|
import { bem } from "../utils/bem.js";
|
|
5
5
|
|
|
6
|
-
declare module "react" {
|
|
7
|
-
interface CSSProperties {
|
|
8
|
-
"--rmd-badge-size"?: string | number;
|
|
9
|
-
"--rmd-badge-offset"?: string | number;
|
|
10
|
-
"--rmd-badge-offset-top"?: string | number;
|
|
11
|
-
"--rmd-badge-offset-right"?: string | number;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
6
|
const styles = bem("rmd-badge");
|
|
16
7
|
|
|
17
8
|
/**
|
package/src/box/styles.ts
CHANGED
|
@@ -11,16 +11,25 @@ declare module "react" {
|
|
|
11
11
|
interface CSSProperties {
|
|
12
12
|
"--rmd-box-gap"?: string | number;
|
|
13
13
|
"--rmd-box-padding"?: string | number;
|
|
14
|
+
"--rmd-box-padding-h"?: string | number;
|
|
15
|
+
"--rmd-box-padding-v"?: string | number;
|
|
14
16
|
"--rmd-box-item-min-size"?: string | number;
|
|
17
|
+
"--rmd-box-item-min-height"?: string | number;
|
|
15
18
|
"--rmd-box-columns"?: string | number;
|
|
19
|
+
"--rmd-box-row-max-height"?: string;
|
|
20
|
+
"--rmd-box-auto-rows-height"?: string;
|
|
16
21
|
"--rmd-box-phone-columns"?: number | string;
|
|
22
|
+
"--rmd-box-phone-item-min-height"?: number | string;
|
|
17
23
|
"--rmd-box-phone-item-min-size"?: number | string;
|
|
18
24
|
"--rmd-box-tablet-columns"?: number | string;
|
|
19
25
|
"--rmd-box-tablet-item-min-size"?: number | string;
|
|
26
|
+
"--rmd-box-tablet-item-min-height"?: number | string;
|
|
20
27
|
"--rmd-box-desktop-columns"?: number | string;
|
|
21
28
|
"--rmd-box-desktop-item-min-size"?: number | string;
|
|
29
|
+
"--rmd-box-desktop-item-min-height"?: number | string;
|
|
22
30
|
"--rmd-box-large-desktop-columns"?: number | string;
|
|
23
31
|
"--rmd-box-large-desktop-item-min-size"?: number | string;
|
|
32
|
+
"--rmd-box-large-desktop-item-min-height"?: number | string;
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
|
package/src/button/styles.ts
CHANGED
|
@@ -19,8 +19,12 @@ declare module "react" {
|
|
|
19
19
|
"--rmd-button-text-vertical-padding"?: string | number;
|
|
20
20
|
"--rmd-button-text-min-height"?: string | number;
|
|
21
21
|
"--rmd-button-text-min-width"?: string | number;
|
|
22
|
+
"--rmd-button-text-border-radius"?: string | number;
|
|
22
23
|
"--rmd-button-icon-size"?: string | number;
|
|
23
|
-
"--rmd-button-icon-
|
|
24
|
+
"--rmd-button-icon-padding"?: string | number;
|
|
25
|
+
"--rmd-button-icon-font-size"?: string | number;
|
|
26
|
+
"--rmd-button-icon-border-radius"?: string | number;
|
|
27
|
+
"--rmd-button-icon-square-border-radius"?: string | number;
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
|
package/src/card/Card.tsx
CHANGED
|
@@ -4,14 +4,6 @@ import { Box } from "../box/Box.js";
|
|
|
4
4
|
import { type BoxAlignItems, type BoxOptions } from "../box/styles.js";
|
|
5
5
|
import { type CardClassNameOptions, card } from "./styles.js";
|
|
6
6
|
|
|
7
|
-
declare module "react" {
|
|
8
|
-
interface CSSProperties {
|
|
9
|
-
"--rmd-card-background-color"?: string;
|
|
10
|
-
"--rmd-card-color"?: string;
|
|
11
|
-
"--rmd-card-secondary-color"?: string;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
7
|
/**
|
|
16
8
|
* @since 6.0.0 Extends the {@link CardClassNameOptions} and removed the
|
|
17
9
|
* deprecated `raiseable` prop
|