@proyecto-viviana/solidaria-components 0.3.2 → 0.4.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.
- package/dist/ActionBar.js +184 -0
- package/dist/ActionBar.js.map +1 -0
- package/dist/ActionBar.jsx +128 -0
- package/dist/ActionBar.jsx.map +1 -0
- package/dist/ActionGroup.js +179 -0
- package/dist/ActionGroup.js.map +1 -0
- package/dist/ActionGroup.jsx +129 -0
- package/dist/ActionGroup.jsx.map +1 -0
- package/dist/Alert.js +111 -0
- package/dist/Alert.js.map +1 -0
- package/dist/Alert.jsx +82 -0
- package/dist/Alert.jsx.map +1 -0
- package/dist/Autocomplete.js +130 -0
- package/dist/Autocomplete.js.map +1 -0
- package/dist/Autocomplete.jsx +116 -0
- package/dist/Autocomplete.jsx.map +1 -0
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Breadcrumbs.js +334 -0
- package/dist/Breadcrumbs.js.map +1 -0
- package/dist/Breadcrumbs.jsx +266 -0
- package/dist/Breadcrumbs.jsx.map +1 -0
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +348 -0
- package/dist/Button.js.map +1 -0
- package/dist/Button.jsx +314 -0
- package/dist/Button.jsx.map +1 -0
- package/dist/Calendar.d.ts +4 -4
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Calendar.js +538 -0
- package/dist/Calendar.js.map +1 -0
- package/dist/Calendar.jsx +333 -0
- package/dist/Calendar.jsx.map +1 -0
- package/dist/CalendarPicker.d.ts +33 -0
- package/dist/CalendarPicker.d.ts.map +1 -0
- package/dist/CalendarPicker.js +44 -0
- package/dist/CalendarPicker.js.map +1 -0
- package/dist/CalendarPicker.jsx +44 -0
- package/dist/CalendarPicker.jsx.map +1 -0
- package/dist/Checkbox.d.ts +83 -4
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox.js +923 -0
- package/dist/Checkbox.js.map +1 -0
- package/dist/Checkbox.jsx +707 -0
- package/dist/Checkbox.jsx.map +1 -0
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +202 -0
- package/dist/Collection.js.map +1 -0
- package/dist/Collection.jsx +152 -0
- package/dist/Collection.jsx.map +1 -0
- package/dist/Color.d.ts.map +1 -1
- package/dist/Color.js +1720 -0
- package/dist/Color.js.map +1 -0
- package/dist/Color.jsx +1344 -0
- package/dist/Color.jsx.map +1 -0
- package/dist/ColorEditor.js +208 -0
- package/dist/ColorEditor.js.map +1 -0
- package/dist/ColorEditor.jsx +120 -0
- package/dist/ColorEditor.jsx.map +1 -0
- package/dist/ComboBox.d.ts +4 -4
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/ComboBox.js +992 -0
- package/dist/ComboBox.js.map +1 -0
- package/dist/ComboBox.jsx +714 -0
- package/dist/ComboBox.jsx.map +1 -0
- package/dist/ContextualHelpTrigger.js +146 -0
- package/dist/ContextualHelpTrigger.js.map +1 -0
- package/dist/ContextualHelpTrigger.jsx +109 -0
- package/dist/ContextualHelpTrigger.jsx.map +1 -0
- package/dist/DateField.d.ts +3 -3
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DateField.js +4 -0
- package/dist/DateField.jsx +4 -0
- package/dist/DateField2.js +499 -0
- package/dist/DateField2.js.map +1 -0
- package/dist/DateField2.jsx +317 -0
- package/dist/DateField2.jsx.map +1 -0
- package/dist/DatePicker.d.ts +4 -4
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/DatePicker.js +991 -0
- package/dist/DatePicker.js.map +1 -0
- package/dist/DatePicker.jsx +682 -0
- package/dist/DatePicker.jsx.map +1 -0
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.js +337 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/Dialog.jsx +192 -0
- package/dist/Dialog.jsx.map +1 -0
- package/dist/Disclosure.d.ts.map +1 -1
- package/dist/Disclosure.js +328 -0
- package/dist/Disclosure.js.map +1 -0
- package/dist/Disclosure.jsx +230 -0
- package/dist/Disclosure.jsx.map +1 -0
- package/dist/DragAndDrop.d.ts.map +1 -1
- package/dist/DragAndDrop.js +176 -0
- package/dist/DragAndDrop.js.map +1 -0
- package/dist/DragAndDrop.jsx +160 -0
- package/dist/DragAndDrop.jsx.map +1 -0
- package/dist/DropZone.d.ts.map +1 -1
- package/dist/DropZone.js +189 -0
- package/dist/DropZone.js.map +1 -0
- package/dist/DropZone.jsx +144 -0
- package/dist/DropZone.jsx.map +1 -0
- package/dist/FieldError.js +66 -0
- package/dist/FieldError.js.map +1 -0
- package/dist/FieldError.jsx +47 -0
- package/dist/FieldError.jsx.map +1 -0
- package/dist/FileTrigger.js +79 -0
- package/dist/FileTrigger.js.map +1 -0
- package/dist/FileTrigger.jsx +49 -0
- package/dist/FileTrigger.jsx.map +1 -0
- package/dist/Focusable.js +70 -0
- package/dist/Focusable.js.map +1 -0
- package/dist/Focusable.jsx +69 -0
- package/dist/Focusable.jsx.map +1 -0
- package/dist/Form.js +99 -0
- package/dist/Form.js.map +1 -0
- package/dist/Form.jsx +73 -0
- package/dist/Form.jsx.map +1 -0
- package/dist/GridList.d.ts +34 -2
- package/dist/GridList.d.ts.map +1 -1
- package/dist/GridList.js +723 -0
- package/dist/GridList.js.map +1 -0
- package/dist/GridList.jsx +552 -0
- package/dist/GridList.jsx.map +1 -0
- package/dist/HiddenTimeInput.js +104 -0
- package/dist/HiddenTimeInput.js.map +1 -0
- package/dist/HiddenTimeInput.jsx +69 -0
- package/dist/HiddenTimeInput.jsx.map +1 -0
- package/dist/Icon.d.ts.map +1 -1
- package/dist/Icon.js +127 -0
- package/dist/Icon.js.map +1 -0
- package/dist/Icon.jsx +72 -0
- package/dist/Icon.jsx.map +1 -0
- package/dist/Keyboard.js +30 -0
- package/dist/Keyboard.js.map +1 -0
- package/dist/Keyboard.jsx +24 -0
- package/dist/Keyboard.jsx.map +1 -0
- package/dist/Landmark.js +134 -0
- package/dist/Landmark.js.map +1 -0
- package/dist/Landmark.jsx +118 -0
- package/dist/Landmark.jsx.map +1 -0
- package/dist/Link.d.ts.map +1 -1
- package/dist/Link.js +219 -0
- package/dist/Link.js.map +1 -0
- package/dist/Link.jsx +189 -0
- package/dist/Link.jsx.map +1 -0
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/ListBox.js +670 -0
- package/dist/ListBox.js.map +1 -0
- package/dist/ListBox.jsx +508 -0
- package/dist/ListBox.jsx.map +1 -0
- package/dist/Menu.d.ts +27 -9
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Menu.js +1254 -0
- package/dist/Menu.js.map +1 -0
- package/dist/Menu.jsx +1042 -0
- package/dist/Menu.jsx.map +1 -0
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Meter.js +123 -0
- package/dist/Meter.js.map +1 -0
- package/dist/Meter.jsx +107 -0
- package/dist/Meter.jsx.map +1 -0
- package/dist/Modal.d.ts.map +1 -1
- package/dist/Modal.js +380 -0
- package/dist/Modal.js.map +1 -0
- package/dist/Modal.jsx +314 -0
- package/dist/Modal.jsx.map +1 -0
- package/dist/NumberField.d.ts +3 -3
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/NumberField.js +573 -0
- package/dist/NumberField.js.map +1 -0
- package/dist/NumberField.jsx +443 -0
- package/dist/NumberField.jsx.map +1 -0
- package/dist/Popover.d.ts +10 -2
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Popover.js +464 -0
- package/dist/Popover.js.map +1 -0
- package/dist/Popover.jsx +333 -0
- package/dist/Popover.jsx.map +1 -0
- package/dist/Pressable.js +69 -0
- package/dist/Pressable.js.map +1 -0
- package/dist/Pressable.jsx +68 -0
- package/dist/Pressable.jsx.map +1 -0
- package/dist/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar.js +130 -0
- package/dist/ProgressBar.js.map +1 -0
- package/dist/ProgressBar.jsx +114 -0
- package/dist/ProgressBar.jsx.map +1 -0
- package/dist/RadioGroup.d.ts +82 -4
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup.js +931 -0
- package/dist/RadioGroup.js.map +1 -0
- package/dist/RadioGroup.jsx +681 -0
- package/dist/RadioGroup.jsx.map +1 -0
- package/dist/RangeCalendar.d.ts.map +1 -1
- package/dist/RangeCalendar.js +410 -0
- package/dist/RangeCalendar.js.map +1 -0
- package/dist/RangeCalendar.jsx +253 -0
- package/dist/RangeCalendar.jsx.map +1 -0
- package/dist/RouterProvider.js +118 -0
- package/dist/RouterProvider.js.map +1 -0
- package/dist/RouterProvider.jsx +112 -0
- package/dist/RouterProvider.jsx.map +1 -0
- package/dist/SearchField.d.ts +2 -2
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/SearchField.js +643 -0
- package/dist/SearchField.js.map +1 -0
- package/dist/SearchField.jsx +526 -0
- package/dist/SearchField.jsx.map +1 -0
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +1031 -0
- package/dist/Select.js.map +1 -0
- package/dist/Select.jsx +744 -0
- package/dist/Select.jsx.map +1 -0
- package/dist/SelectionIndicator.d.ts.map +1 -1
- package/dist/SelectionIndicator.js +86 -0
- package/dist/SelectionIndicator.js.map +1 -0
- package/dist/SelectionIndicator.jsx +50 -0
- package/dist/SelectionIndicator.jsx.map +1 -0
- package/dist/Separator.js +97 -0
- package/dist/Separator.js.map +1 -0
- package/dist/Separator.jsx +85 -0
- package/dist/Separator.jsx.map +1 -0
- package/dist/SharedElementTransition.d.ts.map +1 -1
- package/dist/SharedElementTransition.js +165 -0
- package/dist/SharedElementTransition.js.map +1 -0
- package/dist/SharedElementTransition.jsx +138 -0
- package/dist/SharedElementTransition.jsx.map +1 -0
- package/dist/Slider.d.ts +33 -1
- package/dist/Slider.d.ts.map +1 -1
- package/dist/Slider.js +515 -0
- package/dist/Slider.js.map +1 -0
- package/dist/Slider.jsx +403 -0
- package/dist/Slider.jsx.map +1 -0
- package/dist/StepList.js +198 -0
- package/dist/StepList.js.map +1 -0
- package/dist/StepList.jsx +141 -0
- package/dist/StepList.jsx.map +1 -0
- package/dist/Switch.d.ts +65 -2
- package/dist/Switch.d.ts.map +1 -1
- package/dist/Switch.js +534 -0
- package/dist/Switch.js.map +1 -0
- package/dist/Switch.jsx +393 -0
- package/dist/Switch.jsx.map +1 -0
- package/dist/Table.d.ts +48 -0
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +1759 -0
- package/dist/Table.js.map +1 -0
- package/dist/Table.jsx +1348 -0
- package/dist/Table.jsx.map +1 -0
- package/dist/Tabs.d.ts +0 -4
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/Tabs.js +595 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Tabs.jsx +367 -0
- package/dist/Tabs.jsx.map +1 -0
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/TagGroup.js +378 -0
- package/dist/TagGroup.js.map +1 -0
- package/dist/TagGroup.jsx +270 -0
- package/dist/TagGroup.jsx.map +1 -0
- package/dist/Text.d.ts +18 -6
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +42 -0
- package/dist/Text.js.map +1 -0
- package/dist/Text.jsx +35 -0
- package/dist/Text.jsx.map +1 -0
- package/dist/TextField.d.ts +6 -6
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js +436 -0
- package/dist/TextField.js.map +1 -0
- package/dist/TextField.jsx +403 -0
- package/dist/TextField.jsx.map +1 -0
- package/dist/TimeField.d.ts +3 -3
- package/dist/TimeField.d.ts.map +1 -1
- package/dist/TimeField.js +372 -0
- package/dist/TimeField.js.map +1 -0
- package/dist/TimeField.jsx +224 -0
- package/dist/TimeField.jsx.map +1 -0
- package/dist/Toast.d.ts +14 -0
- package/dist/Toast.d.ts.map +1 -1
- package/dist/Toast.js +551 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Toast.jsx +361 -0
- package/dist/Toast.jsx.map +1 -0
- package/dist/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton.js +123 -0
- package/dist/ToggleButton.js.map +1 -0
- package/dist/ToggleButton.jsx +88 -0
- package/dist/ToggleButton.jsx.map +1 -0
- package/dist/ToggleButtonGroup.d.ts.map +1 -1
- package/dist/ToggleButtonGroup.js +114 -0
- package/dist/ToggleButtonGroup.js.map +1 -0
- package/dist/ToggleButtonGroup.jsx +85 -0
- package/dist/ToggleButtonGroup.jsx.map +1 -0
- package/dist/Toolbar.js +112 -0
- package/dist/Toolbar.js.map +1 -0
- package/dist/Toolbar.jsx +92 -0
- package/dist/Toolbar.jsx.map +1 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js +539 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/Tooltip.jsx +465 -0
- package/dist/Tooltip.jsx.map +1 -0
- package/dist/Tree.d.ts +14 -2
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Tree.js +1424 -0
- package/dist/Tree.js.map +1 -0
- package/dist/Tree.jsx +1172 -0
- package/dist/Tree.jsx.map +1 -0
- package/dist/Virtualizer.d.ts +16 -2
- package/dist/Virtualizer.d.ts.map +1 -1
- package/dist/Virtualizer.js +2 -0
- package/dist/Virtualizer.jsx +2 -0
- package/dist/Virtualizer2.js +751 -0
- package/dist/Virtualizer2.js.map +1 -0
- package/dist/Virtualizer2.jsx +730 -0
- package/dist/Virtualizer2.jsx.map +1 -0
- package/dist/VirtualizerLayouts.d.ts +18 -0
- package/dist/VirtualizerLayouts.d.ts.map +1 -1
- package/dist/VisuallyHidden.js +42 -0
- package/dist/VisuallyHidden.js.map +1 -0
- package/dist/VisuallyHidden.jsx +35 -0
- package/dist/VisuallyHidden.jsx.map +1 -0
- package/dist/contexts.js +33 -0
- package/dist/contexts.js.map +1 -0
- package/dist/contexts.jsx +33 -0
- package/dist/contexts.jsx.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +70 -23932
- package/dist/index.jsx +70 -18337
- package/dist/useDragAndDrop.js +2 -0
- package/dist/useDragAndDrop.jsx +2 -0
- package/dist/useDragAndDrop2.js +395 -0
- package/dist/useDragAndDrop2.js.map +1 -0
- package/dist/useDragAndDrop2.jsx +395 -0
- package/dist/useDragAndDrop2.jsx.map +1 -0
- package/dist/utils.d.ts +83 -11
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +285 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.jsx +277 -0
- package/dist/utils.jsx.map +1 -0
- package/dist/virtualizer/Layout.js +144 -0
- package/dist/virtualizer/Layout.js.map +1 -0
- package/dist/virtualizer/Layout.jsx +144 -0
- package/dist/virtualizer/Layout.jsx.map +1 -0
- package/package.json +401 -4
- package/src/Breadcrumbs.tsx +3 -1
- package/src/Button.tsx +22 -2
- package/src/Calendar.tsx +27 -10
- package/src/CalendarPicker.tsx +73 -0
- package/src/Checkbox.tsx +539 -3
- package/src/Collection.tsx +9 -3
- package/src/Color.tsx +42 -14
- package/src/ComboBox.tsx +50 -6
- package/src/DateField.tsx +20 -2
- package/src/DatePicker.tsx +57 -5
- package/src/Dialog.tsx +13 -5
- package/src/Disclosure.tsx +3 -1
- package/src/DragAndDrop.tsx +3 -1
- package/src/DropZone.tsx +3 -1
- package/src/GridList.tsx +125 -24
- package/src/Icon.tsx +3 -1
- package/src/Link.tsx +3 -1
- package/src/ListBox.tsx +31 -4
- package/src/Menu.tsx +252 -128
- package/src/Meter.tsx +3 -1
- package/src/Modal.tsx +100 -52
- package/src/NumberField.tsx +51 -8
- package/src/Popover.tsx +40 -10
- package/src/ProgressBar.tsx +3 -1
- package/src/RadioGroup.tsx +468 -4
- package/src/RangeCalendar.tsx +3 -1
- package/src/SearchField.tsx +27 -3
- package/src/Select.tsx +22 -7
- package/src/SelectionIndicator.tsx +3 -1
- package/src/SharedElementTransition.tsx +3 -1
- package/src/Slider.tsx +159 -13
- package/src/Switch.tsx +395 -2
- package/src/Table.tsx +409 -95
- package/src/Tabs.tsx +16 -45
- package/src/TagGroup.tsx +3 -1
- package/src/Text.tsx +31 -10
- package/src/TextField.tsx +43 -5
- package/src/TimeField.tsx +20 -2
- package/src/Toast.tsx +79 -14
- package/src/ToggleButton.tsx +3 -1
- package/src/ToggleButtonGroup.tsx +3 -1
- package/src/Tooltip.tsx +3 -1
- package/src/Tree.tsx +77 -9
- package/src/Virtualizer.tsx +180 -31
- package/src/VirtualizerLayouts.ts +45 -10
- package/src/index.ts +50 -0
- package/src/utils.tsx +243 -27
- package/dist/index.js.map +0 -1
- package/dist/index.jsx.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.jsx","names":["mergeProps"],"sources":["../src/utils.tsx"],"sourcesContent":["/**\n * Utility functions for solidaria-components\n * Port of react-aria-components/src/utils.tsx\n */\n\nimport {\n type JSX,\n type Accessor,\n type Context,\n type FlowComponent,\n createComponent,\n createContext,\n useContext,\n createMemo,\n createSignal,\n onMount,\n sharedConfig,\n untrack,\n Show,\n} from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nimport { mergeProps } from \"@proyecto-viviana/solidaria\";\n\n/**\n * Render props pattern - children can be a function that receives state\n */\nexport type RenderChildren<T> = JSX.Element | ((renderProps: T) => JSX.Element);\n\n/**\n * Class name can be a string or a function that computes based on state\n */\nexport type ClassNameOrFunction<T> = string | ((renderProps: T) => string);\n\n/**\n * Style can be an object or a function that computes based on state\n */\nexport type StyleOrFunction<T> = JSX.CSSProperties | ((renderProps: T) => JSX.CSSProperties);\n\n/**\n * Common render props interface\n */\nexport interface RenderPropsBase<T> {\n /** The children of the component. A function may be provided to receive render props. */\n children?: RenderChildren<T>;\n /** The CSS className for the element. A function may be provided to compute the class based on state. */\n class?: ClassNameOrFunction<T>;\n /** The inline style for the element. A function may be provided to compute the style based on state. */\n style?: StyleOrFunction<T>;\n}\n\n/**\n * Slot props for named slots\n */\nexport interface SlotProps {\n /** A slot name for the component. */\n slot?: string;\n}\n\nexport const DEFAULT_SLOT = \"default\";\n\n/**\n * Return type for useRenderProps\n */\nexport interface RenderPropsResult<T> {\n /** Accessor for class - safe to call anytime */\n class: Accessor<string>;\n /** Accessor for style - safe to call anytime */\n style: Accessor<JSX.CSSProperties | undefined>;\n /**\n * Render the children. This is a function that returns JSX, NOT a getter.\n * For SSR compatibility, this should be called within the JSX tree.\n *\n * Usage in components:\n * {renderProps.renderChildren()}\n *\n * Or if you need the raw children/function:\n * {renderProps.renderChildren()}\n */\n renderChildren: () => JSX.Element;\n /**\n * Render a render-prop child ONCE over a reactive view of the values,\n * mirroring how React reconciles a render prop's returned tree in place.\n *\n * Prefer this over `renderChildren()` for interactive leaf components (a\n * Tab, a toggle segment) whose child wraps the pressable element: re-invoking\n * the render function on every values() change recreates that DOM subtree,\n * which detaches the pointer/press target mid-gesture and makes the browser\n * suppress the native `click` (createPress then has to synthesize an\n * untrusted fallback click — a visible parity break vs React). Static (non\n * function) children are returned untouched, exactly like `renderChildren`.\n */\n renderChildrenStable: () => JSX.Element;\n /** The raw children prop (function or JSX) - use renderChildren() in most cases */\n children: RenderChildren<T> | undefined;\n /** The render props values accessor */\n values: Accessor<T>;\n}\n\n/**\n * Resolves render props (children, class, style) based on component state.\n *\n * For SSR compatibility, children are NOT evaluated eagerly. Instead:\n * - Use `renderChildren()` to render children with current values\n * - Or access `children` directly if you need the raw prop\n *\n * This avoids the getter pattern that causes SSR hydration mismatches.\n */\nexport function useRenderProps<T extends object>(\n props: RenderPropsBase<T> & { defaultClassName?: string },\n values: Accessor<T>,\n): RenderPropsResult<T> {\n // Don't destructure children — access lazily to avoid eager evaluation\n // that would trigger child component creation before context providers mount.\n const { class: className, style, defaultClassName = \"\" } = props;\n\n // Compute class and style eagerly (they don't depend on context)\n const computedClass = createMemo(() => {\n const currentValues = values();\n return typeof className === \"function\"\n ? className(currentValues)\n : (className ?? defaultClassName);\n });\n\n const computedStyle = createMemo(() => {\n const currentValues = values();\n return typeof style === \"function\" ? style(currentValues) : style;\n });\n\n // Return object with explicit function for rendering children\n // Children are accessed lazily during render (inside context providers)\n return {\n class: computedClass,\n style: computedStyle,\n renderChildren: () => {\n const children = props.children;\n // Only read values() for render-prop children. Static JSX children must\n // not track the render-state memo: re-running the insertion effect\n // recreates real DOM nodes on every hover/press/focus flip (React keeps\n // them stable via vdom diffing), which detaches the pressed node\n // mid-press and suppresses the browser's native click.\n //\n // A render prop takes the values argument, so classify by arity — the\n // same convention `solid-js/h` uses for dynamic props. A zero-arg\n // function child is an accessor (a compiled `{expression}` child, a\n // solid-refresh dev wrapper, a one-shot `solid-js/h` element thunk):\n // return it untouched so the insert machinery unwraps it in its own\n // nested effect. Calling it here would track its reads in the shared\n // insertion effect, and every re-run disposes the child computations\n // that effect owns — a one-shot h thunk then hands back the same\n // disposed node, leaving connected DOM whose reactivity is dead.\n return typeof children === \"function\" && children.length > 0\n ? children(values())\n : (children as JSX.Element);\n },\n renderChildrenStable: () => {\n const children = props.children;\n if (typeof children !== \"function\" || children.length === 0) {\n return children as JSX.Element;\n }\n // Invoke the render function exactly once, over a getter view of the\n // values, so the returned DOM is created a single time and only the\n // reactive reads inside it (JSX bindings, component props) re-run on a\n // values() change — React's reconciliation, not Solid's recreation.\n //\n // `untrack` keeps the enclosing insert from tracking values() (so it\n // never re-runs and never recreates), but does NOT change the owner:\n // this still executes inside the caller's insert scope, so any slotted\n // context the render prop reads binds against the surrounding provider.\n //\n // The value keys are read once here (untracked). Render-state memos in\n // this codebase return a fixed-shape object, so the key set is stable.\n return untrack(() => {\n const snapshot = values();\n const view = {} as T;\n for (const key of Object.keys(snapshot) as Array<keyof T & string>) {\n Object.defineProperty(view, key, {\n enumerable: true,\n configurable: true,\n get: () => values()[key],\n });\n }\n return (children as (renderProps: T) => JSX.Element)(view);\n });\n },\n get children() {\n return props.children;\n },\n values,\n };\n}\n\nexport function composeRenderProps<T extends object>(\n base: RenderPropsBase<T> | undefined,\n override: RenderPropsBase<T> | undefined,\n): RenderPropsBase<T> {\n if (!base) return override ?? {};\n if (!override) return base;\n return {\n children: override.children ?? base.children,\n class: override.class ?? base.class,\n style: override.style ?? base.style,\n };\n}\n\n/** A Solid ref target: a callback, a mutable `{ current }` object, or undefined. */\nexport type RefLike<T> = T | ((el: T) => void) | { current?: T | null } | undefined;\n\n/** A value paired with an optional ref to merge onto the consuming element. */\nexport type WithRef<T, E> = T & { ref?: RefLike<E> };\n\n/**\n * A context value carrying named slots (mirrors react-aria-components'\n * `SlottedValue`). Each entry under `slots` is the props object delivered to the\n * component rendered with the matching `slot` name.\n */\nexport interface SlottedValue<T> {\n slots?: Record<string, T>;\n}\n\n/** A slotted context value: a slots record, a bare value, or null/undefined. */\nexport type SlottedContextValue<T> = SlottedValue<T> | T | null | undefined;\n\n/**\n * The value type for a context consumed via {@link useContextProps}. Mirrors\n * upstream `ContextValue<T, E>`: it may carry `slots` and an optional `ref` to\n * merge onto the consuming element.\n */\nexport type ContextValue<T, E = HTMLElement> = SlottedContextValue<WithRef<T, E>>;\n\n/**\n * Creates a context that can carry either a bare value or a `slots` record.\n */\nexport function createSlottedContext<T>() {\n return createContext<SlottedContextValue<T>>(null);\n}\n\n/** Assigns an element to a Solid ref (callback or mutable `{ current }` object). */\nexport function assignRef<T>(ref: RefLike<T>, el: T): void {\n if (!ref) {\n return;\n }\n\n if (typeof ref === \"function\") {\n (ref as (el: T) => void)(el);\n } else if (typeof ref === \"object\" && \"current\" in ref) {\n (ref as { current?: T | null }).current = el;\n }\n}\n\n/** Merges multiple Solid refs into one callback that forwards to each, once. */\nexport function mergeRefs<T>(...refs: Array<RefLike<T>>): (el: T) => void {\n return (el: T) => {\n const seen = new Set<RefLike<T>>();\n for (const ref of refs) {\n if (!ref || seen.has(ref)) {\n continue;\n }\n\n seen.add(ref);\n assignRef(ref, el);\n }\n };\n}\n\n/**\n * Resolves a (possibly slotted) context value for the given slot name. Port of\n * react-aria-components' `useSlottedContext`:\n * - `slot === null` opts out of the context entirely (returns `null`);\n * - if the context carries a `slots` record, the entry for `slot` (or\n * {@link DEFAULT_SLOT}) is returned, throwing on an unknown slot name;\n * - otherwise the bare context value is returned.\n */\nexport function useSlottedContext<T>(\n context: Context<SlottedContextValue<T>>,\n slot?: string | null,\n): T | null | undefined {\n const ctx = useContext(context);\n if (slot === null) {\n // An explicit `null` slot means: ignore this context.\n return null;\n }\n\n if (ctx && typeof ctx === \"object\" && \"slots\" in ctx && ctx.slots) {\n const slots = ctx.slots as Record<string, T>;\n const slotName = slot || DEFAULT_SLOT;\n const slotValue = slots[slotName];\n if (!slotValue) {\n const validSlots = Object.keys(slots)\n .map((name) => `\"${name}\"`)\n .join(\", \");\n throw new Error(\n slot\n ? `Invalid slot \"${slot}\". Valid slot names are ${validSlots}.`\n : `A slot prop is required. Valid slot names are ${validSlots}.`,\n );\n }\n return slotValue;\n }\n\n return ctx as T | null | undefined;\n}\n\n/**\n * Merges context-provided props and a context ref into a component's own props\n * and ref. Port of react-aria-components' `useContextProps`:\n * - the context is resolved for `props.slot` via {@link useSlottedContext};\n * - props win over context props (handler props are chained by `mergeProps`);\n * - the component's own ref and the context's ref merge into one callback.\n *\n * The prop merge stays reactive (Solid `mergeProps` preserves getters), so prop\n * changes keep flowing; the context value is read once at setup, matching a single\n * upstream render.\n */\nexport function useContextProps<TProps extends SlotProps, TRef>(\n props: TProps,\n ref: RefLike<TRef>,\n context: Context<ContextValue<TProps, TRef>>,\n): [TProps, (el: TRef) => void] {\n const ctx = (useSlottedContext(context, props.slot) ?? {}) as WithRef<Partial<TProps>, TRef>;\n const { ref: contextRef, ...contextProps } = ctx;\n const mergedRef = mergeRefs(ref, contextRef);\n const mergedProps = mergeProps(contextProps as object, props as object) as unknown as TProps;\n return [mergedProps, mergedRef];\n}\n\n/**\n * Detects whether slotted content was rendered into a placeholder, for the\n * aria-label fallback pattern. Port of react-aria-components' `useSlot`: returns a\n * ref callback to attach to the placeholder and an accessor that is `true` while\n * an element is mounted there. The accessor flips to `false` after mount if the\n * ref never ran (no slotted content was provided).\n */\nexport function useSlot(initialState = true): [(el: Element | null) => void, Accessor<boolean>] {\n const [hasSlot, setHasSlot] = createSignal(initialState);\n let hasRun = false;\n const ref = (el: Element | null) => {\n hasRun = true;\n setHasSlot(!!el);\n };\n onMount(() => {\n if (!hasRun) {\n setHasSlot(false);\n }\n });\n return [ref, hasSlot];\n}\n\n/**\n * Nests a set of context providers around `children`. Port of\n * react-aria-components' `Provider`: each `[Context, value]` pair wraps the\n * previous result, so the LAST pair is the outermost provider — matching upstream's\n * wrap-in-iteration-order.\n *\n * `children` is read through a lazy getter inside the innermost provider so child\n * components are *created* within every provider's owner; Solid binds `useContext`\n * at component-execution time, so eager children would miss these providers.\n */\nexport function Provider(props: {\n values: Array<[Context<unknown>, unknown]>;\n children: JSX.Element;\n}): JSX.Element {\n const build = (index: number): JSX.Element => {\n if (index < 0) {\n return props.children;\n }\n const [context, value] = props.values[index];\n return createComponent(context.Provider, {\n value,\n get children() {\n return build(index - 1);\n },\n });\n };\n return build(props.values.length - 1);\n}\n\n/**\n * Converts boolean state values to data attributes\n */\nexport function dataAttr(value: boolean | undefined): \"\" | undefined {\n return value ? \"\" : undefined;\n}\n\n/**\n * Creates data attributes from render props\n */\nexport function createDataAttributes<T extends Record<string, boolean | string | undefined>>(\n values: T,\n): Record<string, string | undefined> {\n const result: Record<string, string | undefined> = {};\n\n for (const [key, value] of Object.entries(values)) {\n if (typeof value === \"boolean\") {\n result[`data-${camelToKebab(key)}`] = value ? \"\" : undefined;\n } else if (value !== undefined) {\n result[`data-${camelToKebab(key)}`] = value;\n }\n }\n\n return result;\n}\n\nfunction camelToKebab(str: string): string {\n return str.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase();\n}\n\n/**\n * Remove data attributes from props (for internal use)\n */\nexport function removeDataAttributes<T extends Record<string, unknown>>(props: T): T {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(props)) {\n if (!key.startsWith(\"data-\")) {\n result[key] = value;\n }\n }\n\n return result as T;\n}\n\n/**\n * Filter DOM props - keep only valid DOM attributes.\n *\n * @param props - Component props to filter\n * @param options - Options for filtering (global: include global attrs)\n * @returns Object containing only valid DOM props. Use type parameter R to specify return type.\n */\nexport function filterDOMProps<R extends object = Record<string, unknown>>(\n props: object,\n options: { global?: boolean } = {},\n): R {\n const { global = false } = options;\n const result: Record<string, unknown> = {};\n\n const globalAttrs = new Set([\n \"id\",\n \"class\",\n \"style\",\n \"tabIndex\",\n \"role\",\n \"title\",\n \"lang\",\n \"dir\",\n \"hidden\",\n \"draggable\",\n \"accessKey\",\n \"contentEditable\",\n \"spellcheck\",\n ]);\n\n const ariaAttrs = /^aria-/;\n const dataAttrs = /^data-/;\n const eventHandlers = /^on[A-Z]/;\n\n for (const key in props) {\n if (\n Object.prototype.hasOwnProperty.call(props, key) &&\n ((global && globalAttrs.has(key)) ||\n ariaAttrs.test(key) ||\n dataAttrs.test(key) ||\n eventHandlers.test(key))\n ) {\n result[key] = (props as Record<string, unknown>)[key];\n }\n }\n\n return result as R;\n}\n\nexport interface ClientOnlyProps {\n /** The children to render only on the client */\n children: JSX.Element;\n /** Optional fallback to render during SSR and initial hydration */\n fallback?: JSX.Element;\n}\n\n/**\n * ClientOnly component - renders children only on the client side.\n *\n * During SSR, renders the fallback (or nothing).\n * During hydration, renders the same fallback to match SSR.\n * After hydration completes, switches to render children.\n *\n * This is useful for components that rely on browser APIs or\n * have different server/client output.\n *\n * @example\n * ```tsx\n * <ClientOnly fallback={<div>Loading...</div>}>\n * <Calendar />\n * </ClientOnly>\n * ```\n */\nexport const ClientOnly: FlowComponent<ClientOnlyProps> = (props) => {\n // On server, always render fallback\n if (isServer) {\n return <>{props.fallback}</>;\n }\n\n // Outside a hydration walk there is nothing to defer (see useIsHydrated).\n if (!sharedConfig.context) {\n return <>{props.children}</>;\n }\n\n // Hydrating: render the fallback until the walk completes.\n const [isHydrated, setIsHydrated] = createSignal(false);\n\n // onMount runs after hydration is complete\n onMount(() => {\n setIsHydrated(true);\n });\n\n return (\n <Show when={isHydrated()} fallback={props.fallback}>\n {props.children}\n </Show>\n );\n};\n\n/**\n * Returns true only on the client after hydration is complete.\n * Can be used to conditionally render client-only content.\n *\n * @example\n * ```tsx\n * const hydrated = useIsHydrated();\n * return (\n * <Show when={hydrated()} fallback={<Placeholder />}>\n * <ClientOnlyComponent />\n * </Show>\n * );\n * ```\n */\nexport function useIsHydrated(): Accessor<boolean> {\n // On server, always return false\n if (isServer) {\n return () => false;\n }\n\n // Outside a hydration walk (pure CSR, or a remount created after hydration\n // finished) the caller is already \"hydrated\" — report true immediately.\n // Solid sets `sharedConfig.context` only while synchronously walking\n // server-rendered DOM, so this is exactly the window the false→true flip\n // exists for. A fresh per-instance false→true flip on every remount is not\n // just wasted work: ancestor `children()`/`Context.Provider` resolution\n // unwraps and tracks the <Show> accessor this hook gates, so the post-mount\n // flip re-resolves those children, recreates the subtree (with another fresh\n // signal), and loops forever — a stack overflow with no overlay rendered.\n if (!sharedConfig.context) {\n return () => true;\n }\n\n // Hydrating: start false (so the first render matches the server, which\n // emitted nothing for hydrated-gated content) and flip to true after mount.\n const [isHydrated, setIsHydrated] = createSignal(false);\n\n // onMount runs in the effect phase — *after* the synchronous hydration pass\n // has finished walking the server DOM — so flipping here renders the gated\n // content as a fresh client-side update (Portal: no getNextElement walk, no\n // mismatch). This mirrors the component gate above and is strictly earlier\n // than a rAF tick.\n onMount(() => {\n setIsHydrated(true);\n });\n\n return isHydrated;\n}\n"],"mappings":";;;;;;;;AA0DA,MAAa,eAAe;;;;;;;;;;AAiD5B,SAAgB,eACd,OACA,QACsB;CAGtB,MAAM,EAAE,OAAO,WAAW,OAAO,mBAAmB,OAAO;CAiB3D,OAAO;EACL,OAfoB,iBAAiB;GACrC,MAAM,gBAAgB,OAAO;GAC7B,OAAO,OAAO,cAAc,aACxB,UAAU,aAAa,IACtB,aAAa;EACpB,CAUqB;EACnB,OAToB,iBAAiB;GACrC,MAAM,gBAAgB,OAAO;GAC7B,OAAO,OAAO,UAAU,aAAa,MAAM,aAAa,IAAI;EAC9D,CAMqB;EACnB,sBAAsB;GACpB,MAAM,WAAW,MAAM;GAgBvB,OAAO,OAAO,aAAa,cAAc,SAAS,SAA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OACE,CAAC,KAAK,MAAM,WAAW,GAAG,UAAU,MAAM,UAAU;OACjD,MAAM,SAAS;IAClB,EAAE;AAEN;;;;;;;;;;;;;;;AAgBA,SAAgB,gBAAmC;CAEjD,IAAI,UACF,aAAa;CAYf,IAAI,CAAC,aAAa,SAChB,aAAa;CAKf,MAAM,CAAC,YAAY,iBAAiB,aAAa,KAAK;CAOtD,cAAc;EACZ,cAAc,IAAI;CACpB,CAAC;CAED,OAAO;AACT"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
//#region src/virtualizer/Layout.ts
|
|
2
|
+
var Point = class Point {
|
|
3
|
+
x;
|
|
4
|
+
y;
|
|
5
|
+
constructor(x = 0, y = 0) {
|
|
6
|
+
this.x = x;
|
|
7
|
+
this.y = y;
|
|
8
|
+
}
|
|
9
|
+
copy() {
|
|
10
|
+
return new Point(this.x, this.y);
|
|
11
|
+
}
|
|
12
|
+
equals(point) {
|
|
13
|
+
return this.x === point.x && this.y === point.y;
|
|
14
|
+
}
|
|
15
|
+
isOrigin() {
|
|
16
|
+
return this.x === 0 && this.y === 0;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var Size = class Size {
|
|
20
|
+
width;
|
|
21
|
+
height;
|
|
22
|
+
constructor(width = 0, height = 0) {
|
|
23
|
+
this.width = Math.max(0, width);
|
|
24
|
+
this.height = Math.max(0, height);
|
|
25
|
+
}
|
|
26
|
+
copy() {
|
|
27
|
+
return new Size(this.width, this.height);
|
|
28
|
+
}
|
|
29
|
+
equals(other) {
|
|
30
|
+
return this.width === other.width && this.height === other.height;
|
|
31
|
+
}
|
|
32
|
+
get area() {
|
|
33
|
+
return this.width * this.height;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var Rect = class Rect {
|
|
37
|
+
x;
|
|
38
|
+
y;
|
|
39
|
+
width;
|
|
40
|
+
height;
|
|
41
|
+
constructor(x = 0, y = 0, width = 0, height = 0) {
|
|
42
|
+
this.x = x;
|
|
43
|
+
this.y = y;
|
|
44
|
+
this.width = width;
|
|
45
|
+
this.height = height;
|
|
46
|
+
}
|
|
47
|
+
get maxX() {
|
|
48
|
+
return this.x + this.width;
|
|
49
|
+
}
|
|
50
|
+
get maxY() {
|
|
51
|
+
return this.y + this.height;
|
|
52
|
+
}
|
|
53
|
+
get area() {
|
|
54
|
+
return this.width * this.height;
|
|
55
|
+
}
|
|
56
|
+
get topLeft() {
|
|
57
|
+
return new Point(this.x, this.y);
|
|
58
|
+
}
|
|
59
|
+
get topRight() {
|
|
60
|
+
return new Point(this.maxX, this.y);
|
|
61
|
+
}
|
|
62
|
+
get bottomLeft() {
|
|
63
|
+
return new Point(this.x, this.maxY);
|
|
64
|
+
}
|
|
65
|
+
get bottomRight() {
|
|
66
|
+
return new Point(this.maxX, this.maxY);
|
|
67
|
+
}
|
|
68
|
+
intersects(rect) {
|
|
69
|
+
return this.x <= rect.maxX && rect.x <= this.maxX && this.y <= rect.maxY && rect.y <= this.maxY;
|
|
70
|
+
}
|
|
71
|
+
containsRect(rect) {
|
|
72
|
+
return this.x <= rect.x && this.y <= rect.y && this.maxX >= rect.maxX && this.maxY >= rect.maxY;
|
|
73
|
+
}
|
|
74
|
+
containsPoint(point) {
|
|
75
|
+
return this.x <= point.x && this.y <= point.y && this.maxX >= point.x && this.maxY >= point.y;
|
|
76
|
+
}
|
|
77
|
+
union(other) {
|
|
78
|
+
const x = Math.min(this.x, other.x);
|
|
79
|
+
const y = Math.min(this.y, other.y);
|
|
80
|
+
return new Rect(x, y, Math.max(this.maxX, other.maxX) - x, Math.max(this.maxY, other.maxY) - y);
|
|
81
|
+
}
|
|
82
|
+
intersection(other) {
|
|
83
|
+
if (!this.intersects(other)) return new Rect(0, 0, 0, 0);
|
|
84
|
+
const x = Math.max(this.x, other.x);
|
|
85
|
+
const y = Math.max(this.y, other.y);
|
|
86
|
+
return new Rect(x, y, Math.min(this.maxX, other.maxX) - x, Math.min(this.maxY, other.maxY) - y);
|
|
87
|
+
}
|
|
88
|
+
copy() {
|
|
89
|
+
return new Rect(this.x, this.y, this.width, this.height);
|
|
90
|
+
}
|
|
91
|
+
equals(rect) {
|
|
92
|
+
return this.x === rect.x && this.y === rect.y && this.width === rect.width && this.height === rect.height;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var LayoutInfo = class LayoutInfo {
|
|
96
|
+
type;
|
|
97
|
+
key;
|
|
98
|
+
rect;
|
|
99
|
+
parentKey = null;
|
|
100
|
+
content = null;
|
|
101
|
+
estimatedSize = false;
|
|
102
|
+
isSticky = false;
|
|
103
|
+
opacity = 1;
|
|
104
|
+
transform = null;
|
|
105
|
+
zIndex = 0;
|
|
106
|
+
allowOverflow = false;
|
|
107
|
+
constructor(type, key, rect) {
|
|
108
|
+
this.type = type;
|
|
109
|
+
this.key = key;
|
|
110
|
+
this.rect = rect;
|
|
111
|
+
}
|
|
112
|
+
copy() {
|
|
113
|
+
const copy = new LayoutInfo(this.type, this.key, this.rect.copy());
|
|
114
|
+
copy.parentKey = this.parentKey;
|
|
115
|
+
copy.content = this.content;
|
|
116
|
+
copy.estimatedSize = this.estimatedSize;
|
|
117
|
+
copy.isSticky = this.isSticky;
|
|
118
|
+
copy.opacity = this.opacity;
|
|
119
|
+
copy.transform = this.transform;
|
|
120
|
+
copy.zIndex = this.zIndex;
|
|
121
|
+
copy.allowOverflow = this.allowOverflow;
|
|
122
|
+
return copy;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var Layout = class {
|
|
126
|
+
virtualizer = null;
|
|
127
|
+
shouldInvalidate(newRect, oldRect) {
|
|
128
|
+
return newRect.width !== oldRect.width || newRect.height !== oldRect.height;
|
|
129
|
+
}
|
|
130
|
+
shouldInvalidateLayoutOptions(newOptions, oldOptions) {
|
|
131
|
+
return newOptions !== oldOptions;
|
|
132
|
+
}
|
|
133
|
+
update(_context) {}
|
|
134
|
+
getItemRect(key) {
|
|
135
|
+
return this.getLayoutInfo(key)?.rect ?? null;
|
|
136
|
+
}
|
|
137
|
+
getVisibleRect() {
|
|
138
|
+
return this.virtualizer?.visibleRect ?? new Rect();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
//#endregion
|
|
142
|
+
export { Layout, LayoutInfo, Point, Rect, Size };
|
|
143
|
+
|
|
144
|
+
//# sourceMappingURL=Layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layout.js","names":[],"sources":["../../src/virtualizer/Layout.ts"],"sourcesContent":["import type { Key } from \"@proyecto-viviana/solid-stately\";\n\nexport interface InvalidationContext<O = unknown> {\n contentChanged?: boolean;\n offsetChanged?: boolean;\n sizeChanged?: boolean;\n itemSizeChanged?: boolean;\n layoutOptionsChanged?: boolean;\n layoutOptions?: O;\n}\n\nexport class Point {\n constructor(\n public x = 0,\n public y = 0,\n ) {}\n copy(): Point {\n return new Point(this.x, this.y);\n }\n equals(point: Point): boolean {\n return this.x === point.x && this.y === point.y;\n }\n isOrigin(): boolean {\n return this.x === 0 && this.y === 0;\n }\n}\n\nexport class Size {\n width: number;\n height: number;\n\n constructor(width = 0, height = 0) {\n this.width = Math.max(0, width);\n this.height = Math.max(0, height);\n }\n\n copy(): Size {\n return new Size(this.width, this.height);\n }\n\n equals(other: Size): boolean {\n return this.width === other.width && this.height === other.height;\n }\n\n get area(): number {\n return this.width * this.height;\n }\n}\n\nexport class Rect {\n constructor(\n public x = 0,\n public y = 0,\n public width = 0,\n public height = 0,\n ) {}\n\n get maxX(): number {\n return this.x + this.width;\n }\n\n get maxY(): number {\n return this.y + this.height;\n }\n\n get area(): number {\n return this.width * this.height;\n }\n\n get topLeft(): Point {\n return new Point(this.x, this.y);\n }\n\n get topRight(): Point {\n return new Point(this.maxX, this.y);\n }\n\n get bottomLeft(): Point {\n return new Point(this.x, this.maxY);\n }\n\n get bottomRight(): Point {\n return new Point(this.maxX, this.maxY);\n }\n\n intersects(rect: Rect): boolean {\n return this.x <= rect.maxX && rect.x <= this.maxX && this.y <= rect.maxY && rect.y <= this.maxY;\n }\n\n containsRect(rect: Rect): boolean {\n return this.x <= rect.x && this.y <= rect.y && this.maxX >= rect.maxX && this.maxY >= rect.maxY;\n }\n\n containsPoint(point: Point): boolean {\n return this.x <= point.x && this.y <= point.y && this.maxX >= point.x && this.maxY >= point.y;\n }\n\n union(other: Rect): Rect {\n const x = Math.min(this.x, other.x);\n const y = Math.min(this.y, other.y);\n const width = Math.max(this.maxX, other.maxX) - x;\n const height = Math.max(this.maxY, other.maxY) - y;\n return new Rect(x, y, width, height);\n }\n\n intersection(other: Rect): Rect {\n if (!this.intersects(other)) {\n return new Rect(0, 0, 0, 0);\n }\n const x = Math.max(this.x, other.x);\n const y = Math.max(this.y, other.y);\n const width = Math.min(this.maxX, other.maxX) - x;\n const height = Math.min(this.maxY, other.maxY) - y;\n return new Rect(x, y, width, height);\n }\n\n copy(): Rect {\n return new Rect(this.x, this.y, this.width, this.height);\n }\n\n equals(rect: Rect): boolean {\n return (\n this.x === rect.x &&\n this.y === rect.y &&\n this.width === rect.width &&\n this.height === rect.height\n );\n }\n}\n\nexport class LayoutInfo {\n parentKey: Key | null = null;\n content: unknown = null;\n estimatedSize = false;\n isSticky = false;\n opacity = 1;\n transform: string | null = null;\n zIndex = 0;\n allowOverflow = false;\n\n constructor(\n public type: string,\n public key: Key,\n public rect: Rect,\n ) {}\n\n copy(): LayoutInfo {\n const copy = new LayoutInfo(this.type, this.key, this.rect.copy());\n copy.parentKey = this.parentKey;\n copy.content = this.content;\n copy.estimatedSize = this.estimatedSize;\n copy.isSticky = this.isSticky;\n copy.opacity = this.opacity;\n copy.transform = this.transform;\n copy.zIndex = this.zIndex;\n copy.allowOverflow = this.allowOverflow;\n return copy;\n }\n}\n\ninterface VirtualizerLike {\n visibleRect: Rect;\n}\n\nexport abstract class Layout<T extends object = object, O = unknown> {\n virtualizer: VirtualizerLike | null = null;\n\n abstract getVisibleLayoutInfos(rect: Rect): LayoutInfo[];\n abstract getLayoutInfo(key: Key): LayoutInfo | null;\n abstract getContentSize(): Size;\n\n shouldInvalidate(newRect: Rect, oldRect: Rect): boolean {\n return newRect.width !== oldRect.width || newRect.height !== oldRect.height;\n }\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return newOptions !== oldOptions;\n }\n\n update(_context: InvalidationContext<O>): void {}\n\n updateItemSize?(_key: Key, _size: Size): boolean;\n getDropTargetLayoutInfo?(_target: unknown): LayoutInfo | null;\n\n protected getItemRect(key: Key): Rect | null {\n return this.getLayoutInfo(key)?.rect ?? null;\n }\n\n getVisibleRect(): Rect {\n return this.virtualizer?.visibleRect ?? new Rect();\n }\n}\n"],"mappings":";AAWA,IAAa,QAAb,MAAa,MAAM;CAER;CACA;CAFT,YACE,IAAW,GACX,IAAW,GACX;EAFO,KAAA,IAAA;EACA,KAAA,IAAA;CACN;CACH,OAAc;EACZ,OAAO,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC;CACjC;CACA,OAAO,OAAuB;EAC5B,OAAO,KAAK,MAAM,MAAM,KAAK,KAAK,MAAM,MAAM;CAChD;CACA,WAAoB;EAClB,OAAO,KAAK,MAAM,KAAK,KAAK,MAAM;CACpC;AACF;AAEA,IAAa,OAAb,MAAa,KAAK;CAChB;CACA;CAEA,YAAY,QAAQ,GAAG,SAAS,GAAG;EACjC,KAAK,QAAQ,KAAK,IAAI,GAAG,KAAK;EAC9B,KAAK,SAAS,KAAK,IAAI,GAAG,MAAM;CAClC;CAEA,OAAa;EACX,OAAO,IAAI,KAAK,KAAK,OAAO,KAAK,MAAM;CACzC;CAEA,OAAO,OAAsB;EAC3B,OAAO,KAAK,UAAU,MAAM,SAAS,KAAK,WAAW,MAAM;CAC7D;CAEA,IAAI,OAAe;EACjB,OAAO,KAAK,QAAQ,KAAK;CAC3B;AACF;AAEA,IAAa,OAAb,MAAa,KAAK;CAEP;CACA;CACA;CACA;CAJT,YACE,IAAW,GACX,IAAW,GACX,QAAe,GACf,SAAgB,GAChB;EAJO,KAAA,IAAA;EACA,KAA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Ae;CACxB;CAEA,OAAO,UAAwC,CAAC;CAKhD,YAAsB,KAAuB;EAC3C,OAAO,KAAK,cAAc,GAAG,CAAC,EAAE,QAAQ;CAC1C;CAEA,iBAAuB;EACrB,OAAO,KAAK,aAAa,eAAe,IAAI,KAAK;CACnD;AACF"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
//#region src/virtualizer/Layout.ts
|
|
2
|
+
var Point = class Point {
|
|
3
|
+
x;
|
|
4
|
+
y;
|
|
5
|
+
constructor(x = 0, y = 0) {
|
|
6
|
+
this.x = x;
|
|
7
|
+
this.y = y;
|
|
8
|
+
}
|
|
9
|
+
copy() {
|
|
10
|
+
return new Point(this.x, this.y);
|
|
11
|
+
}
|
|
12
|
+
equals(point) {
|
|
13
|
+
return this.x === point.x && this.y === point.y;
|
|
14
|
+
}
|
|
15
|
+
isOrigin() {
|
|
16
|
+
return this.x === 0 && this.y === 0;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var Size = class Size {
|
|
20
|
+
width;
|
|
21
|
+
height;
|
|
22
|
+
constructor(width = 0, height = 0) {
|
|
23
|
+
this.width = Math.max(0, width);
|
|
24
|
+
this.height = Math.max(0, height);
|
|
25
|
+
}
|
|
26
|
+
copy() {
|
|
27
|
+
return new Size(this.width, this.height);
|
|
28
|
+
}
|
|
29
|
+
equals(other) {
|
|
30
|
+
return this.width === other.width && this.height === other.height;
|
|
31
|
+
}
|
|
32
|
+
get area() {
|
|
33
|
+
return this.width * this.height;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var Rect = class Rect {
|
|
37
|
+
x;
|
|
38
|
+
y;
|
|
39
|
+
width;
|
|
40
|
+
height;
|
|
41
|
+
constructor(x = 0, y = 0, width = 0, height = 0) {
|
|
42
|
+
this.x = x;
|
|
43
|
+
this.y = y;
|
|
44
|
+
this.width = width;
|
|
45
|
+
this.height = height;
|
|
46
|
+
}
|
|
47
|
+
get maxX() {
|
|
48
|
+
return this.x + this.width;
|
|
49
|
+
}
|
|
50
|
+
get maxY() {
|
|
51
|
+
return this.y + this.height;
|
|
52
|
+
}
|
|
53
|
+
get area() {
|
|
54
|
+
return this.width * this.height;
|
|
55
|
+
}
|
|
56
|
+
get topLeft() {
|
|
57
|
+
return new Point(this.x, this.y);
|
|
58
|
+
}
|
|
59
|
+
get topRight() {
|
|
60
|
+
return new Point(this.maxX, this.y);
|
|
61
|
+
}
|
|
62
|
+
get bottomLeft() {
|
|
63
|
+
return new Point(this.x, this.maxY);
|
|
64
|
+
}
|
|
65
|
+
get bottomRight() {
|
|
66
|
+
return new Point(this.maxX, this.maxY);
|
|
67
|
+
}
|
|
68
|
+
intersects(rect) {
|
|
69
|
+
return this.x <= rect.maxX && rect.x <= this.maxX && this.y <= rect.maxY && rect.y <= this.maxY;
|
|
70
|
+
}
|
|
71
|
+
containsRect(rect) {
|
|
72
|
+
return this.x <= rect.x && this.y <= rect.y && this.maxX >= rect.maxX && this.maxY >= rect.maxY;
|
|
73
|
+
}
|
|
74
|
+
containsPoint(point) {
|
|
75
|
+
return this.x <= point.x && this.y <= point.y && this.maxX >= point.x && this.maxY >= point.y;
|
|
76
|
+
}
|
|
77
|
+
union(other) {
|
|
78
|
+
const x = Math.min(this.x, other.x);
|
|
79
|
+
const y = Math.min(this.y, other.y);
|
|
80
|
+
return new Rect(x, y, Math.max(this.maxX, other.maxX) - x, Math.max(this.maxY, other.maxY) - y);
|
|
81
|
+
}
|
|
82
|
+
intersection(other) {
|
|
83
|
+
if (!this.intersects(other)) return new Rect(0, 0, 0, 0);
|
|
84
|
+
const x = Math.max(this.x, other.x);
|
|
85
|
+
const y = Math.max(this.y, other.y);
|
|
86
|
+
return new Rect(x, y, Math.min(this.maxX, other.maxX) - x, Math.min(this.maxY, other.maxY) - y);
|
|
87
|
+
}
|
|
88
|
+
copy() {
|
|
89
|
+
return new Rect(this.x, this.y, this.width, this.height);
|
|
90
|
+
}
|
|
91
|
+
equals(rect) {
|
|
92
|
+
return this.x === rect.x && this.y === rect.y && this.width === rect.width && this.height === rect.height;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var LayoutInfo = class LayoutInfo {
|
|
96
|
+
type;
|
|
97
|
+
key;
|
|
98
|
+
rect;
|
|
99
|
+
parentKey = null;
|
|
100
|
+
content = null;
|
|
101
|
+
estimatedSize = false;
|
|
102
|
+
isSticky = false;
|
|
103
|
+
opacity = 1;
|
|
104
|
+
transform = null;
|
|
105
|
+
zIndex = 0;
|
|
106
|
+
allowOverflow = false;
|
|
107
|
+
constructor(type, key, rect) {
|
|
108
|
+
this.type = type;
|
|
109
|
+
this.key = key;
|
|
110
|
+
this.rect = rect;
|
|
111
|
+
}
|
|
112
|
+
copy() {
|
|
113
|
+
const copy = new LayoutInfo(this.type, this.key, this.rect.copy());
|
|
114
|
+
copy.parentKey = this.parentKey;
|
|
115
|
+
copy.content = this.content;
|
|
116
|
+
copy.estimatedSize = this.estimatedSize;
|
|
117
|
+
copy.isSticky = this.isSticky;
|
|
118
|
+
copy.opacity = this.opacity;
|
|
119
|
+
copy.transform = this.transform;
|
|
120
|
+
copy.zIndex = this.zIndex;
|
|
121
|
+
copy.allowOverflow = this.allowOverflow;
|
|
122
|
+
return copy;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var Layout = class {
|
|
126
|
+
virtualizer = null;
|
|
127
|
+
shouldInvalidate(newRect, oldRect) {
|
|
128
|
+
return newRect.width !== oldRect.width || newRect.height !== oldRect.height;
|
|
129
|
+
}
|
|
130
|
+
shouldInvalidateLayoutOptions(newOptions, oldOptions) {
|
|
131
|
+
return newOptions !== oldOptions;
|
|
132
|
+
}
|
|
133
|
+
update(_context) {}
|
|
134
|
+
getItemRect(key) {
|
|
135
|
+
return this.getLayoutInfo(key)?.rect ?? null;
|
|
136
|
+
}
|
|
137
|
+
getVisibleRect() {
|
|
138
|
+
return this.virtualizer?.visibleRect ?? new Rect();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
//#endregion
|
|
142
|
+
export { Layout, LayoutInfo, Point, Rect, Size };
|
|
143
|
+
|
|
144
|
+
//# sourceMappingURL=Layout.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layout.jsx","names":[],"sources":["../../src/virtualizer/Layout.ts"],"sourcesContent":["import type { Key } from \"@proyecto-viviana/solid-stately\";\n\nexport interface InvalidationContext<O = unknown> {\n contentChanged?: boolean;\n offsetChanged?: boolean;\n sizeChanged?: boolean;\n itemSizeChanged?: boolean;\n layoutOptionsChanged?: boolean;\n layoutOptions?: O;\n}\n\nexport class Point {\n constructor(\n public x = 0,\n public y = 0,\n ) {}\n copy(): Point {\n return new Point(this.x, this.y);\n }\n equals(point: Point): boolean {\n return this.x === point.x && this.y === point.y;\n }\n isOrigin(): boolean {\n return this.x === 0 && this.y === 0;\n }\n}\n\nexport class Size {\n width: number;\n height: number;\n\n constructor(width = 0, height = 0) {\n this.width = Math.max(0, width);\n this.height = Math.max(0, height);\n }\n\n copy(): Size {\n return new Size(this.width, this.height);\n }\n\n equals(other: Size): boolean {\n return this.width === other.width && this.height === other.height;\n }\n\n get area(): number {\n return this.width * this.height;\n }\n}\n\nexport class Rect {\n constructor(\n public x = 0,\n public y = 0,\n public width = 0,\n public height = 0,\n ) {}\n\n get maxX(): number {\n return this.x + this.width;\n }\n\n get maxY(): number {\n return this.y + this.height;\n }\n\n get area(): number {\n return this.width * this.height;\n }\n\n get topLeft(): Point {\n return new Point(this.x, this.y);\n }\n\n get topRight(): Point {\n return new Point(this.maxX, this.y);\n }\n\n get bottomLeft(): Point {\n return new Point(this.x, this.maxY);\n }\n\n get bottomRight(): Point {\n return new Point(this.maxX, this.maxY);\n }\n\n intersects(rect: Rect): boolean {\n return this.x <= rect.maxX && rect.x <= this.maxX && this.y <= rect.maxY && rect.y <= this.maxY;\n }\n\n containsRect(rect: Rect): boolean {\n return this.x <= rect.x && this.y <= rect.y && this.maxX >= rect.maxX && this.maxY >= rect.maxY;\n }\n\n containsPoint(point: Point): boolean {\n return this.x <= point.x && this.y <= point.y && this.maxX >= point.x && this.maxY >= point.y;\n }\n\n union(other: Rect): Rect {\n const x = Math.min(this.x, other.x);\n const y = Math.min(this.y, other.y);\n const width = Math.max(this.maxX, other.maxX) - x;\n const height = Math.max(this.maxY, other.maxY) - y;\n return new Rect(x, y, width, height);\n }\n\n intersection(other: Rect): Rect {\n if (!this.intersects(other)) {\n return new Rect(0, 0, 0, 0);\n }\n const x = Math.max(this.x, other.x);\n const y = Math.max(this.y, other.y);\n const width = Math.min(this.maxX, other.maxX) - x;\n const height = Math.min(this.maxY, other.maxY) - y;\n return new Rect(x, y, width, height);\n }\n\n copy(): Rect {\n return new Rect(this.x, this.y, this.width, this.height);\n }\n\n equals(rect: Rect): boolean {\n return (\n this.x === rect.x &&\n this.y === rect.y &&\n this.width === rect.width &&\n this.height === rect.height\n );\n }\n}\n\nexport class LayoutInfo {\n parentKey: Key | null = null;\n content: unknown = null;\n estimatedSize = false;\n isSticky = false;\n opacity = 1;\n transform: string | null = null;\n zIndex = 0;\n allowOverflow = false;\n\n constructor(\n public type: string,\n public key: Key,\n public rect: Rect,\n ) {}\n\n copy(): LayoutInfo {\n const copy = new LayoutInfo(this.type, this.key, this.rect.copy());\n copy.parentKey = this.parentKey;\n copy.content = this.content;\n copy.estimatedSize = this.estimatedSize;\n copy.isSticky = this.isSticky;\n copy.opacity = this.opacity;\n copy.transform = this.transform;\n copy.zIndex = this.zIndex;\n copy.allowOverflow = this.allowOverflow;\n return copy;\n }\n}\n\ninterface VirtualizerLike {\n visibleRect: Rect;\n}\n\nexport abstract class Layout<T extends object = object, O = unknown> {\n virtualizer: VirtualizerLike | null = null;\n\n abstract getVisibleLayoutInfos(rect: Rect): LayoutInfo[];\n abstract getLayoutInfo(key: Key): LayoutInfo | null;\n abstract getContentSize(): Size;\n\n shouldInvalidate(newRect: Rect, oldRect: Rect): boolean {\n return newRect.width !== oldRect.width || newRect.height !== oldRect.height;\n }\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return newOptions !== oldOptions;\n }\n\n update(_context: InvalidationContext<O>): void {}\n\n updateItemSize?(_key: Key, _size: Size): boolean;\n getDropTargetLayoutInfo?(_target: unknown): LayoutInfo | null;\n\n protected getItemRect(key: Key): Rect | null {\n return this.getLayoutInfo(key)?.rect ?? null;\n }\n\n getVisibleRect(): Rect {\n return this.virtualizer?.visibleRect ?? new Rect();\n }\n}\n"],"mappings":";AAWA,IAAa,QAAb,MAAa,MAAM;CAER;CACA;CAFT,YACE,IAAW,GACX,IAAW,GACX;EAFO,KAAA,IAAA;EACA,KAAA,IAAA;CACN;CACH,OAAc;EACZ,OAAO,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC;CACjC;CACA,OAAO,OAAuB;EAC5B,OAAO,KAAK,MAAM,MAAM,KAAK,KAAK,MAAM,MAAM;CAChD;CACA,WAAoB;EAClB,OAAO,KAAK,MAAM,KAAK,KAAK,MAAM;CACpC;AACF;AAEA,IAAa,OAAb,MAAa,KAAK;CAChB;CACA;CAEA,YAAY,QAAQ,GAAG,SAAS,GAAG;EACjC,KAAK,QAAQ,KAAK,IAAI,GAAG,KAAK;EAC9B,KAAK,SAAS,KAAK,IAAI,GAAG,MAAM;CAClC;CAEA,OAAa;EACX,OAAO,IAAI,KAAK,KAAK,OAAO,KAAK,MAAM;CACzC;CAEA,OAAO,OAAsB;EAC3B,OAAO,KAAK,UAAU,MAAM,SAAS,KAAK,WAAW,MAAM;CAC7D;CAEA,IAAI,OAAe;EACjB,OAAO,KAAK,QAAQ,KAAK;CAC3B;AACF;AAEA,IAAa,OAAb,MAAa,KAAK;CAEP;CACA;CACA;CACA;CAJT,YACE,IAAW,GACX,IAAW,GACX,QAAe,GACf,SAAgB,GAChB;EAJO,KAAA,IAAA;EACA,KAAA,IAAA;EACA,KAAA,QAAA;EACA,KAAA,SAAA;CACN;CAEH,IAAI,OAAe;EACjB,OAAO,KAAK,IAAI,KAAK;CACvB;CAEA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