@vkzstudio/muza-ui 1.0.44 → 1.0.46
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/components/Accordion/Accordion.stories.d.ts.map +1 -1
- package/dist/components/Button/Button.stories.d.ts.map +1 -1
- package/dist/components/Card/Card.d.ts +63 -0
- package/dist/components/Card/Card.d.ts.map +1 -0
- package/dist/components/Card/Card.js +67 -0
- package/dist/components/Card/Card.stories.d.ts +13 -0
- package/dist/components/Card/Card.stories.d.ts.map +1 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Card/index.d.ts.map +1 -0
- package/dist/components/Carousel/Carousel.d.ts +140 -0
- package/dist/components/Carousel/Carousel.d.ts.map +1 -0
- package/dist/components/Carousel/Carousel.js +241 -0
- package/dist/components/Carousel/Carousel.stories.d.ts +13 -0
- package/dist/components/Carousel/Carousel.stories.d.ts.map +1 -0
- package/dist/components/Carousel/index.d.ts +2 -0
- package/dist/components/Carousel/index.d.ts.map +1 -0
- package/dist/components/DataTable/DataTable.d.ts +14 -5
- package/dist/components/DataTable/DataTable.d.ts.map +1 -1
- package/dist/components/DataTable/DataTable.js +39 -39
- package/dist/components/DataTable/DataTable.stories.d.ts.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +38 -7
- package/dist/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +165 -163
- package/dist/components/DropdownMenu/DropdownMenu.stories.d.ts +3 -17
- package/dist/components/DropdownMenu/DropdownMenu.stories.d.ts.map +1 -1
- package/dist/components/EdgeButton/EdgeButton.stories.d.ts.map +1 -1
- package/dist/components/ExpandableTable/ExpandableTable.d.ts +30 -11
- package/dist/components/ExpandableTable/ExpandableTable.d.ts.map +1 -1
- package/dist/components/ExpandableTable/ExpandableTable.js +100 -111
- package/dist/components/ExpandableTable/ExpandableTable.stories.d.ts +3 -1
- package/dist/components/ExpandableTable/ExpandableTable.stories.d.ts.map +1 -1
- package/dist/components/FileUpload/FileItem.d.ts +6 -0
- package/dist/components/FileUpload/FileItem.d.ts.map +1 -1
- package/dist/components/FileUpload/FileItem.js +38 -41
- package/dist/components/FileUpload/FileUpload.d.ts +32 -0
- package/dist/components/FileUpload/FileUpload.d.ts.map +1 -1
- package/dist/components/FileUpload/FileUpload.js +87 -83
- package/dist/components/FileUpload/FileUpload.stories.d.ts +1 -0
- package/dist/components/FileUpload/FileUpload.stories.d.ts.map +1 -1
- package/dist/components/Flex/Flex.d.ts +373 -2
- package/dist/components/Flex/Flex.d.ts.map +1 -1
- package/dist/components/Flex/Flex.js +61 -63
- package/dist/components/Flex/Flex.stories.d.ts.map +1 -1
- package/dist/components/Icons/CustomBadges.d.ts +14 -0
- package/dist/components/Icons/CustomBadges.d.ts.map +1 -0
- package/dist/components/Icons/CustomBadges.js +334 -0
- package/dist/components/Icons/CustomIcons.d.ts +24 -0
- package/dist/components/Icons/CustomIcons.d.ts.map +1 -1
- package/dist/components/Icons/CustomIcons.js +88 -42
- package/dist/components/Icons/CustomLogos.d.ts +29 -0
- package/dist/components/Icons/CustomLogos.d.ts.map +1 -0
- package/dist/components/Icons/CustomLogos.js +593 -0
- package/dist/components/Icons/Icons.stories.d.ts.map +1 -1
- package/dist/components/Icons/LogosAndBadges.stories.d.ts +7 -0
- package/dist/components/Icons/LogosAndBadges.stories.d.ts.map +1 -0
- package/dist/components/Icons/index.d.ts +2 -0
- package/dist/components/Icons/index.d.ts.map +1 -1
- package/dist/components/LanguageSwitcher/LanguageSwitcher.d.ts +24 -1
- package/dist/components/LanguageSwitcher/LanguageSwitcher.d.ts.map +1 -1
- package/dist/components/LanguageSwitcher/LanguageSwitcher.js +71 -52
- package/dist/components/LanguageSwitcher/LanguageSwitcher.stories.d.ts +2 -0
- package/dist/components/LanguageSwitcher/LanguageSwitcher.stories.d.ts.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +18 -17
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts.map +1 -1
- package/dist/components/MuzaUIProvider/MuzaUIProvider.stories.d.ts.map +1 -1
- package/dist/components/Pagination/Pagination.js +1 -1
- package/dist/components/Pagination/Pagination.stories.d.ts.map +1 -1
- package/dist/components/Progress/Progress.d.ts +49 -0
- package/dist/components/Progress/Progress.d.ts.map +1 -0
- package/dist/components/Progress/Progress.js +64 -0
- package/dist/components/Progress/Progress.stories.d.ts +13 -0
- package/dist/components/Progress/Progress.stories.d.ts.map +1 -0
- package/dist/components/Progress/index.d.ts +2 -0
- package/dist/components/Progress/index.d.ts.map +1 -0
- package/dist/components/Reorderable/Reorderable.stories.d.ts.map +1 -1
- package/dist/components/ResponsiveLayoutTable/ResponsiveLayoutTable.d.ts +266 -0
- package/dist/components/ResponsiveLayoutTable/ResponsiveLayoutTable.d.ts.map +1 -0
- package/dist/components/ResponsiveLayoutTable/ResponsiveLayoutTable.examples.d.ts +39 -0
- package/dist/components/ResponsiveLayoutTable/ResponsiveLayoutTable.examples.d.ts.map +1 -0
- package/dist/components/ResponsiveLayoutTable/ResponsiveLayoutTable.js +134 -0
- package/dist/components/ResponsiveLayoutTable/ResponsiveLayoutTable.stories.d.ts +14 -0
- package/dist/components/ResponsiveLayoutTable/ResponsiveLayoutTable.stories.d.ts.map +1 -0
- package/dist/components/ResponsiveLayoutTable/index.d.ts +2 -0
- package/dist/components/ResponsiveLayoutTable/index.d.ts.map +1 -0
- package/dist/components/Select/Select.d.ts +20 -7
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/Select.js +123 -92
- package/dist/components/Select/Select.stories.d.ts +1 -0
- package/dist/components/Select/Select.stories.d.ts.map +1 -1
- package/dist/components/Select/utils.d.ts +1 -0
- package/dist/components/Select/utils.d.ts.map +1 -1
- package/dist/components/Select/utils.js +5 -2
- package/dist/components/Sheet/Sheet.d.ts +89 -0
- package/dist/components/Sheet/Sheet.d.ts.map +1 -0
- package/dist/components/Sheet/Sheet.js +189 -0
- package/dist/components/Sheet/Sheet.stories.d.ts +20 -0
- package/dist/components/Sheet/Sheet.stories.d.ts.map +1 -0
- package/dist/components/Sheet/index.d.ts +2 -0
- package/dist/components/Sheet/index.d.ts.map +1 -0
- package/dist/components/Slider/Slider.d.ts +65 -0
- package/dist/components/Slider/Slider.d.ts.map +1 -0
- package/dist/components/Slider/Slider.js +134 -0
- package/dist/components/Slider/Slider.stories.d.ts +12 -0
- package/dist/components/Slider/Slider.stories.d.ts.map +1 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Slider/index.d.ts.map +1 -0
- package/dist/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/components/Toggle/Toggle.js +1 -1
- package/dist/components/ToggleCheckButton/ToggleCheckButton.d.ts +69 -0
- package/dist/components/ToggleCheckButton/ToggleCheckButton.d.ts.map +1 -0
- package/dist/components/ToggleCheckButton/ToggleCheckButton.js +64 -0
- package/dist/components/ToggleCheckButton/ToggleCheckButton.stories.d.ts +8 -0
- package/dist/components/ToggleCheckButton/ToggleCheckButton.stories.d.ts.map +1 -0
- package/dist/components/ToggleCheckButton/index.d.ts +2 -0
- package/dist/components/ToggleCheckButton/index.d.ts.map +1 -0
- package/dist/components/Typography/Typography.stories.d.ts.map +1 -1
- package/dist/components/WebCheckoutNav/WebCheckoutNav.examples.d.ts +19 -0
- package/dist/components/WebCheckoutNav/WebCheckoutNav.examples.d.ts.map +1 -0
- package/dist/components/WebCheckoutNav/WebCheckoutNav.stories.d.ts +8 -0
- package/dist/components/WebCheckoutNav/WebCheckoutNav.stories.d.ts.map +1 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/globals.css +1 -0
- package/dist/hooks/use-is-breakpoint.d.ts +11 -0
- package/dist/hooks/use-is-breakpoint.d.ts.map +1 -1
- package/dist/hooks/use-is-breakpoint.js +24 -13
- package/dist/index.js +316 -262
- package/dist/muza-ui.css +1 -1
- package/dist/styles/primitives.css +5 -1
- package/dist/styles/token-colors.css +221 -12
- package/dist/styles/token-sizes.css +636 -267
- package/dist/styles/typography.css +36 -7
- package/dist/translations/locales/cs.d.ts.map +1 -1
- package/dist/translations/locales/cs.js +17 -0
- package/dist/translations/locales/en.d.ts.map +1 -1
- package/dist/translations/locales/en.js +17 -0
- package/dist/translations/locales/sk.d.ts.map +1 -1
- package/dist/translations/locales/sk.js +19 -2
- package/dist/translations/types.d.ts +42 -0
- package/dist/translations/types.d.ts.map +1 -1
- package/dist/utils/cn.d.ts.map +1 -1
- package/dist/utils/cn.js +24 -7
- package/package.json +6 -3
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { ResponsiveBreakpoint } from '../../hooks/use-is-breakpoint';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Column definition for a single layout of the ResponsiveLayoutTable.
|
|
5
|
+
*
|
|
6
|
+
* Each column either renders a raw value from the row via `dataKey` (wrapped in
|
|
7
|
+
* a Typography component) or a fully custom cell via `render`. Use `skeleton` to
|
|
8
|
+
* describe the loading placeholder shape.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam T - The type of data objects in each row
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const columns: ResponsiveLayoutTableColumn<Transaction>[] = [
|
|
15
|
+
* { title: 'Customer', dataKey: 'customer', className: 'w-[240px]' },
|
|
16
|
+
* {
|
|
17
|
+
* title: 'Amount',
|
|
18
|
+
* render: (row) => <AmountCell row={row} />,
|
|
19
|
+
* skeleton: <Skeleton className="h-4 w-20" />,
|
|
20
|
+
* },
|
|
21
|
+
* ]
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export interface ResponsiveLayoutTableColumn<T extends {
|
|
25
|
+
id: string | number;
|
|
26
|
+
}> {
|
|
27
|
+
/** Header label. Accepts ReactNode for multi-line headers (e.g. tablet stacked text). */
|
|
28
|
+
title?: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Property key from the data object. Used as default cell content when `render`
|
|
31
|
+
* is omitted — the raw value is rendered inside a Typography component. Ignored
|
|
32
|
+
* when `render` is provided.
|
|
33
|
+
*/
|
|
34
|
+
dataKey?: keyof T;
|
|
35
|
+
/** Additional CSS class applied to both the header and body cells. */
|
|
36
|
+
className?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Truncates default cell text to the specified number of lines. Only applies
|
|
39
|
+
* when `render` is omitted. `true` or `1` clamps to one line, `2` clamps to two.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
lineClamp?: boolean | 1 | 2;
|
|
43
|
+
/**
|
|
44
|
+
* Custom render function for cell content. Receives the full row data so that
|
|
45
|
+
* compressed layouts can combine data from multiple fields in a single cell.
|
|
46
|
+
* When omitted, the raw `dataKey` value is displayed inside a Typography component.
|
|
47
|
+
*
|
|
48
|
+
* @param rowData - The data object for the current row
|
|
49
|
+
* @param rowIndex - The zero-based index of the row in `data`
|
|
50
|
+
* @param disabled - Whether the table is in the disabled state (forwarded from
|
|
51
|
+
* `ResponsiveLayoutTableProps.disabled` so cells can mute their own styling)
|
|
52
|
+
*/
|
|
53
|
+
render?: (rowData: T, rowIndex: number, disabled?: boolean) => React.ReactNode;
|
|
54
|
+
/**
|
|
55
|
+
* Skeleton placeholder rendered in this cell when the row is in a loading state
|
|
56
|
+
* (see `ResponsiveLayoutTableProps.isRowLoading`). Compose `<Skeleton />` primitives
|
|
57
|
+
* to match the shape of the real cell. Omit to fall back to a generic full-width bar.
|
|
58
|
+
*/
|
|
59
|
+
skeleton?: React.ReactNode;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Per-layout className overrides for the header and body rows.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* classNames: { row: 'border-dashed', header: 'bg-surface-base-tertiary' }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export interface ResponsiveLayoutTableLayoutClassNames {
|
|
70
|
+
/** Additional CSS class applied to each body row. */
|
|
71
|
+
row?: string;
|
|
72
|
+
/** Additional CSS class applied to the header row. */
|
|
73
|
+
header?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A single layout configuration for the ResponsiveLayoutTable. Each layout
|
|
77
|
+
* describes a distinct set of columns that becomes active when its `responsive`
|
|
78
|
+
* predicate matches. Layouts are evaluated in order and the first match wins;
|
|
79
|
+
* the last entry should omit `responsive` so it matches as a fallback.
|
|
80
|
+
*
|
|
81
|
+
* @typeParam T - The type of data objects in each row
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* const layouts: ResponsiveLayoutTableLayout<Transaction>[] = [
|
|
86
|
+
* { responsive: 'lg', columns: desktopColumns },
|
|
87
|
+
* { responsive: 'md', columns: tabletColumns },
|
|
88
|
+
* { showHeader: false, columns: phoneColumns },
|
|
89
|
+
* ]
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export interface ResponsiveLayoutTableLayout<T extends {
|
|
93
|
+
id: string | number;
|
|
94
|
+
}> {
|
|
95
|
+
/**
|
|
96
|
+
* Controls when this layout is active.
|
|
97
|
+
* - Named breakpoint (`'xs'..'3xl'`): active at and above that breakpoint, resolved internally via hooks.
|
|
98
|
+
* - Boolean: caller supplies the result directly (e.g. from `useMediaQuery('(min-width: 52rem)')`).
|
|
99
|
+
* `true` activates this layout, `false` skips it. Use this for arbitrary thresholds.
|
|
100
|
+
* - Omitted: treated as fallback (always matches).
|
|
101
|
+
*
|
|
102
|
+
* @see {@link ResponsiveBreakpoint}
|
|
103
|
+
*/
|
|
104
|
+
responsive?: ResponsiveBreakpoint | boolean;
|
|
105
|
+
/** Column definitions for this layout. */
|
|
106
|
+
columns: ResponsiveLayoutTableColumn<T>[];
|
|
107
|
+
/**
|
|
108
|
+
* Whether to show the header row.
|
|
109
|
+
* @default true
|
|
110
|
+
*/
|
|
111
|
+
showHeader?: boolean;
|
|
112
|
+
/** Per-layout className overrides for the header and body rows. */
|
|
113
|
+
classNames?: ResponsiveLayoutTableLayoutClassNames;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Top-level className overrides for the ResponsiveLayoutTable.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```tsx
|
|
120
|
+
* classNames={{
|
|
121
|
+
* root: 'rounded-xl',
|
|
122
|
+
* rowBackgroundInset:
|
|
123
|
+
* 'before:-left-comp-webcheckout-table-cells-p-hor before:-right-comp-webcheckout-table-cells-p-hor',
|
|
124
|
+
* }}
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export interface ResponsiveLayoutTableClassNames {
|
|
128
|
+
/** Outer wrapper `<div>`. */
|
|
129
|
+
root?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Classes applied to each row's `::before` pseudo-element when
|
|
132
|
+
* `overflowingRowBackground` is `true`. Default is zero bleed
|
|
133
|
+
* (the background sits flush inside the row). Consumer passes any
|
|
134
|
+
* Tailwind classes with the `before:` prefix and can use `first:` /
|
|
135
|
+
* `last:` variants to extend the tint past the first / last row so it
|
|
136
|
+
* reaches the surrounding card's top / bottom padding.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```tsx
|
|
140
|
+
* classNames={{
|
|
141
|
+
* rowBackgroundInset:
|
|
142
|
+
* 'before:-left-comp-webcheckout-table-cells-p-hor ' +
|
|
143
|
+
* 'before:-right-comp-webcheckout-table-cells-p-hor ' +
|
|
144
|
+
* 'first:before:-top-sm last:before:-bottom-sm',
|
|
145
|
+
* }}
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
rowBackgroundInset?: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Props for the ResponsiveLayoutTable component.
|
|
152
|
+
* @typeParam T - The type of data objects in each row. Must include an
|
|
153
|
+
* `id: string | number` field so each row has a stable React key —
|
|
154
|
+
* keying by index corrupts focus / selection / animation state when
|
|
155
|
+
* rows reorder, filter, or paginate.
|
|
156
|
+
*/
|
|
157
|
+
export interface ResponsiveLayoutTableProps<T extends {
|
|
158
|
+
id: string | number;
|
|
159
|
+
}> extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'className'> {
|
|
160
|
+
/** Array of data objects where each item represents one table row. */
|
|
161
|
+
data: T[];
|
|
162
|
+
/**
|
|
163
|
+
* Array of layout configurations ordered from largest to smallest breakpoint.
|
|
164
|
+
* The first layout whose `responsive` matches wins. The last layout should
|
|
165
|
+
* omit `responsive` (fallback for smallest viewports).
|
|
166
|
+
*
|
|
167
|
+
* Uses the same pattern as ExpandableTable's column `responsive` prop:
|
|
168
|
+
* - Named breakpoint (`'xs'..'3xl'`): resolved internally via hooks.
|
|
169
|
+
* - Boolean: consumer controls it with their own `useMediaQuery()`.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```tsx
|
|
173
|
+
* layouts={[
|
|
174
|
+
* { responsive: 'lg', columns: desktopColumns },
|
|
175
|
+
* { responsive: 'md', columns: tabletColumns },
|
|
176
|
+
* { showHeader: false, columns: phoneColumns },
|
|
177
|
+
* ]}
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
layouts: ResponsiveLayoutTableLayout<T>[];
|
|
181
|
+
/**
|
|
182
|
+
* Fires when a row is clicked. When provided and not `disabled`, rows become
|
|
183
|
+
* interactive: pointer cursor, keyboard-activatable, and a hover border.
|
|
184
|
+
*/
|
|
185
|
+
onRowClick?: (rowData: T, rowIndex: number) => void;
|
|
186
|
+
/** Prevents interaction and applies muted text colors. @default false */
|
|
187
|
+
disabled?: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Predicate that marks a row as "new", applying the
|
|
190
|
+
* `bg-comp-responsive-layout-table-bg-success` tint. On interactive rows,
|
|
191
|
+
* hover and focus-visible backgrounds visually override the new-state tint.
|
|
192
|
+
*/
|
|
193
|
+
isRowNew?: (rowData: T, rowIndex: number) => boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Predicate that marks a row as loading. Each cell renders its column
|
|
196
|
+
* `skeleton` (or a default bar) instead of the normal content, and the row
|
|
197
|
+
* becomes non-interactive regardless of `onRowClick`. The `isRowNew` tint is
|
|
198
|
+
* also suppressed for loading rows.
|
|
199
|
+
*
|
|
200
|
+
* Use for initial load (an array of empty objects with the predicate always
|
|
201
|
+
* returning true) and for pagination (append placeholder rows after real
|
|
202
|
+
* data and detect them in the predicate).
|
|
203
|
+
*/
|
|
204
|
+
isRowLoading?: (rowData: T, rowIndex: number) => boolean;
|
|
205
|
+
/**
|
|
206
|
+
* When `true`, row backgrounds (new/hover/focus) render via a `::before`
|
|
207
|
+
* pseudo-element sized to the row (zero bleed by default). The outer
|
|
208
|
+
* wrapper switches to `overflow: visible` in this mode — horizontal
|
|
209
|
+
* scrolling is disabled, so only use when your active layout fits the
|
|
210
|
+
* viewport (typically the phone layout).
|
|
211
|
+
*
|
|
212
|
+
* Pair with `classNames.rowBackgroundInset` to extend the tint past any
|
|
213
|
+
* edge — typically to bleed through the surrounding card's horizontal
|
|
214
|
+
* padding, and (via `first:` / `last:`) its top and bottom padding.
|
|
215
|
+
* @default false
|
|
216
|
+
*/
|
|
217
|
+
overflowingRowBackground?: boolean;
|
|
218
|
+
/** className overrides for sub-elements. */
|
|
219
|
+
classNames?: ResponsiveLayoutTableClassNames;
|
|
220
|
+
/**
|
|
221
|
+
* Controls how column widths are calculated, mirroring the CSS
|
|
222
|
+
* `table-layout` property.
|
|
223
|
+
*
|
|
224
|
+
* - `'auto'` (default): Columns size based on their content. This is more
|
|
225
|
+
* flexible. In case of overflow the content is scrollable.
|
|
226
|
+
* - `'fixed'`: Columns use fixed widths (from column definitions or equal
|
|
227
|
+
* distribution). This is more predictable and performs better for large
|
|
228
|
+
* datasets, but content may truncate.
|
|
229
|
+
*
|
|
230
|
+
* @default 'auto'
|
|
231
|
+
*/
|
|
232
|
+
tableLayout?: 'auto' | 'fixed';
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* A responsive table that switches between completely different column layouts
|
|
236
|
+
* at configurable breakpoints. Each layout defines its own set of columns with
|
|
237
|
+
* independent headers and render functions, enabling compressed tablet views
|
|
238
|
+
* (stacked cells) and phone card layouts (single full-width column) — not just
|
|
239
|
+
* hidden columns.
|
|
240
|
+
*
|
|
241
|
+
* Supports named Tailwind breakpoints and arbitrary boolean values for custom
|
|
242
|
+
* thresholds. Rows become interactive when `onRowClick` is provided (pointer
|
|
243
|
+
* cursor, keyboard-activatable, hover border). Loading rows are driven by the
|
|
244
|
+
* `isRowLoading` predicate and render per-column `skeleton` placeholders.
|
|
245
|
+
*
|
|
246
|
+
* @typeParam T - The type of data objects in each row. Must include an
|
|
247
|
+
* `id: string | number` field so rows receive a stable React key.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```tsx
|
|
251
|
+
* <ResponsiveLayoutTable
|
|
252
|
+
* data={transactions}
|
|
253
|
+
* layouts={[
|
|
254
|
+
* { responsive: 'lg', columns: desktopColumns },
|
|
255
|
+
* { responsive: 'md', columns: tabletColumns },
|
|
256
|
+
* { showHeader: false, columns: phoneColumns },
|
|
257
|
+
* ]}
|
|
258
|
+
* onRowClick={(row) => navigate(`/transactions/${row.id}`)}
|
|
259
|
+
* />
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
declare const ResponsiveLayoutTable: <T extends {
|
|
263
|
+
id: string | number;
|
|
264
|
+
}>({ data, layouts, onRowClick, disabled, isRowNew, isRowLoading, overflowingRowBackground, classNames, tableLayout, ...props }: ResponsiveLayoutTableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
265
|
+
export { ResponsiveLayoutTable };
|
|
266
|
+
//# sourceMappingURL=ResponsiveLayoutTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponsiveLayoutTable.d.ts","sourceRoot":"","sources":["../../../src/components/Responsi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,MAAM,GAAG,MAAM,CAAA;CAAE,EAAE,8HAW/D,0BAA0B,CAAC,CAAC,CAAC,4CA2J/B,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ResponsiveLayoutTableColumn, ResponsiveLayoutTableLayout } from './ResponsiveLayoutTable';
|
|
2
|
+
export interface Transaction {
|
|
3
|
+
id: string;
|
|
4
|
+
date: string;
|
|
5
|
+
time: string;
|
|
6
|
+
customer: string;
|
|
7
|
+
transactionCode: string;
|
|
8
|
+
status: 'warning' | 'success' | 'info' | 'error';
|
|
9
|
+
statusLabel: string;
|
|
10
|
+
amount: number;
|
|
11
|
+
originalAmount?: number;
|
|
12
|
+
isNew?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const formatKc: (value: number) => string;
|
|
15
|
+
export declare const transactions: Transaction[];
|
|
16
|
+
interface CellProps {
|
|
17
|
+
row: Transaction;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const DateTimeCell: ({ row, disabled }: CellProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const DateTimeCellSkeleton: () => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const CustomerCell: ({ row, disabled }: CellProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const CustomerCellSkeleton: () => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare const TransactionCodeCell: ({ row, disabled }: CellProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare const TransactionCodeCellSkeleton: () => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare const StatusCell: ({ row, disabled }: CellProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare const StatusCellSkeleton: () => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare const AmountCell: ({ row, disabled, hideOriginalAmount, }: CellProps & {
|
|
29
|
+
hideOriginalAmount?: boolean;
|
|
30
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare const AmountCellSkeleton: () => import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export declare const ActionArrowCell: ({ row, disabled }: CellProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare const ActionArrowCellSkeleton: () => import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare const desktopColumns: ResponsiveLayoutTableColumn<Transaction>[];
|
|
35
|
+
export declare const tabletColumns: ResponsiveLayoutTableColumn<Transaction>[];
|
|
36
|
+
export declare const phoneColumns: ResponsiveLayoutTableColumn<Transaction>[];
|
|
37
|
+
export declare const layouts: ResponsiveLayoutTableLayout<Transaction>[];
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=ResponsiveLayoutTable.examples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponsiveLayoutTable.examples.d.ts","sourceRoot":"","sources":["../../../src/components/ResponsiveLayoutTable/ResponsiveLayoutTable.examples.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,yBAAyB,CAAA;AAIhC,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAA;IAChD,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAID,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,WAC+B,CAAA;AAIrE,eAAO,MAAM,YAAY,EAAE,WAAW,EAkCrC,CAAA;AAID,UAAU,SAAS;IACjB,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,YAAY,GAAI,mBAAmB,SAAS,4CAyBxD,CAAA;AAED,eAAO,MAAM,oBAAoB,+CAKhC,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,mBAAmB,SAAS,4CAaxD,CAAA;AAED,eAAO,MAAM,oBAAoB,+CAEhC,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,mBAAmB,SAAS,4CAwC/D,CAAA;AAED,eAAO,MAAM,2BAA2B,+CAKvC,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,mBAAmB,SAAS,4CAItD,CAAA;AAED,eAAO,MAAM,kBAAkB,+CAE9B,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,wCAIxB,SAAS,GAAG;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,4CAgC9C,CAAA;AAED,eAAO,MAAM,kBAAkB,+CAE9B,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,mBAAmB,SAAS,4CAmC3D,CAAA;AAED,eAAO,MAAM,uBAAuB,+CAKnC,CAAA;AAID,eAAO,MAAM,cAAc,EAAE,2BAA2B,CAAC,WAAW,CAAC,EAsDpE,CAAA;AAID,eAAO,MAAM,aAAa,EAAE,2BAA2B,CAAC,WAAW,CAAC,EAqEnE,CAAA;AAID,eAAO,MAAM,YAAY,EAAE,2BAA2B,CAAC,WAAW,CAAC,EA2BlE,CAAA;AAID,eAAO,MAAM,OAAO,EAAE,2BAA2B,CAAC,WAAW,CAAC,EAI7D,CAAA"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx as r, jsxs as T } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { useBreakpoints as E } from "../../hooks/use-is-breakpoint.js";
|
|
4
|
+
import { Skeleton as H } from "../Skeleton/Skeleton.js";
|
|
5
|
+
import { cn as l } from "../../utils/cn.js";
|
|
6
|
+
import { typographyVariants as S, Typography as V } from "../Typography/Typography.js";
|
|
7
|
+
const J = ({
|
|
8
|
+
data: y,
|
|
9
|
+
layouts: n,
|
|
10
|
+
onRowClick: f,
|
|
11
|
+
disabled: o = !1,
|
|
12
|
+
isRowNew: h,
|
|
13
|
+
isRowLoading: d,
|
|
14
|
+
overflowingRowBackground: i = !1,
|
|
15
|
+
classNames: c,
|
|
16
|
+
tableLayout: x,
|
|
17
|
+
...k
|
|
18
|
+
}) => {
|
|
19
|
+
const K = E(), g = (() => {
|
|
20
|
+
for (const e of n) {
|
|
21
|
+
if (e.responsive === void 0) return e;
|
|
22
|
+
if (typeof e.responsive == "boolean") {
|
|
23
|
+
if (e.responsive) return e;
|
|
24
|
+
} else if (K[e.responsive])
|
|
25
|
+
return e;
|
|
26
|
+
}
|
|
27
|
+
return n[n.length - 1];
|
|
28
|
+
})(), {
|
|
29
|
+
columns: u,
|
|
30
|
+
showHeader: m = !0,
|
|
31
|
+
classNames: p
|
|
32
|
+
} = g, j = !!f && !o;
|
|
33
|
+
return /* @__PURE__ */ r(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
className: l(
|
|
37
|
+
"w-full",
|
|
38
|
+
i ? "overflow-visible" : "overflow-x-auto overflow-y-hidden",
|
|
39
|
+
c == null ? void 0 : c.root
|
|
40
|
+
),
|
|
41
|
+
...k,
|
|
42
|
+
children: /* @__PURE__ */ T(
|
|
43
|
+
"table",
|
|
44
|
+
{
|
|
45
|
+
className: l("w-full border-collapse", {
|
|
46
|
+
"table-fixed": x === "fixed"
|
|
47
|
+
}),
|
|
48
|
+
children: [
|
|
49
|
+
m && /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ r("tr", { className: l(p == null ? void 0 : p.header), children: u.map((e, s) => /* @__PURE__ */ r(
|
|
50
|
+
"th",
|
|
51
|
+
{
|
|
52
|
+
className: l(
|
|
53
|
+
S({
|
|
54
|
+
size: "sm",
|
|
55
|
+
uppercase: !0,
|
|
56
|
+
variant: "body",
|
|
57
|
+
weight: "medium"
|
|
58
|
+
}),
|
|
59
|
+
"h-comp-webcheckout-table-cells-h-first-row",
|
|
60
|
+
"px-comp-webcheckout-table-cells-p-hor py-comp-webcheckout-table-cells-p-ver text-left",
|
|
61
|
+
"text-text-dark-secondary",
|
|
62
|
+
{ "text-text-dark-disabled": o },
|
|
63
|
+
e.className
|
|
64
|
+
),
|
|
65
|
+
children: e.title
|
|
66
|
+
},
|
|
67
|
+
s
|
|
68
|
+
)) }) }),
|
|
69
|
+
/* @__PURE__ */ r("tbody", { children: y.map((e, s) => {
|
|
70
|
+
const a = (d == null ? void 0 : d(e, s)) ?? !1, v = !a && ((h == null ? void 0 : h(e, s)) ?? !1), b = j && !a;
|
|
71
|
+
return /* @__PURE__ */ r(
|
|
72
|
+
"tr",
|
|
73
|
+
{
|
|
74
|
+
className: l(
|
|
75
|
+
"border-t border-stroke-base-secondary",
|
|
76
|
+
!m && "first:border-t-0",
|
|
77
|
+
{
|
|
78
|
+
"relative before:absolute before:inset-0 before:content-['']": i,
|
|
79
|
+
"bg-comp-responsive-layout-table-bg-success": !i && v,
|
|
80
|
+
"before:bg-comp-responsive-layout-table-bg-success": i && v,
|
|
81
|
+
"cursor-pointer": b,
|
|
82
|
+
"outline-0 hover:bg-surface-state-bg-info focus-visible:bg-surface-state-bg-info": b && !i,
|
|
83
|
+
"outline-0 hover:before:bg-surface-state-bg-info focus-visible:before:bg-surface-state-bg-info": b && i
|
|
84
|
+
},
|
|
85
|
+
i && (c == null ? void 0 : c.rowBackgroundInset),
|
|
86
|
+
p == null ? void 0 : p.row
|
|
87
|
+
),
|
|
88
|
+
onClick: b ? () => f(e, s) : void 0,
|
|
89
|
+
onKeyDown: b ? (t) => {
|
|
90
|
+
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), f(e, s));
|
|
91
|
+
} : void 0,
|
|
92
|
+
tabIndex: b ? 0 : void 0,
|
|
93
|
+
"aria-busy": a || void 0,
|
|
94
|
+
children: u.map((t, z) => /* @__PURE__ */ r(
|
|
95
|
+
"td",
|
|
96
|
+
{
|
|
97
|
+
className: l(
|
|
98
|
+
"h-comp-webcheckout-table-cells-h w-full",
|
|
99
|
+
"px-comp-webcheckout-table-cells-p-hor py-comp-webcheckout-table-cells-p-ver",
|
|
100
|
+
i && "relative",
|
|
101
|
+
t.className
|
|
102
|
+
),
|
|
103
|
+
children: a ? t.skeleton ?? /* @__PURE__ */ r(H, { color: "light", className: "h-4 w-full" }) : t.render ? t.render(e, s, o) : /* @__PURE__ */ r(
|
|
104
|
+
V,
|
|
105
|
+
{
|
|
106
|
+
variant: "body",
|
|
107
|
+
size: "base",
|
|
108
|
+
weight: "medium",
|
|
109
|
+
component: "span",
|
|
110
|
+
fixY: !0,
|
|
111
|
+
className: l({
|
|
112
|
+
"line-clamp-1": t.lineClamp === !0 || t.lineClamp === 1,
|
|
113
|
+
"line-clamp-2": t.lineClamp === 2,
|
|
114
|
+
"text-text-dark-disabled": o
|
|
115
|
+
}),
|
|
116
|
+
children: t.dataKey ? e[t.dataKey] : null
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
},
|
|
120
|
+
z
|
|
121
|
+
))
|
|
122
|
+
},
|
|
123
|
+
e.id
|
|
124
|
+
);
|
|
125
|
+
}) })
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
export {
|
|
133
|
+
J as ResponsiveLayoutTable
|
|
134
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: Meta;
|
|
3
|
+
export default meta;
|
|
4
|
+
type Story = StoryObj;
|
|
5
|
+
export declare const Default: Story;
|
|
6
|
+
export declare const WithRowClick: Story;
|
|
7
|
+
export declare const WithNewRow: Story;
|
|
8
|
+
export declare const NewRowWithRowClick: Story;
|
|
9
|
+
export declare const OverflowingRowBackground: Story;
|
|
10
|
+
export declare const Disabled: Story;
|
|
11
|
+
export declare const Loading: Story;
|
|
12
|
+
export declare const LoadingMore: Story;
|
|
13
|
+
export declare const CustomBreakpoint: Story;
|
|
14
|
+
//# sourceMappingURL=ResponsiveLayoutTable.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponsiveLayoutTable.stories.d.ts","sourceRoot":"","sources":["../../../src/components/ResponsiveLayoutTable/ResponsiveLayoutTable.stories.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAiB3D,QAAA,MAAM,IAAI,EAAE,IAoDX,CAAA;AAED,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAA;AAErB,eAAO,MAAM,OAAO,EAAE,KAmBrB,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,KAuB1B,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAoBxB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAwBhC,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,KA8BtC,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAsBtB,CAAA;AAUD,eAAO,MAAM,OAAO,EAAE,KAoBrB,CAAA;AAeD,eAAO,MAAM,WAAW,EAAE,KAwBzB,CAAA;AAID,eAAO,MAAM,gBAAgB,EAAE,KA6B9B,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { ResponsiveLayoutTable, type ResponsiveLayoutTableProps, type ResponsiveLayoutTableLayout, type ResponsiveLayoutTableColumn, type ResponsiveLayoutTableClassNames, type ResponsiveLayoutTableLayoutClassNames, } from './ResponsiveLayoutTable';
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ResponsiveLayoutTable/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,+BAA+B,EACpC,KAAK,qCAAqC,GAC3C,MAAM,yBAAyB,CAAA"}
|
|
@@ -6,6 +6,7 @@ import { default as React, ReactNode } from 'react';
|
|
|
6
6
|
* const options: ISelectOption[] = [
|
|
7
7
|
* { value: 'a', label: 'Option A' },
|
|
8
8
|
* { value: 'b', label: 'Option B', disabled: true, icon: <Icon /> },
|
|
9
|
+
* { value: 'c', label: 'Location C', description: 'Address line' },
|
|
9
10
|
* ]
|
|
10
11
|
*/
|
|
11
12
|
export interface ISelectOption {
|
|
@@ -13,6 +14,8 @@ export interface ISelectOption {
|
|
|
13
14
|
value: string;
|
|
14
15
|
/** Visible label rendered inside the dropdown item and in the trigger when selected. */
|
|
15
16
|
label: ReactNode;
|
|
17
|
+
/** Secondary text rendered below the label, producing a two-line layout. */
|
|
18
|
+
description?: ReactNode;
|
|
16
19
|
/** Prevents the option from being selected and applies disabled styling. @default false */
|
|
17
20
|
disabled?: boolean;
|
|
18
21
|
/** Icon rendered before the option label inside the dropdown. */
|
|
@@ -20,23 +23,25 @@ export interface ISelectOption {
|
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
25
|
* Props for the Select component.
|
|
26
|
+
*
|
|
27
|
+
* @see ISelectOption
|
|
23
28
|
*/
|
|
24
29
|
export interface ISelectProps {
|
|
25
|
-
/** Label text
|
|
30
|
+
/** Label text rendered above the trigger by `FormField`. */
|
|
26
31
|
label?: string;
|
|
27
|
-
/** Helper text
|
|
32
|
+
/** Helper text rendered below the trigger. Switches to the error color when `error` is `true`. */
|
|
28
33
|
hint?: string;
|
|
29
|
-
/** Applies error styling to the trigger border and hint text. @default false */
|
|
34
|
+
/** Applies error styling to the trigger border and `hint` text. @default false */
|
|
30
35
|
error?: boolean;
|
|
31
36
|
/** Marks the field as required and shows an asterisk next to the label. @default false */
|
|
32
37
|
required?: boolean;
|
|
33
|
-
/** Hides the required asterisk even when `required` is true
|
|
38
|
+
/** Hides the required asterisk even when `required` is `true`. @default false */
|
|
34
39
|
disableRequiredAsterisk?: boolean;
|
|
35
40
|
/** Element rendered after the selected value inside the trigger. */
|
|
36
41
|
suffix?: ReactNode;
|
|
37
42
|
/** Icon or element rendered before the selected value inside the trigger. */
|
|
38
43
|
prefix?: ReactNode;
|
|
39
|
-
/**
|
|
44
|
+
/** Placeholder text shown when no option is selected. @default translations.select.placeholder */
|
|
40
45
|
placeholder?: string;
|
|
41
46
|
/** Text shown inside the dropdown when `options` is empty. @default translations.select.noOptions */
|
|
42
47
|
emptyMessage?: string;
|
|
@@ -51,6 +56,7 @@ export interface ISelectProps {
|
|
|
51
56
|
* options={[
|
|
52
57
|
* { value: 'a', label: 'Option A' },
|
|
53
58
|
* { value: 'b', label: 'Option B', disabled: true, icon: <Icon /> },
|
|
59
|
+
* { value: 'c', label: 'Location C', description: 'Address line' },
|
|
54
60
|
* ]}
|
|
55
61
|
* />
|
|
56
62
|
*/
|
|
@@ -59,9 +65,16 @@ export interface ISelectProps {
|
|
|
59
65
|
disabled?: boolean;
|
|
60
66
|
/** Controlled selected value. Must match a `value` field in `options`. */
|
|
61
67
|
value?: string;
|
|
62
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Fires when the user picks an option. Receives the newly selected `value` string.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```tsx
|
|
73
|
+
* <Select onChange={(value) => setSelected(value)} />
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
63
76
|
onChange?: (value: string) => void;
|
|
64
|
-
/** Scrolls the dropdown to the selected option when
|
|
77
|
+
/** Scrolls the dropdown to the selected option when it opens. @default false */
|
|
65
78
|
shouldScrollToSelectedOption?: boolean;
|
|
66
79
|
/** Distance in pixels from the viewport edge before the dropdown repositions. Passed to Radix collision padding. */
|
|
67
80
|
collisionPadding?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,KAAK,SAAS,EAMf,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,KAAK,SAAS,EAMf,MAAM,OAAO,CAAA;AAgBd;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAA;IACb,wFAAwF;IACxF,KAAK,EAAE,SAAS,CAAA;IAChB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iEAAiE;IACjE,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kGAAkG;IAClG,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kFAAkF;IAClF,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iFAAiF;IACjF,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,oEAAoE;IACpE,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,kGAAkG;IAClG,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qGAAqG;IACrG,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IAClC;;;;;;;;;;;;OAYG;IACH,OAAO,EAAE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