@proyecto-viviana/solidaria-components 0.2.5 → 0.2.9
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/LICENSE +21 -0
- package/dist/ActionBar.d.ts +71 -0
- package/dist/ActionBar.d.ts.map +1 -0
- package/dist/ActionGroup.d.ts +74 -0
- package/dist/ActionGroup.d.ts.map +1 -0
- package/dist/Alert.d.ts +70 -0
- package/dist/Alert.d.ts.map +1 -0
- package/dist/Breadcrumbs.d.ts +10 -2
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Button.d.ts +4 -0
- package/dist/Button.d.ts.map +1 -1
- package/dist/Calendar.d.ts +13 -0
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Checkbox.d.ts +2 -2
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Collection.d.ts +125 -0
- package/dist/Collection.d.ts.map +1 -0
- package/dist/Color.d.ts +114 -2
- package/dist/Color.d.ts.map +1 -1
- package/dist/ColorEditor.d.ts +42 -0
- package/dist/ColorEditor.d.ts.map +1 -0
- package/dist/ComboBox.d.ts +64 -0
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/ContextualHelpTrigger.d.ts +40 -0
- package/dist/ContextualHelpTrigger.d.ts.map +1 -0
- package/dist/DateField.d.ts +27 -2
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DatePicker.d.ts +67 -2
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Disclosure.d.ts +2 -0
- package/dist/Disclosure.d.ts.map +1 -1
- package/dist/DragAndDrop.d.ts +80 -0
- package/dist/DragAndDrop.d.ts.map +1 -0
- package/dist/DragPreview.d.ts +14 -0
- package/dist/DragPreview.d.ts.map +1 -0
- package/dist/DropZone.d.ts +27 -0
- package/dist/DropZone.d.ts.map +1 -0
- package/dist/FieldError.d.ts +23 -0
- package/dist/FieldError.d.ts.map +1 -0
- package/dist/FileTrigger.d.ts +26 -0
- package/dist/FileTrigger.d.ts.map +1 -0
- package/dist/Focusable.d.ts +27 -0
- package/dist/Focusable.d.ts.map +1 -0
- package/dist/Form.d.ts +27 -0
- package/dist/Form.d.ts.map +1 -0
- package/dist/GridList.d.ts +40 -1
- package/dist/GridList.d.ts.map +1 -1
- package/dist/Icon.d.ts +57 -0
- package/dist/Icon.d.ts.map +1 -0
- package/dist/Keyboard.d.ts +13 -0
- package/dist/Keyboard.d.ts.map +1 -0
- package/dist/Link.d.ts.map +1 -1
- package/dist/ListBox.d.ts +43 -1
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/ListDropTargetDelegate.d.ts +38 -0
- package/dist/ListDropTargetDelegate.d.ts.map +1 -0
- package/dist/Menu.d.ts +20 -2
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Meter.d.ts +2 -2
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Modal.d.ts +2 -0
- package/dist/Modal.d.ts.map +1 -1
- package/dist/NumberField.d.ts +2 -0
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/Popover.d.ts +4 -2
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Pressable.d.ts +27 -0
- package/dist/Pressable.d.ts.map +1 -0
- package/dist/ProgressBar.d.ts +2 -2
- package/dist/ProgressBar.d.ts.map +1 -1
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RangeCalendar.d.ts +5 -0
- package/dist/RangeCalendar.d.ts.map +1 -1
- package/dist/RouterProvider.d.ts +75 -0
- package/dist/RouterProvider.d.ts.map +1 -0
- package/dist/SearchField.d.ts +2 -3
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/Select.d.ts +11 -0
- package/dist/Select.d.ts.map +1 -1
- package/dist/SelectionIndicator.d.ts +30 -0
- package/dist/SelectionIndicator.d.ts.map +1 -0
- package/dist/SharedElementTransition.d.ts +39 -0
- package/dist/SharedElementTransition.d.ts.map +1 -0
- package/dist/Slider.d.ts +6 -3
- package/dist/Slider.d.ts.map +1 -1
- package/dist/Table.d.ts +39 -0
- package/dist/Table.d.ts.map +1 -1
- package/dist/Tabs.d.ts +4 -3
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/TagGroup.d.ts +12 -2
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/Text.d.ts +10 -0
- package/dist/Text.d.ts.map +1 -0
- package/dist/TextField.d.ts +4 -0
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TimeField.d.ts +26 -1
- package/dist/TimeField.d.ts.map +1 -1
- package/dist/Toast.d.ts.map +1 -1
- package/dist/ToggleButton.d.ts +30 -0
- package/dist/ToggleButton.d.ts.map +1 -0
- package/dist/ToggleButtonGroup.d.ts +33 -0
- package/dist/ToggleButtonGroup.d.ts.map +1 -0
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Tooltip.d.ts +9 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tree.d.ts +44 -2
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Virtualizer.d.ts +61 -0
- package/dist/Virtualizer.d.ts.map +1 -0
- package/dist/VirtualizerLayouts.d.ts +82 -0
- package/dist/VirtualizerLayouts.d.ts.map +1 -0
- package/dist/VisuallyHidden.d.ts +3 -1
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/contexts.d.ts +1 -0
- package/dist/contexts.d.ts.map +1 -1
- package/dist/index.d.ts +57 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13961 -5946
- package/dist/index.js.map +1 -7
- package/dist/index.ssr.js +9612 -2401
- package/dist/index.ssr.js.map +1 -7
- package/dist/useDragAndDrop.d.ts +93 -0
- package/dist/useDragAndDrop.d.ts.map +1 -0
- package/dist/utils.d.ts +7 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/virtualizer/Layout.d.ts +79 -0
- package/dist/virtualizer/Layout.d.ts.map +1 -0
- package/package.json +8 -6
- package/src/ActionBar.tsx +248 -0
- package/src/ActionGroup.tsx +285 -0
- package/src/Alert.tsx +177 -0
- package/src/Autocomplete.tsx +1 -1
- package/src/Breadcrumbs.tsx +103 -17
- package/src/Button.tsx +65 -21
- package/src/Calendar.tsx +179 -53
- package/src/Checkbox.tsx +1 -2
- package/src/Collection.tsx +341 -0
- package/src/Color.tsx +652 -34
- package/src/ColorEditor.tsx +231 -0
- package/src/ComboBox.tsx +315 -81
- package/src/ContextualHelpTrigger.tsx +183 -0
- package/src/DateField.tsx +93 -19
- package/src/DatePicker.tsx +495 -25
- package/src/Dialog.tsx +40 -9
- package/src/Disclosure.tsx +33 -27
- package/src/DragAndDrop.tsx +334 -0
- package/src/DragPreview.tsx +45 -0
- package/src/DropZone.tsx +213 -0
- package/src/FieldError.tsx +67 -0
- package/src/FileTrigger.tsx +83 -0
- package/src/Focusable.tsx +106 -0
- package/src/Form.tsx +85 -0
- package/src/GridList.tsx +379 -41
- package/src/Icon.tsx +154 -0
- package/src/Keyboard.tsx +26 -0
- package/src/Link.tsx +14 -1
- package/src/ListBox.tsx +484 -33
- package/src/ListDropTargetDelegate.ts +282 -0
- package/src/Menu.tsx +388 -35
- package/src/Meter.tsx +7 -3
- package/src/Modal.tsx +32 -4
- package/src/NumberField.tsx +163 -43
- package/src/Popover.tsx +136 -180
- package/src/Pressable.tsx +108 -0
- package/src/ProgressBar.tsx +7 -3
- package/src/RadioGroup.tsx +35 -25
- package/src/RangeCalendar.tsx +100 -68
- package/src/RouterProvider.tsx +240 -0
- package/src/SearchField.tsx +142 -34
- package/src/Select.tsx +221 -73
- package/src/SelectionIndicator.tsx +105 -0
- package/src/SharedElementTransition.tsx +258 -0
- package/src/Slider.tsx +16 -6
- package/src/Table.tsx +417 -57
- package/src/Tabs.tsx +68 -35
- package/src/TagGroup.tsx +121 -36
- package/src/Text.tsx +18 -0
- package/src/TextField.tsx +25 -8
- package/src/TimeField.tsx +101 -151
- package/src/Toast.tsx +108 -14
- package/src/ToggleButton.tsx +159 -0
- package/src/ToggleButtonGroup.tsx +136 -0
- package/src/Toolbar.tsx +14 -8
- package/src/Tooltip.tsx +108 -19
- package/src/Tree.tsx +1143 -87
- package/src/Virtualizer.tsx +702 -0
- package/src/VirtualizerLayouts.ts +265 -0
- package/src/VisuallyHidden.tsx +15 -21
- package/src/contexts.ts +1 -0
- package/src/index.ts +1057 -620
- package/src/useDragAndDrop.ts +351 -0
- package/src/utils.tsx +37 -3
- package/src/virtualizer/Layout.ts +200 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drag and drop compatibility hook for collection components.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors RAC's `useDragAndDrop` shape while delegating to Solid
|
|
5
|
+
* state and aria primitives.
|
|
6
|
+
*/
|
|
7
|
+
import type { Accessor, JSX } from 'solid-js';
|
|
8
|
+
import { DragPreview } from './DragPreview';
|
|
9
|
+
import { ListDropTargetDelegate } from './ListDropTargetDelegate';
|
|
10
|
+
import { type DraggableCollectionOptions, type DraggableCollectionAria, type DraggableItemOptions, type DraggableItemAria, type DroppableCollectionOptions, type DroppableCollectionAria, type DroppableItemOptions, type DroppableItemAria, type DropTargetDelegate as AriaDropTargetDelegate } from '@proyecto-viviana/solidaria';
|
|
11
|
+
import { type DragItem, type DragPreviewRenderer, type DraggableCollectionProps, type DraggableCollectionState, type DraggableCollectionStateOptions, type DropTarget, type DroppableCollectionProps, type DroppableCollectionState, type DroppableCollectionStateOptions } from '@proyecto-viviana/solid-stately';
|
|
12
|
+
interface DraggableCollectionStateOpts<T = object> extends Omit<DraggableCollectionStateOptions<T>, 'getItems'> {
|
|
13
|
+
items?: T[];
|
|
14
|
+
}
|
|
15
|
+
interface DragHooks<T = object> {
|
|
16
|
+
useDraggableCollectionState?: (props: DraggableCollectionStateOpts<T>) => DraggableCollectionState;
|
|
17
|
+
useDraggableCollection?: (props: Omit<DraggableCollectionOptions, 'ref'>, state: DraggableCollectionState, ref: Accessor<HTMLElement | null>) => DraggableCollectionAria;
|
|
18
|
+
useDraggableItem?: (props: DraggableItemOptions, state: DraggableCollectionState) => DraggableItemAria;
|
|
19
|
+
DragPreview?: typeof DragPreview;
|
|
20
|
+
renderDragPreview?: DragAndDropOptions<T>['renderDragPreview'];
|
|
21
|
+
isVirtualDragging?: () => boolean;
|
|
22
|
+
}
|
|
23
|
+
interface DropHooks {
|
|
24
|
+
useDroppableCollectionState?: (props: DroppableCollectionStateOptions) => DroppableCollectionState;
|
|
25
|
+
useDroppableCollection?: (props: Omit<DroppableCollectionOptions, 'ref'>, state: DroppableCollectionState, ref: Accessor<HTMLElement | null>) => DroppableCollectionAria;
|
|
26
|
+
useDroppableItem?: (options: Omit<DroppableItemOptions, 'ref'>, state: DroppableCollectionState, ref: Accessor<HTMLElement | null>) => DroppableItemAria;
|
|
27
|
+
useDropIndicator?: (props: {
|
|
28
|
+
target: DropTarget;
|
|
29
|
+
}, state: DroppableCollectionState, ref: Accessor<HTMLElement | null>) => {
|
|
30
|
+
dropIndicatorProps: JSX.HTMLAttributes<HTMLElement>;
|
|
31
|
+
isDropTarget: boolean;
|
|
32
|
+
isHidden: boolean;
|
|
33
|
+
};
|
|
34
|
+
renderDropIndicator?: (target: DropTarget) => JSX.Element;
|
|
35
|
+
dropTargetDelegate?: AriaDropTargetDelegate;
|
|
36
|
+
ListDropTargetDelegate?: typeof ListDropTargetDelegate;
|
|
37
|
+
}
|
|
38
|
+
export type DragAndDropHooks<T = object> = DragHooks<T> & DropHooks;
|
|
39
|
+
export interface DragAndDrop<T = object> {
|
|
40
|
+
/** Drag and drop hooks for the collection element. */
|
|
41
|
+
dragAndDropHooks: DragAndDropHooks<T>;
|
|
42
|
+
}
|
|
43
|
+
export interface DragAndDropOptions<T = object> extends Partial<Omit<DraggableCollectionProps<T>, 'preview'>>, Partial<DroppableCollectionProps> {
|
|
44
|
+
/**
|
|
45
|
+
* Optional keyboard delegate forwarded to the collection droppable hook.
|
|
46
|
+
*/
|
|
47
|
+
keyboardDelegate?: DroppableCollectionOptions['keyboardDelegate'];
|
|
48
|
+
/**
|
|
49
|
+
* Optional keydown handler composed with collection droppable keyboard behavior.
|
|
50
|
+
*/
|
|
51
|
+
onKeyDown?: DroppableCollectionOptions['onKeyDown'];
|
|
52
|
+
/**
|
|
53
|
+
* A function that returns the items being dragged.
|
|
54
|
+
* If omitted, draggable hooks are not added.
|
|
55
|
+
*/
|
|
56
|
+
getItems?: (keys: Set<string | number>, items: T[]) => DragItem[];
|
|
57
|
+
/**
|
|
58
|
+
* Optional custom drag preview renderer.
|
|
59
|
+
*/
|
|
60
|
+
renderDragPreview?: (items: DragItem[]) => JSX.Element | {
|
|
61
|
+
element: JSX.Element;
|
|
62
|
+
x: number;
|
|
63
|
+
y: number;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Optional drop indicator renderer for collection components.
|
|
67
|
+
*/
|
|
68
|
+
renderDropIndicator?: (target: DropTarget) => JSX.Element;
|
|
69
|
+
/**
|
|
70
|
+
* Optional custom drop target delegate.
|
|
71
|
+
*/
|
|
72
|
+
dropTargetDelegate?: AriaDropTargetDelegate;
|
|
73
|
+
/**
|
|
74
|
+
* Optional drag preview ref.
|
|
75
|
+
*/
|
|
76
|
+
preview?: {
|
|
77
|
+
current: DragPreviewRenderer | null;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Optional item snapshot used by draggable state `getItems`.
|
|
81
|
+
*/
|
|
82
|
+
items?: T[];
|
|
83
|
+
/**
|
|
84
|
+
* Disable both drag and drop behavior.
|
|
85
|
+
*/
|
|
86
|
+
isDisabled?: boolean;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Provides hooks to enable drag-and-drop behavior for collection components.
|
|
90
|
+
*/
|
|
91
|
+
export declare function useDragAndDrop<T = object>(options?: DragAndDropOptions<T>): DragAndDrop<T>;
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=useDragAndDrop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDragAndDrop.d.ts","sourceRoot":"","sources":["../src/useD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,OAAO,GAAE,kBAAkB,CAAC,CAAC,CAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAqN9F"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Utility functions for solidaria-components
|
|
3
3
|
* Port of react-aria-components/src/utils.tsx
|
|
4
4
|
*/
|
|
5
|
-
import { type JSX, type Accessor, type FlowComponent, createContext } from 'solid-js';
|
|
5
|
+
import { type JSX, type Accessor, type FlowComponent, type ParentComponent, createContext } from 'solid-js';
|
|
6
6
|
/**
|
|
7
7
|
* Render props pattern - children can be a function that receives state
|
|
8
8
|
*/
|
|
@@ -33,6 +33,7 @@ export interface SlotProps {
|
|
|
33
33
|
/** A slot name for the component. */
|
|
34
34
|
slot?: string;
|
|
35
35
|
}
|
|
36
|
+
export declare const DEFAULT_SLOT = "default";
|
|
36
37
|
/**
|
|
37
38
|
* Return type for useRenderProps
|
|
38
39
|
*/
|
|
@@ -69,6 +70,7 @@ export interface RenderPropsResult<T> {
|
|
|
69
70
|
export declare function useRenderProps<T extends object>(props: RenderPropsBase<T> & {
|
|
70
71
|
defaultClassName?: string;
|
|
71
72
|
}, values: Accessor<T>): RenderPropsResult<T>;
|
|
73
|
+
export declare function composeRenderProps<T extends object>(base: RenderPropsBase<T> | undefined, override: RenderPropsBase<T> | undefined): RenderPropsBase<T>;
|
|
72
74
|
/**
|
|
73
75
|
* Context value that can be null or the actual value
|
|
74
76
|
*/
|
|
@@ -81,6 +83,10 @@ export declare function createSlottedContext<T>(): import("solid-js").Context<T
|
|
|
81
83
|
* Use context with null check
|
|
82
84
|
*/
|
|
83
85
|
export declare function useSlottedContext<T>(context: ReturnType<typeof createContext<T | null>>): T | null;
|
|
86
|
+
export declare function useContextProps<TProps extends object, TRef>(props: TProps, ref: TRef, context?: ContextValue<Partial<TProps>>): [TProps, TRef];
|
|
87
|
+
export declare const Provider: ParentComponent<{
|
|
88
|
+
values: Array<[ReturnType<typeof createContext<unknown>>, unknown]>;
|
|
89
|
+
}>;
|
|
84
90
|
/**
|
|
85
91
|
* Converts boolean state values to data attributes
|
|
86
92
|
*/
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,KAAK,GAAG,EACR,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,aAAa,EAMd,MAAM,UAAU,CAAC;AAOlB;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,GAAG,CAAC,aAAa,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,GAAG,CAAC,aAAa,CAAC,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,yFAAyF;IACzF,QAAQ,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC7B,yGAAyG;IACzG,KAAK,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAC/B,wGAAwG;IACxG,KAAK,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,KAAK,GAAG,EACR,KAAK,QAAQ,EACb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AAS,GAAG,EAAE,GAAG,SAAS,CAEnE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,EACzF,MAAM,EAAE,CAAC,GACR,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAYpC;AAUD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAUnF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvE,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,CAAC,CA4BH;AAMD,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;IACtB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,eAAe,CAmBrD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,IAAI,QAAQ,CAAC,OAAO,CAAC,CAiBjD"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Key } from '@proyecto-viviana/solid-stately';
|
|
2
|
+
export interface InvalidationContext<O = unknown> {
|
|
3
|
+
contentChanged?: boolean;
|
|
4
|
+
offsetChanged?: boolean;
|
|
5
|
+
sizeChanged?: boolean;
|
|
6
|
+
itemSizeChanged?: boolean;
|
|
7
|
+
layoutOptionsChanged?: boolean;
|
|
8
|
+
layoutOptions?: O;
|
|
9
|
+
}
|
|
10
|
+
export declare class Point {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
constructor(x?: number, y?: number);
|
|
14
|
+
copy(): Point;
|
|
15
|
+
equals(point: Point): boolean;
|
|
16
|
+
isOrigin(): boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class Size {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
constructor(width?: number, height?: number);
|
|
22
|
+
copy(): Size;
|
|
23
|
+
equals(other: Size): boolean;
|
|
24
|
+
get area(): number;
|
|
25
|
+
}
|
|
26
|
+
export declare class Rect {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
constructor(x?: number, y?: number, width?: number, height?: number);
|
|
32
|
+
get maxX(): number;
|
|
33
|
+
get maxY(): number;
|
|
34
|
+
get area(): number;
|
|
35
|
+
get topLeft(): Point;
|
|
36
|
+
get topRight(): Point;
|
|
37
|
+
get bottomLeft(): Point;
|
|
38
|
+
get bottomRight(): Point;
|
|
39
|
+
intersects(rect: Rect): boolean;
|
|
40
|
+
containsRect(rect: Rect): boolean;
|
|
41
|
+
containsPoint(point: Point): boolean;
|
|
42
|
+
union(other: Rect): Rect;
|
|
43
|
+
intersection(other: Rect): Rect;
|
|
44
|
+
copy(): Rect;
|
|
45
|
+
equals(rect: Rect): boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare class LayoutInfo {
|
|
48
|
+
type: string;
|
|
49
|
+
key: Key;
|
|
50
|
+
rect: Rect;
|
|
51
|
+
parentKey: Key | null;
|
|
52
|
+
content: unknown;
|
|
53
|
+
estimatedSize: boolean;
|
|
54
|
+
isSticky: boolean;
|
|
55
|
+
opacity: number;
|
|
56
|
+
transform: string | null;
|
|
57
|
+
zIndex: number;
|
|
58
|
+
allowOverflow: boolean;
|
|
59
|
+
constructor(type: string, key: Key, rect: Rect);
|
|
60
|
+
copy(): LayoutInfo;
|
|
61
|
+
}
|
|
62
|
+
interface VirtualizerLike {
|
|
63
|
+
visibleRect: Rect;
|
|
64
|
+
}
|
|
65
|
+
export declare abstract class Layout<T extends object = object, O = unknown> {
|
|
66
|
+
virtualizer: VirtualizerLike | null;
|
|
67
|
+
abstract getVisibleLayoutInfos(rect: Rect): LayoutInfo[];
|
|
68
|
+
abstract getLayoutInfo(key: Key): LayoutInfo | null;
|
|
69
|
+
abstract getContentSize(): Size;
|
|
70
|
+
shouldInvalidate(newRect: Rect, oldRect: Rect): boolean;
|
|
71
|
+
shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean;
|
|
72
|
+
update(_context: InvalidationContext<O>): void;
|
|
73
|
+
updateItemSize?(_key: Key, _size: Size): boolean;
|
|
74
|
+
getDropTargetLayoutInfo?(_target: unknown): LayoutInfo | null;
|
|
75
|
+
protected getItemRect(key: Key): Rect | null;
|
|
76
|
+
getVisibleRect(): Rect;
|
|
77
|
+
}
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=Layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../src/virtualizer/Layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,OAAO;IAC9C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,aAAa,CAAC,EAAE,CAAC,CAAC;CACnB;AAED,qBAAa,KAAK;IACG,CAAC;IAAa,CAAC;gBAAf,CAAC,SAAI,EAAS,CAAC,SAAI;IACtC,IAAI,IAAI,KAAK;IAGb,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAG7B,QAAQ,IAAI,OAAO;CAGpB;AAED,qBAA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S;gBAEH,IAAI,EAAE,MAAM,EAAS,GAAG,EAAE,GAAG,EAAS,IAAI,EAAE,IAAI;IAEnE,IAAI,IAAI,UAAU;CAYnB;AAED,UAAU,eAAe;IACvB,WAAW,EAAE,IAAI,CAAC;CACnB;AAED,8BAAsB,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,OAAO;IACjE,WAAW,EAAE,eAAe,GAAG,IAAI,CAAQ;IAE3C,QAAQ,CAAC,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,EAAE;IACxD,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,GAAG,IAAI;IACnD,QAAQ,CAAC,cAAc,IAAI,IAAI;IAE/B,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,OAAO;IAIvD,6BAA6B,CAAC,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO;IAIpE,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,IAAI;IAE9C,cAAc,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,GAAG,OAAO;IAChD,uBAAuB,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI;IAE7D,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;IAI5C,cAAc,IAAI,IAAI;CAGvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proyecto-viviana/solidaria-components",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Pre-wired headless components for SolidJS - port of react-aria-components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,17 +22,18 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsup && rm -f tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json",
|
|
24
24
|
"dev": "tsup --watch",
|
|
25
|
-
"prepublishOnly": "echo 'Use
|
|
25
|
+
"prepublishOnly": "echo 'Use the root Changesets npm release workflow'"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@proyecto-viviana/
|
|
28
|
+
"@internationalized/date": "^3.8.0",
|
|
29
|
+
"@proyecto-viviana/solidaria": "^0.2.8",
|
|
30
|
+
"@proyecto-viviana/solid-stately": "^0.2.7"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
33
|
"solid-js": "^1.9.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"solid-js": "^1.9.
|
|
36
|
+
"solid-js": "^1.9.11"
|
|
36
37
|
},
|
|
37
38
|
"keywords": [
|
|
38
39
|
"solid",
|
|
@@ -45,7 +46,8 @@
|
|
|
45
46
|
"license": "MIT",
|
|
46
47
|
"repository": {
|
|
47
48
|
"type": "git",
|
|
48
|
-
"url": "https://github.com/proyecto-viviana/proyecto-viviana"
|
|
49
|
+
"url": "git+https://github.com/proyecto-viviana/proyecto-viviana.git",
|
|
50
|
+
"directory": "packages/solidaria-components"
|
|
49
51
|
},
|
|
50
52
|
"publishConfig": {
|
|
51
53
|
"access": "public"
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionBar component for solidaria-components
|
|
3
|
+
*
|
|
4
|
+
* Headless action bar that appears when items are selected in a collection.
|
|
5
|
+
* Shows a selection count, clear button, and action buttons.
|
|
6
|
+
*
|
|
7
|
+
* No RAC headless equivalent — this is a thin component layer that ties
|
|
8
|
+
* selection state to visibility and keyboard behavior.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
type JSX,
|
|
13
|
+
type ParentProps,
|
|
14
|
+
Show,
|
|
15
|
+
createContext,
|
|
16
|
+
createMemo,
|
|
17
|
+
createEffect,
|
|
18
|
+
splitProps,
|
|
19
|
+
useContext,
|
|
20
|
+
} from 'solid-js';
|
|
21
|
+
import { announce, createToolbar } from '@proyecto-viviana/solidaria';
|
|
22
|
+
import type { Key } from '@proyecto-viviana/solid-stately';
|
|
23
|
+
import {
|
|
24
|
+
type ClassNameOrFunction,
|
|
25
|
+
type StyleOrFunction,
|
|
26
|
+
type SlotProps,
|
|
27
|
+
useRenderProps,
|
|
28
|
+
filterDOMProps,
|
|
29
|
+
} from './utils';
|
|
30
|
+
|
|
31
|
+
// ============================================
|
|
32
|
+
// TYPES
|
|
33
|
+
// ============================================
|
|
34
|
+
|
|
35
|
+
export interface ActionBarRenderProps {
|
|
36
|
+
/** Whether the action bar is visible. */
|
|
37
|
+
isOpen: boolean;
|
|
38
|
+
/** The number of selected items. */
|
|
39
|
+
selectedItemCount: number | 'all';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ActionBarProps extends SlotProps {
|
|
43
|
+
/** The number of selected items. ActionBar is hidden when 0. */
|
|
44
|
+
selectedItemCount: number | 'all';
|
|
45
|
+
/** Callback when the clear button is pressed. */
|
|
46
|
+
onClearSelection: () => void;
|
|
47
|
+
/** Callback when an action is triggered. */
|
|
48
|
+
onAction?: (key: Key) => void;
|
|
49
|
+
/** The action buttons to display. */
|
|
50
|
+
children?: JSX.Element;
|
|
51
|
+
/** CSS class for the container. */
|
|
52
|
+
class?: ClassNameOrFunction<ActionBarRenderProps>;
|
|
53
|
+
/** Inline style for the container. */
|
|
54
|
+
style?: StyleOrFunction<ActionBarRenderProps>;
|
|
55
|
+
/** Accessible label for the action bar. @default 'Actions' */
|
|
56
|
+
'aria-label'?: string;
|
|
57
|
+
/** Identifies the element (or elements) that labels the action bar. */
|
|
58
|
+
'aria-labelledby'?: string;
|
|
59
|
+
/** Optional keydown handler on the action bar element. */
|
|
60
|
+
onKeyDown?: JSX.EventHandlerUnion<HTMLDivElement, KeyboardEvent>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ============================================
|
|
64
|
+
// CONTEXT
|
|
65
|
+
// ============================================
|
|
66
|
+
|
|
67
|
+
export interface ActionBarContextValue {
|
|
68
|
+
selectedItemCount: () => number | 'all';
|
|
69
|
+
onClearSelection: () => void;
|
|
70
|
+
onAction?: (key: Key) => void;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const ActionBarContext = createContext<ActionBarContextValue | null>(null);
|
|
74
|
+
|
|
75
|
+
export function useActionBarContext(): ActionBarContextValue | null {
|
|
76
|
+
return useContext(ActionBarContext);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ============================================
|
|
80
|
+
// ACTIONBAR COMPONENT
|
|
81
|
+
// ============================================
|
|
82
|
+
|
|
83
|
+
export function ActionBar(props: ActionBarProps): JSX.Element {
|
|
84
|
+
const [local, domProps] = splitProps(props, [
|
|
85
|
+
'selectedItemCount',
|
|
86
|
+
'onClearSelection',
|
|
87
|
+
'onAction',
|
|
88
|
+
'children',
|
|
89
|
+
'class',
|
|
90
|
+
'style',
|
|
91
|
+
'slot',
|
|
92
|
+
'aria-label',
|
|
93
|
+
'aria-labelledby',
|
|
94
|
+
'onKeyDown',
|
|
95
|
+
]);
|
|
96
|
+
|
|
97
|
+
const isOpen = () => local.selectedItemCount !== 0;
|
|
98
|
+
|
|
99
|
+
const { toolbarProps } = createToolbar({
|
|
100
|
+
orientation: 'horizontal',
|
|
101
|
+
get 'aria-label'() {
|
|
102
|
+
return local['aria-label'] ?? (local['aria-labelledby'] ? undefined : 'Actions');
|
|
103
|
+
},
|
|
104
|
+
get 'aria-labelledby'() {
|
|
105
|
+
return local['aria-labelledby'];
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
let wasOpen = false;
|
|
110
|
+
// Announce only when transitioning from closed -> open.
|
|
111
|
+
createEffect(() => {
|
|
112
|
+
const open = isOpen();
|
|
113
|
+
if (open && !wasOpen) {
|
|
114
|
+
announce('Actions available.');
|
|
115
|
+
}
|
|
116
|
+
wasOpen = open;
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Escape key to clear selection
|
|
120
|
+
const handleKeyDown: JSX.EventHandlerUnion<HTMLDivElement, KeyboardEvent> = (e) => {
|
|
121
|
+
const onKeyDown = local.onKeyDown as JSX.EventHandler<HTMLDivElement, KeyboardEvent> | undefined;
|
|
122
|
+
onKeyDown?.(e);
|
|
123
|
+
if (e.defaultPrevented) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (e.key === 'Escape' && isOpen()) {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
e.stopPropagation();
|
|
130
|
+
local.onClearSelection();
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const renderProps = useRenderProps(
|
|
135
|
+
{
|
|
136
|
+
children: undefined,
|
|
137
|
+
class: local.class,
|
|
138
|
+
style: local.style,
|
|
139
|
+
defaultClassName: 'solidaria-ActionBar',
|
|
140
|
+
},
|
|
141
|
+
() => ({
|
|
142
|
+
isOpen: isOpen(),
|
|
143
|
+
selectedItemCount: local.selectedItemCount,
|
|
144
|
+
})
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const filteredDOMProps = createMemo(() => filterDOMProps(domProps as Record<string, unknown>, { global: true }));
|
|
148
|
+
|
|
149
|
+
const contextValue = createMemo<ActionBarContextValue>(() => ({
|
|
150
|
+
selectedItemCount: () => local.selectedItemCount,
|
|
151
|
+
onClearSelection: local.onClearSelection,
|
|
152
|
+
onAction: local.onAction,
|
|
153
|
+
}));
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<Show when={isOpen()}>
|
|
157
|
+
<ActionBarContext.Provider value={contextValue()}>
|
|
158
|
+
<div
|
|
159
|
+
{...filteredDOMProps()}
|
|
160
|
+
{...toolbarProps}
|
|
161
|
+
class={renderProps.class()}
|
|
162
|
+
style={renderProps.style()}
|
|
163
|
+
slot={local.slot}
|
|
164
|
+
data-open={isOpen() || undefined}
|
|
165
|
+
onKeyDown={handleKeyDown}
|
|
166
|
+
>
|
|
167
|
+
{local.children}
|
|
168
|
+
</div>
|
|
169
|
+
</ActionBarContext.Provider>
|
|
170
|
+
</Show>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ============================================
|
|
175
|
+
// ACTIONBAR CONTAINER
|
|
176
|
+
// ============================================
|
|
177
|
+
|
|
178
|
+
export interface ActionBarContainerProps extends ParentProps {
|
|
179
|
+
class?: string;
|
|
180
|
+
style?: JSX.CSSProperties;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Container that positions a collection and its ActionBar.
|
|
185
|
+
*/
|
|
186
|
+
export function ActionBarContainer(props: ActionBarContainerProps): JSX.Element {
|
|
187
|
+
return (
|
|
188
|
+
<div
|
|
189
|
+
class={props.class ?? 'solidaria-ActionBarContainer'}
|
|
190
|
+
style={{ position: 'relative', ...props.style }}
|
|
191
|
+
>
|
|
192
|
+
{props.children}
|
|
193
|
+
</div>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// ============================================
|
|
198
|
+
// SELECTION COUNT
|
|
199
|
+
// ============================================
|
|
200
|
+
|
|
201
|
+
export interface ActionBarSelectionCountProps {
|
|
202
|
+
class?: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Displays the count of selected items.
|
|
207
|
+
*/
|
|
208
|
+
export function ActionBarSelectionCount(props: ActionBarSelectionCountProps): JSX.Element {
|
|
209
|
+
const ctx = useActionBarContext();
|
|
210
|
+
|
|
211
|
+
const text = () => {
|
|
212
|
+
if (!ctx) return '';
|
|
213
|
+
const count = ctx.selectedItemCount();
|
|
214
|
+
if (count === 'all') return 'All selected';
|
|
215
|
+
if (count === 0) return 'None selected';
|
|
216
|
+
return `${count} selected`;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
return <span class={props.class}>{text()}</span>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// ============================================
|
|
223
|
+
// CLEAR BUTTON
|
|
224
|
+
// ============================================
|
|
225
|
+
|
|
226
|
+
export interface ActionBarClearButtonProps {
|
|
227
|
+
class?: string;
|
|
228
|
+
children?: JSX.Element;
|
|
229
|
+
'aria-label'?: string;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Button to clear the current selection.
|
|
234
|
+
*/
|
|
235
|
+
export function ActionBarClearButton(props: ActionBarClearButtonProps): JSX.Element {
|
|
236
|
+
const ctx = useActionBarContext();
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<button
|
|
240
|
+
type="button"
|
|
241
|
+
aria-label={props['aria-label'] ?? 'Clear selection'}
|
|
242
|
+
class={props.class}
|
|
243
|
+
onClick={() => ctx?.onClearSelection()}
|
|
244
|
+
>
|
|
245
|
+
{props.children ?? '\u2715'}
|
|
246
|
+
</button>
|
|
247
|
+
);
|
|
248
|
+
}
|