polymorph-ui-components-mcp 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/docs/Accordion.md +45 -0
- package/build/docs/Avatar.md +80 -0
- package/build/docs/Badge.md +58 -0
- package/build/docs/Banner.md +134 -0
- package/build/docs/Book.md +111 -0
- package/build/docs/Browser.md +92 -0
- package/build/docs/Button.md +154 -0
- package/build/docs/CHANGELOG.md +0 -0
- package/build/docs/Calendar.md +129 -0
- package/build/docs/Carousel.md +73 -0
- package/build/docs/CheckListItem.md +76 -0
- package/build/docs/Checkbox.md +84 -0
- package/build/docs/Choicebox.md +71 -0
- package/build/docs/ColorPicker.md +83 -0
- package/build/docs/Combobox.md +336 -0
- package/build/docs/CommandMenu.md +208 -0
- package/build/docs/ContextMenu.md +132 -0
- package/build/docs/GUIDELINES.md +380 -0
- package/build/docs/Gauge.md +46 -0
- package/build/docs/GridItem.md +78 -0
- package/build/docs/Icon.md +66 -0
- package/build/docs/IconStack.md +68 -0
- package/build/docs/Img.md +56 -0
- package/build/docs/Input.md +151 -0
- package/build/docs/InputButton.md +246 -0
- package/build/docs/KeyboardInput.md +104 -0
- package/build/docs/ListItem.md +156 -0
- package/build/docs/Loader.md +55 -0
- package/build/docs/LoadingDots.md +45 -0
- package/build/docs/Menu.md +139 -0
- package/build/docs/Modal.md +221 -0
- package/build/docs/ModalAnimation.md +29 -0
- package/build/docs/OverlayAnimation.md +21 -0
- package/build/docs/Pagination.md +102 -0
- package/build/docs/Phone.md +82 -0
- package/build/docs/Pill.md +122 -0
- package/build/docs/Progress.md +53 -0
- package/build/docs/Radio.md +75 -0
- package/build/docs/RelativeTime.md +76 -0
- package/build/docs/Scroller.md +194 -0
- package/build/docs/Select.md +177 -0
- package/build/docs/Sheet.md +133 -0
- package/build/docs/Shimmer.md +76 -0
- package/build/docs/Slider.md +68 -0
- package/build/docs/Snippet.md +99 -0
- package/build/docs/SplitButton.md +157 -0
- package/build/docs/SplitInput.md +157 -0
- package/build/docs/Step.md +52 -0
- package/build/docs/Stepper.md +85 -0
- package/build/docs/Table.md +252 -0
- package/build/docs/Tabs.md +117 -0
- package/build/docs/ThemeSwitcher.md +125 -0
- package/build/docs/Toast.md +140 -0
- package/build/docs/Toggle.md +70 -0
- package/build/docs/Toolbar.md +100 -0
- package/build/docs/Tooltip.md +86 -0
- package/build/docs/_index.json +218 -0
- package/build/docs/templates/changelog.hbs +36 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +163 -0
- package/build/index.js.map +1 -0
- package/build/services/registry.d.ts +11 -0
- package/build/types.d.ts +4 -0
- package/package.json +34 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Progress
|
|
2
|
+
|
|
3
|
+
A linear progress bar showing task completion or usage. The `value` prop controls the filled portion relative to `max`. When `showLabel` is true, a percentage text is displayed next to the bar. Setting `value` to a negative number activates an indeterminate sliding animation for unknown-duration tasks.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```svelte
|
|
8
|
+
<script>
|
|
9
|
+
import { Progress } from 'polymorph-ui-components';
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Progress value={60} />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Required | Default | Description |
|
|
18
|
+
| --------- | --------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| value | `number` | Yes | `-` | Current progress value (0 to max). Values are clamped to the 0-max range. A negative value activates the indeterminate animation for unknown-duration tasks. |
|
|
20
|
+
| max | `number` | No | `100` | The maximum value representing 100% completion. The filled percentage is calculated as (value / max) \* 100. |
|
|
21
|
+
| showLabel | `boolean` | No | `false` | Whether to display the rounded percentage text next to the progress bar. Hidden during indeterminate mode. |
|
|
22
|
+
| testId | `string` | No | `-` | Value for the data-pw attribute, used for end-to-end testing selectors. |
|
|
23
|
+
| classes | `string` | No | `-` | CSS class string applied to the component's top-level element. Useful for theming — define classes with CSS variable overrides and pass them to create variant styles. |
|
|
24
|
+
|
|
25
|
+
## CSS Variables
|
|
26
|
+
|
|
27
|
+
Override these custom properties to theme the component.
|
|
28
|
+
|
|
29
|
+
| Variable | Default | CSS Property | Description |
|
|
30
|
+
| ----------------------------------- | ----------------- | ------------------ | ------------------------------------------------------------- |
|
|
31
|
+
| `--progress-container-width` | `100%` | width | Width of the outer container holding the track and label. |
|
|
32
|
+
| `--progress-container-padding` | `0` | padding | Padding around the progress container. |
|
|
33
|
+
| `--progress-container-gap` | `8px` | gap | Gap between the track and the percentage label. |
|
|
34
|
+
| `--progress-track-height` | `8px` | height | Height of the background track. |
|
|
35
|
+
| `--progress-track-background` | `#e4e4e7` | background | Background color of the unfilled track. |
|
|
36
|
+
| `--progress-track-border-radius` | `4px` | border-radius | Corner rounding of the track. |
|
|
37
|
+
| `--progress-bar-background` | `currentColor` | background | Background color of the filled bar. |
|
|
38
|
+
| `--progress-bar-border-radius` | `4px` | border-radius | Corner rounding of the filled bar. |
|
|
39
|
+
| `--progress-bar-transition` | `width 0.3s ease` | transition | Transition applied when the bar width changes. |
|
|
40
|
+
| `--progress-indeterminate-duration` | `1.5s` | animation-duration | Duration of one cycle of the indeterminate sliding animation. |
|
|
41
|
+
| `--progress-label-font-size` | `14px` | font-size | Font size of the percentage label. |
|
|
42
|
+
| `--progress-label-font-weight` | `500` | font-weight | Font weight of the percentage label. |
|
|
43
|
+
| `--progress-label-color` | `currentColor` | color | Text color of the percentage label. |
|
|
44
|
+
| `--progress-label-font-family` | `inherit` | font-family | Font family of the percentage label. |
|
|
45
|
+
| `--progress-label-margin` | `0` | margin | Margin around the percentage label. |
|
|
46
|
+
|
|
47
|
+
## Web Component
|
|
48
|
+
|
|
49
|
+
Tag: `<pui-progress>`
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<pui-progress value="60" max="100" show-label></pui-progress>
|
|
53
|
+
```
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Radio
|
|
2
|
+
|
|
3
|
+
A single radio button within a group. Multiple Radio components sharing the same `name` form a mutually exclusive group where only one can be selected at a time. Uses a hidden native `<input type="radio">` for accessibility with a fully customizable visual indicator. The `selectedValue` prop is bindable so that all radios in a group stay synchronized.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```svelte
|
|
8
|
+
<script>
|
|
9
|
+
import { Radio } from 'polymorph-ui-components';
|
|
10
|
+
|
|
11
|
+
let selectedPayment = $state('upi');
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Radio name="payment" value="upi" bind:selectedValue={selectedPayment} text="UPI" />
|
|
15
|
+
<Radio name="payment" value="card" bind:selectedValue={selectedPayment} text="Card" />
|
|
16
|
+
<Radio name="payment" value="netbanking" bind:selectedValue={selectedPayment} text="Net Banking" />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Props
|
|
20
|
+
|
|
21
|
+
| Prop | Type | Required | Default | Description |
|
|
22
|
+
| ------------- | --------- | -------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
+
| name | `string` | Yes | — | The group name shared by all radio buttons in the same group. Maps to the native input's `name` attribute. |
|
|
24
|
+
| value | `string` | Yes | — | The value this radio button represents. When selected, `selectedValue` becomes this value. |
|
|
25
|
+
| selectedValue | `string` | No | `''` | The currently selected value in the group. Bindable. When this matches `value`, the radio appears selected. |
|
|
26
|
+
| text | `string` | No | `''` | Label text displayed next to the radio indicator. Hidden when empty. |
|
|
27
|
+
| disabled | `boolean` | No | `false` | When true, the radio button cannot be interacted with and appears in a disabled visual state. |
|
|
28
|
+
| testId | `string` | No | `undefined` | Test identifier applied as `data-pw` attribute on the container for Playwright test selectors. |
|
|
29
|
+
| classes | `string` | No | `-` | CSS class string applied to the component's top-level element. Useful for theming — define classes with CSS variable overrides and pass them to create variant styles. |
|
|
30
|
+
|
|
31
|
+
## Events
|
|
32
|
+
|
|
33
|
+
| Event | Type | Description |
|
|
34
|
+
| -------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
35
|
+
| onchange | `(value: string) => void` | Fires when this radio button is selected. Receives the `value` of the newly selected radio. Does not fire when the radio is deselected by selecting another in the group. |
|
|
36
|
+
|
|
37
|
+
## CSS Variables
|
|
38
|
+
|
|
39
|
+
Override these custom properties to theme the component.
|
|
40
|
+
|
|
41
|
+
| Variable | Default | CSS Property | Description |
|
|
42
|
+
| ------------------------------- | ----------------------------------- | ---------------- | ---------------------------------------------------------------- |
|
|
43
|
+
| `--radio-container-display` | `inline-flex` | display | Display mode of the radio container. |
|
|
44
|
+
| `--radio-container-align-items` | `center` | align-items | Vertical alignment of the indicator and label. |
|
|
45
|
+
| `--radio-container-gap` | `8px` | gap | Space between the radio indicator and label text. |
|
|
46
|
+
| `--radio-container-cursor` | `pointer` | cursor | Cursor style when hovering over the radio. |
|
|
47
|
+
| `--radio-container-opacity` | `1` | opacity | Opacity of the entire radio component. |
|
|
48
|
+
| `--radio-size` | `20px` | width, height | Size of the outer radio circle. |
|
|
49
|
+
| `--radio-border` | `2px solid currentColor` | border | Border of the radio circle when unselected. |
|
|
50
|
+
| `--radio-border-radius` | `50%` | border-radius | Border radius of the outer circle (50% for a perfect circle). |
|
|
51
|
+
| `--radio-background` | `#ffffff` | background-color | Background color of the radio circle when unselected. |
|
|
52
|
+
| `--radio-selected-border` | `2px solid currentColor` | border | Border of the radio circle when selected. |
|
|
53
|
+
| `--radio-selected-background` | `#ffffff` | background-color | Background color of the radio circle when selected. |
|
|
54
|
+
| `--radio-disabled-border` | `2px solid currentColor` | border | Border of the radio circle when disabled. |
|
|
55
|
+
| `--radio-disabled-background` | `transparent` | background-color | Background color of the radio circle when disabled. |
|
|
56
|
+
| `--radio-dot-size` | `10px` | width, height | Size of the inner dot that appears when selected. |
|
|
57
|
+
| `--radio-dot-color` | `currentColor` | background-color | Color of the inner dot when selected. |
|
|
58
|
+
| `--radio-dot-border-radius` | `50%` | border-radius | Border radius of the inner dot (50% for a perfect circle). |
|
|
59
|
+
| `--radio-disabled-dot-color` | `currentColor` | background-color | Color of the inner dot when selected and disabled. |
|
|
60
|
+
| `--radio-hover-border` | `2px solid currentColor` | border | Border of the radio circle on hover (when not disabled). |
|
|
61
|
+
| `--radio-focus-shadow` | `0 0 0 3px currentColor` | box-shadow | Focus ring shadow shown when the radio receives keyboard focus. |
|
|
62
|
+
| `--radio-transition` | `0.2s` | transition | Transition duration for state changes (border, background, dot). |
|
|
63
|
+
| `--radio-text-font-size` | `14px` | font-size | Font size of the label text. |
|
|
64
|
+
| `--radio-text-font-weight` | `400` | font-weight | Font weight of the label text. |
|
|
65
|
+
| `--radio-text-color` | `currentColor` | color | Color of the label text. |
|
|
66
|
+
| `--radio-disabled-text-color` | `currentColor` | color | Color of the label text when disabled. |
|
|
67
|
+
|
|
68
|
+
## Web Component
|
|
69
|
+
|
|
70
|
+
Tag: `<pui-radio>`
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<pui-radio name="color" value="red" text="Red"></pui-radio>
|
|
74
|
+
<pui-radio name="color" value="blue" text="Blue"></pui-radio>
|
|
75
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# RelativeTime
|
|
2
|
+
|
|
3
|
+
Displays a human-readable relative time string (e.g., "5 minutes ago", "in 3 hours") that auto-updates at a configurable interval. Uses `Intl.RelativeTimeFormat` for locale-aware formatting. Renders a semantic `<time>` element with an ISO `datetime` attribute. Optionally wraps the text in a Tooltip showing the full date and time.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```svelte
|
|
8
|
+
<script>
|
|
9
|
+
import { RelativeTime } from 'polymorph-ui-components';
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<RelativeTime date={new Date('2025-12-25T00:00:00')} />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### With Tooltip
|
|
16
|
+
|
|
17
|
+
```svelte
|
|
18
|
+
<RelativeTime date="2025-01-15T10:30:00Z" tooltip />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Short Format
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<RelativeTime date={Date.now() - 300000} format="short" />
|
|
25
|
+
<!-- Renders: "5 min. ago" -->
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Props
|
|
29
|
+
|
|
30
|
+
| Prop | Type | Required | Default | Description |
|
|
31
|
+
| -------------- | ------------------------------- | -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
32
|
+
| date | `Date \| string \| number` | Yes | `-` | The target date to compute relative time from. Accepts a `Date` object, an ISO date string, or a Unix timestamp in milliseconds. |
|
|
33
|
+
| locale | `string` | No | `-` | BCP 47 locale tag for formatting (e.g., `'en-US'`, `'fr'`, `'ja'`). Defaults to the browser's locale when not specified. |
|
|
34
|
+
| format | `'long' \| 'short' \| 'narrow'` | No | `'long'` | The formatting style. `'long'` = "5 minutes ago", `'short'` = "5 min. ago", `'narrow'` = "5m ago". |
|
|
35
|
+
| updateInterval | `number` | No | `60000` | How often (in milliseconds) to recalculate the relative time string. Set to `0` to disable auto-updates. |
|
|
36
|
+
| tooltip | `boolean` | No | `false` | When true, wraps the time element in a Tooltip that shows the full date and time on hover (e.g., "Wednesday, January 15, 2025 at 10:30 AM"). |
|
|
37
|
+
| testId | `string` | No | `-` | Value for the `data-pw` attribute on the `<time>` element, used for Playwright selectors. |
|
|
38
|
+
| classes | `string` | No | `-` | CSS class string applied to the component's top-level element. Useful for theming — define classes with CSS variable overrides and pass them to create variant styles. |
|
|
39
|
+
|
|
40
|
+
## CSS Variables
|
|
41
|
+
|
|
42
|
+
Override these custom properties to theme the component.
|
|
43
|
+
|
|
44
|
+
| Variable | Default | CSS Property | Description |
|
|
45
|
+
| ----------------------------- | --------- | ------------ | -------------------------------------------- |
|
|
46
|
+
| `--relative-time-font-size` | `14px` | font-size | Font size of the relative time text. |
|
|
47
|
+
| `--relative-time-font-weight` | `400` | font-weight | Font weight of the relative time text. |
|
|
48
|
+
| `--relative-time-font-family` | `-` | font-family | Font family of the relative time text. |
|
|
49
|
+
| `--relative-time-color` | `inherit` | color | Text color of the relative time. |
|
|
50
|
+
| `--relative-time-cursor` | `default` | cursor | Cursor style when hovering the time element. |
|
|
51
|
+
|
|
52
|
+
## Type Reference
|
|
53
|
+
|
|
54
|
+
Custom types used by this component's props:
|
|
55
|
+
|
|
56
|
+
### RelativeTimeFormat
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
type RelativeTimeFormat = 'long' | 'short' | 'narrow';
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Internal Dependencies
|
|
63
|
+
|
|
64
|
+
This component uses the following library components internally:
|
|
65
|
+
|
|
66
|
+
- Tooltip (when `tooltip` prop is true)
|
|
67
|
+
|
|
68
|
+
## Web Component
|
|
69
|
+
|
|
70
|
+
Tag: `<pui-relative-time>`
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<pui-relative-time locale="en-US"></pui-relative-time>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
> **Note:** The `date` prop is a Date object — set it via JavaScript property.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Scroller
|
|
2
|
+
|
|
3
|
+
Overflowing horizontal or vertical item list with scroll controls. Shows navigation arrows when content overflows, with gradient fade edges to hint at more content. Supports drag-to-scroll, snap-to-item, and scroll position tracking.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```svelte
|
|
8
|
+
import {Scroller} from 'polymorph-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### Mandatory Properties
|
|
14
|
+
|
|
15
|
+
| Property | Type | Description |
|
|
16
|
+
| ---------- | --------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
17
|
+
| `children` | `Snippet` | The scrollable content rendered inside the scroll container. Each direct child element becomes a scrollable item. |
|
|
18
|
+
|
|
19
|
+
### Optional Properties
|
|
20
|
+
|
|
21
|
+
| Property | Type | Default | Description |
|
|
22
|
+
| ------------------- | ---------------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
+
| `direction` | `'horizontal' \| 'vertical'` | `'horizontal'` | Controls the scroll axis. When `'horizontal'`, content scrolls left/right. When `'vertical'`, content scrolls up/down. |
|
|
24
|
+
| `scrollAmount` | `number` | Container client size | The number of pixels to scroll when an arrow is clicked. Defaults to one full page width (horizontal) or height (vertical) of the visible container. |
|
|
25
|
+
| `showArrows` | `boolean` | `true` | Whether to show navigation arrow buttons when content overflows. Arrows auto-hide when scrolled to the start or end. |
|
|
26
|
+
| `showGradient` | `boolean` | `true` | Whether to show gradient fade overlays at the edges of the scroll container to visually hint at more content. |
|
|
27
|
+
| `dragToScroll` | `boolean` | `false` | Enables click-and-drag scrolling with the mouse. When active, the cursor changes to a grabbing hand during drag. |
|
|
28
|
+
| `snapToItem` | `boolean` | `false` | Enables CSS scroll snapping so the scroll position aligns to child item boundaries. Child items should have `scroll-snap-align` set (e.g., `scroll-snap-align: start`). |
|
|
29
|
+
| `hideScrollbar` | `boolean` | `true` | Whether to hide the native browser scrollbar. When `true`, the scrollbar is hidden via CSS while maintaining scroll functionality. |
|
|
30
|
+
| `hideArrowsOnTouch` | `boolean` | `true` | Whether to auto-hide navigation arrows on touch-capable devices where swiping is the natural scroll interaction. |
|
|
31
|
+
| `smoothScroll` | `boolean` | `true` | Whether arrow-click scrolling uses smooth animated transitions or jumps instantly. |
|
|
32
|
+
| `testId` | `string` | `undefined` | Sets `data-pw` on the root element. Arrow buttons get `{testId}-prev` and `{testId}-next`. |
|
|
33
|
+
| `arrowPrevious` | `Snippet` | Built-in chevron SVG | Custom snippet to render inside the previous/back arrow button, replacing the default chevron icon. |
|
|
34
|
+
| `arrowNext` | `Snippet` | Built-in chevron SVG | Custom snippet to render inside the next/forward arrow button, replacing the default chevron icon. |
|
|
35
|
+
| `classes` | `string` | `-` | CSS class string applied to the component's top-level element. Useful for theming — define classes with CSS variable overrides and pass them to create variant styles. |
|
|
36
|
+
|
|
37
|
+
### Event Properties
|
|
38
|
+
|
|
39
|
+
| Property | Type | Description |
|
|
40
|
+
| ------------------ | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `onscrollposition` | `(position: ScrollPosition) => void` | Called whenever the scroll position changes (on scroll, resize, or content change). Receives a `ScrollPosition` object with current scroll metrics and progress (0 to 1). |
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
### Basic Horizontal Scroller
|
|
46
|
+
|
|
47
|
+
```svelte
|
|
48
|
+
<Scroller>
|
|
49
|
+
{#each items as item}
|
|
50
|
+
<div class="card">{item.name}</div>
|
|
51
|
+
{/each}
|
|
52
|
+
</Scroller>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Vertical Scroller
|
|
56
|
+
|
|
57
|
+
```svelte
|
|
58
|
+
<Scroller direction="vertical">
|
|
59
|
+
{#each items as item}
|
|
60
|
+
<div class="row">{item.name}</div>
|
|
61
|
+
{/each}
|
|
62
|
+
</Scroller>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### With Drag-to-Scroll and Snap
|
|
66
|
+
|
|
67
|
+
```svelte
|
|
68
|
+
<Scroller dragToScroll snapToItem>
|
|
69
|
+
{#each items as item}
|
|
70
|
+
<div class="snap-card" style="scroll-snap-align: start;">
|
|
71
|
+
{item.name}
|
|
72
|
+
</div>
|
|
73
|
+
{/each}
|
|
74
|
+
</Scroller>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Custom Arrow Icons
|
|
78
|
+
|
|
79
|
+
```svelte
|
|
80
|
+
<Scroller>
|
|
81
|
+
{#snippet arrowPrevious()}
|
|
82
|
+
<span>←</span>
|
|
83
|
+
{/snippet}
|
|
84
|
+
{#snippet arrowNext()}
|
|
85
|
+
<span>→</span>
|
|
86
|
+
{/snippet}
|
|
87
|
+
{#each items as item}
|
|
88
|
+
<div>{item.name}</div>
|
|
89
|
+
{/each}
|
|
90
|
+
</Scroller>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Tracking Scroll Position
|
|
94
|
+
|
|
95
|
+
```svelte
|
|
96
|
+
<script>
|
|
97
|
+
function handleScroll(position) {
|
|
98
|
+
console.log(`Progress: ${(position.progress * 100).toFixed(0)}%`);
|
|
99
|
+
}
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
<Scroller onscrollposition={handleScroll}>
|
|
103
|
+
{#each items as item}
|
|
104
|
+
<div>{item.name}</div>
|
|
105
|
+
{/each}
|
|
106
|
+
</Scroller>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## CSS Custom Properties
|
|
110
|
+
|
|
111
|
+
### Container
|
|
112
|
+
|
|
113
|
+
| Variable | Default | Description |
|
|
114
|
+
| ---------------------------- | ------------- | ----------------------------------------------------------------------------------------- |
|
|
115
|
+
| `--scroller-width` | `100%` | Width of the entire scroller component including arrows. |
|
|
116
|
+
| `--scroller-height` | `fit-content` | Height of the entire scroller component. Useful for vertical scrollers with fixed height. |
|
|
117
|
+
| `--scroller-gap` | `0px` | Gap between child items inside the scroll container. |
|
|
118
|
+
| `--scroller-padding` | `0px` | Padding inside the scroll container around the child items. |
|
|
119
|
+
| `--scroller-scroll-behavior` | `smooth` | CSS scroll-behavior for the scroll container. Controls transition style. |
|
|
120
|
+
|
|
121
|
+
### Arrows
|
|
122
|
+
|
|
123
|
+
| Variable | Default | Description |
|
|
124
|
+
| ----------------------------------- | --------------------------------- | ---------------------------------------------------------------------- |
|
|
125
|
+
| `--scroller-arrow-size` | `32px` | Width and height of the circular arrow buttons. |
|
|
126
|
+
| `--scroller-arrow-border-radius` | `50%` | Border radius of arrow buttons. `50%` makes them circular. |
|
|
127
|
+
| `--scroller-arrow-background` | `#ffffff` | Background color of arrow buttons in their default state. |
|
|
128
|
+
| `--scroller-arrow-border` | `1px solid currentColor` | Border of arrow buttons. |
|
|
129
|
+
| `--scroller-arrow-color` | `currentColor` | Icon/text color inside arrow buttons. |
|
|
130
|
+
| `--scroller-arrow-padding` | `4px` | Internal padding of arrow buttons. |
|
|
131
|
+
| `--scroller-arrow-box-shadow` | `0 1px 3px rgba(0,0,0,0.12)` | Box shadow applied to arrow buttons for depth. |
|
|
132
|
+
| `--scroller-arrow-margin` | `0px` | Margin around each arrow button for spacing from the scroll area. |
|
|
133
|
+
| `--scroller-arrow-hover-background` | `transparent` | Background color of arrow buttons on hover. |
|
|
134
|
+
| `--scroller-arrow-hover-color` | Inherits `--scroller-arrow-color` | Icon/text color of arrow buttons on hover. |
|
|
135
|
+
| `--scroller-arrow-icon-size` | `16px` | Width and height of the default chevron SVG icon inside arrow buttons. |
|
|
136
|
+
|
|
137
|
+
### Gradients
|
|
138
|
+
|
|
139
|
+
| Variable | Default | Description |
|
|
140
|
+
| --------------------------- | ----------------------------- | --------------------------------------------------------------------- |
|
|
141
|
+
| `--scroller-gradient-size` | `80px` | Width (horizontal) or height (vertical) of the gradient fade overlay. |
|
|
142
|
+
| `--scroller-gradient-start` | White-to-transparent gradient | Custom gradient for the start (left/top) fade edge. |
|
|
143
|
+
| `--scroller-gradient-end` | White-to-transparent gradient | Custom gradient for the end (right/bottom) fade edge. |
|
|
144
|
+
|
|
145
|
+
### Snap
|
|
146
|
+
|
|
147
|
+
| Variable | Default | Description |
|
|
148
|
+
| ---------------------- | ----------------------------- | ------------------------------------------------------------------------------------ |
|
|
149
|
+
| `--scroller-snap-type` | `x mandatory` / `y mandatory` | CSS scroll-snap-type value. Automatically adapts to direction but can be overridden. |
|
|
150
|
+
|
|
151
|
+
## Type Reference
|
|
152
|
+
|
|
153
|
+
### ScrollDirection
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
type ScrollDirection = 'horizontal' | 'vertical';
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### ScrollPosition
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
type ScrollPosition = {
|
|
163
|
+
scrollOffset: number; // Current scroll offset in pixels
|
|
164
|
+
scrollSize: number; // Total scrollable content size in pixels
|
|
165
|
+
clientSize: number; // Visible container size in pixels
|
|
166
|
+
progress: number; // Scroll progress from 0 (start) to 1 (end)
|
|
167
|
+
};
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### ScrollerProperties
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
type ScrollerProperties = OptionalScrollerProperties &
|
|
174
|
+
ScrollerEventProperties &
|
|
175
|
+
MandatoryScrollerProperties;
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Web Component
|
|
179
|
+
|
|
180
|
+
Tag: `<pui-scroller>`
|
|
181
|
+
|
|
182
|
+
```html
|
|
183
|
+
<pui-scroller direction="horizontal" show-arrows>
|
|
184
|
+
<div>Scrollable content</div>
|
|
185
|
+
</pui-scroller>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Slots
|
|
189
|
+
|
|
190
|
+
| Slot Name | Maps to Snippet | Description |
|
|
191
|
+
| ---------------- | --------------- | --------------------------- |
|
|
192
|
+
| _(default)_ | `children` | Scrollable content. |
|
|
193
|
+
| `arrow-previous` | `arrowPrevious` | Custom previous/left arrow. |
|
|
194
|
+
| `arrow-next` | `arrowNext` | Custom next/right arrow. |
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Select
|
|
2
|
+
|
|
3
|
+
A dropdown selector that supports single and multi-select modes with optional search filtering. In single-select mode, clicking an item selects it and closes the dropdown. In multi-select mode, clicking items toggles them on or off and the dropdown stays open. Selected items in multi-select are shown as dismissible pills. Supports keyboard navigation (Arrow keys, Enter, Escape, Backspace) and closes automatically when clicking outside. The `value` prop is bindable.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```svelte
|
|
8
|
+
<script>
|
|
9
|
+
import { Select } from 'polymorph-ui-components';
|
|
10
|
+
|
|
11
|
+
const items = [
|
|
12
|
+
{ id: 'apple', label: 'Apple' },
|
|
13
|
+
{ id: 'banana', label: 'Banana' },
|
|
14
|
+
{ id: 'cherry', label: 'Cherry' }
|
|
15
|
+
];
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<Select {items} placeholder="Pick a fruit" onchange={(val) => console.log(val)} />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Multi-Select with Search
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<Select {items} multiple searchable placeholder="Search fruits..." bind:value={selectedIds} />
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Props
|
|
28
|
+
|
|
29
|
+
| Prop | Type | Required | Default | Description |
|
|
30
|
+
| ----------- | -------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
31
|
+
| items | `SelectItem[]` | Yes | - | Array of selectable options. Each item has an `id` and a `label`. |
|
|
32
|
+
| value | `string[]` | No | `[]` | Bindable. Array of selected item IDs. In single-select mode, contains at most one element. |
|
|
33
|
+
| multiple | `boolean` | No | `false` | Enables multi-select mode. Items are toggled on/off and displayed as dismissible pills in the trigger area. |
|
|
34
|
+
| searchable | `boolean` | No | `false` | Enables a text input in the trigger area for filtering items by label. Works in both single and multi-select modes. |
|
|
35
|
+
| placeholder | `string` | No | `''` | Text shown when no item is selected (or in the search input when empty). |
|
|
36
|
+
| disabled | `boolean` | No | `false` | When true, the select is non-interactive, has reduced opacity, and pointer events are disabled. |
|
|
37
|
+
| testId | `string` | No | - | Value for the `data-pw` attribute on the container element, used for end-to-end testing selectors. |
|
|
38
|
+
| classes | `string` | No | - | CSS class string applied to the component's top-level element. Useful for theming — define classes with CSS variable overrides and pass them to create variant styles. |
|
|
39
|
+
|
|
40
|
+
## Events
|
|
41
|
+
|
|
42
|
+
| Event | Type | Description |
|
|
43
|
+
| -------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
44
|
+
| onchange | `(value: string[]) => void` | Fires when the selection changes. Receives the full array of selected item IDs. In single-select mode, the array has one element. |
|
|
45
|
+
|
|
46
|
+
## CSS Variables
|
|
47
|
+
|
|
48
|
+
Override these custom properties to theme the component.
|
|
49
|
+
|
|
50
|
+
### Root
|
|
51
|
+
|
|
52
|
+
| Variable | Default | CSS Property | Description |
|
|
53
|
+
| ---------------------- | --------- | ------------ | ------------------------------------- |
|
|
54
|
+
| `--select-width` | `100%` | width | Width of the select container. |
|
|
55
|
+
| `--select-font-family` | `inherit` | font-family | Font family for the select component. |
|
|
56
|
+
| `--select-font-size` | `14px` | font-size | Font size for the select component. |
|
|
57
|
+
| `--select-color` | `currentColor` | color | Text color of the select component. |
|
|
58
|
+
|
|
59
|
+
### Disabled State
|
|
60
|
+
|
|
61
|
+
| Variable | Default | CSS Property | Description |
|
|
62
|
+
| --------------------------- | ------------- | ------------ | ----------------------------------------- |
|
|
63
|
+
| `--select-disabled-opacity` | `0.5` | opacity | Opacity when the select is disabled. |
|
|
64
|
+
| `--select-disabled-cursor` | `not-allowed` | cursor | Cursor shown when the select is disabled. |
|
|
65
|
+
|
|
66
|
+
### Trigger
|
|
67
|
+
|
|
68
|
+
| Variable | Default | CSS Property | Description |
|
|
69
|
+
| ------------------------------------- | -------------------------------------- | ------------- | ----------------------------------------------------------- |
|
|
70
|
+
| `--select-trigger-gap` | `4px` | gap | Gap between items (pills, input, value) inside the trigger. |
|
|
71
|
+
| `--select-trigger-min-height` | `40px` | min-height | Minimum height of the trigger area. |
|
|
72
|
+
| `--select-trigger-padding` | `8px 12px` | padding | Inner padding of the trigger area. |
|
|
73
|
+
| `--select-trigger-background` | `#ffffff` | background | Background color of the trigger area. |
|
|
74
|
+
| `--select-trigger-border` | `1px solid currentColor` | border | Border of the trigger area. |
|
|
75
|
+
| `--select-trigger-border-radius` | `6px` | border-radius | Corner rounding of the trigger area. |
|
|
76
|
+
| `--select-trigger-transition` | `border-color 0.15s, box-shadow 0.15s` | transition | Transition for trigger hover/focus effects. |
|
|
77
|
+
| `--select-trigger-hover-border-color` | `currentColor` | border-color | Border color of the trigger on hover. |
|
|
78
|
+
| `--select-trigger-focus-border-color` | `currentColor` | border-color | Border color of the trigger when focused or open. |
|
|
79
|
+
| `--select-trigger-focus-shadow` | `0 0 0 2px currentColor` | box-shadow | Box shadow of the trigger when focused or open. |
|
|
80
|
+
|
|
81
|
+
### Placeholder
|
|
82
|
+
|
|
83
|
+
| Variable | Default | CSS Property | Description |
|
|
84
|
+
| ---------------------------- | --------- | ------------ | ----------------------------------------------------------- |
|
|
85
|
+
| `--select-placeholder-color` | `currentColor` | color | Text color of the placeholder and search input placeholder. |
|
|
86
|
+
|
|
87
|
+
### Arrow
|
|
88
|
+
|
|
89
|
+
| Variable | Default | CSS Property | Description |
|
|
90
|
+
| ---------------------- | --------- | ------------- | ----------------------------------------- |
|
|
91
|
+
| `--select-arrow-size` | `16px` | width, height | Size of the dropdown chevron arrow icon. |
|
|
92
|
+
| `--select-arrow-color` | `currentColor` | color | Color of the dropdown chevron arrow icon. |
|
|
93
|
+
|
|
94
|
+
### Dropdown
|
|
95
|
+
|
|
96
|
+
| Variable | Default | CSS Property | Description |
|
|
97
|
+
| --------------------------------- | ------------------------------- | ------------- | ------------------------------------------------ |
|
|
98
|
+
| `--select-dropdown-gap` | `4px` | margin-top | Gap between the trigger and the dropdown panel. |
|
|
99
|
+
| `--select-dropdown-background` | `#ffffff` | background | Background color of the dropdown panel. |
|
|
100
|
+
| `--select-dropdown-border` | `1px solid currentColor` | border | Border of the dropdown panel. |
|
|
101
|
+
| `--select-dropdown-border-radius` | `8px` | border-radius | Corner rounding of the dropdown panel. |
|
|
102
|
+
| `--select-dropdown-shadow` | `0 4px 12px rgba(0, 0, 0, 0.1)` | box-shadow | Box shadow of the dropdown panel. |
|
|
103
|
+
| `--select-dropdown-max-height` | `200px` | max-height | Maximum height of the dropdown (scrolls beyond). |
|
|
104
|
+
| `--select-dropdown-z-index` | `10` | z-index | Stack order of the dropdown panel. |
|
|
105
|
+
|
|
106
|
+
### Options
|
|
107
|
+
|
|
108
|
+
| Variable | Default | CSS Property | Description |
|
|
109
|
+
| ------------------------------------------- | ---------------------------------------------- | ------------ | ----------------------------------------------------- |
|
|
110
|
+
| `--select-option-padding` | `8px 12px` | padding | Padding inside each dropdown option. |
|
|
111
|
+
| `--select-option-color` | `currentColor` | color | Text color of dropdown options. |
|
|
112
|
+
| `--select-option-font-size` | `inherit` | font-size | Font size of dropdown options. |
|
|
113
|
+
| `--select-option-hover-background` | `#f4f4f5` | background | Background of options on hover or keyboard highlight. |
|
|
114
|
+
| `--select-option-hover-color` | inherits `--select-option-color` | color | Text color of options on hover or keyboard highlight. |
|
|
115
|
+
| `--select-option-selected-background` | `#18181b` | background | Background of selected options. |
|
|
116
|
+
| `--select-option-selected-color` | `#ffffff` | color | Text color of selected options. |
|
|
117
|
+
| `--select-option-selected-hover-background` | inherits `--select-option-selected-background` | background | Background of selected options on hover. |
|
|
118
|
+
|
|
119
|
+
### Empty State
|
|
120
|
+
|
|
121
|
+
| Variable | Default | CSS Property | Description |
|
|
122
|
+
| --------------------------- | ---------- | ------------ | ------------------------------------------------ |
|
|
123
|
+
| `--select-empty-padding` | `8px 12px` | padding | Padding of the "No results" empty state message. |
|
|
124
|
+
| `--select-empty-color` | `currentColor` | color | Text color of the empty state message. |
|
|
125
|
+
| `--select-empty-font-style` | `italic` | font-style | Font style of the empty state message. |
|
|
126
|
+
| `--select-empty-font-size` | `inherit` | font-size | Font size of the empty state message. |
|
|
127
|
+
|
|
128
|
+
### Pills (Multi-Select)
|
|
129
|
+
|
|
130
|
+
These variables style the Pill components shown for selected items in multi-select mode. They are forwarded to the internal Pill component.
|
|
131
|
+
|
|
132
|
+
| Variable | Default | CSS Property | Description |
|
|
133
|
+
| ----------------------------- | --------- | ------------- | ---------------------------------------- |
|
|
134
|
+
| `--select-pill-background` | `#18181b` | background | Background color of selected item pills. |
|
|
135
|
+
| `--select-pill-color` | `#ffffff` | color | Text color of selected item pills. |
|
|
136
|
+
| `--select-pill-border-radius` | `999px` | border-radius | Corner rounding of selected item pills. |
|
|
137
|
+
| `--select-pill-padding` | `2px 8px` | padding | Padding inside selected item pills. |
|
|
138
|
+
| `--select-pill-font-size` | `14px` | font-size | Font size of selected item pills. |
|
|
139
|
+
|
|
140
|
+
## Type Reference
|
|
141
|
+
|
|
142
|
+
Custom types used by this component's props and events:
|
|
143
|
+
|
|
144
|
+
### SelectItem
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
type SelectItem = {
|
|
148
|
+
id: string;
|
|
149
|
+
label: string;
|
|
150
|
+
};
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Internal Dependencies
|
|
154
|
+
|
|
155
|
+
This component uses the following library components internally:
|
|
156
|
+
|
|
157
|
+
- Pill (for displaying selected items in multi-select mode)
|
|
158
|
+
|
|
159
|
+
## Web Component
|
|
160
|
+
|
|
161
|
+
Tag: `<pui-select>`
|
|
162
|
+
|
|
163
|
+
```html
|
|
164
|
+
<pui-select placeholder="Pick a fruit"></pui-select>
|
|
165
|
+
|
|
166
|
+
<script>
|
|
167
|
+
const el = document.querySelector('pui-select');
|
|
168
|
+
el.items = [
|
|
169
|
+
{ id: 'apple', label: 'Apple' },
|
|
170
|
+
{ id: 'banana', label: 'Banana' },
|
|
171
|
+
{ id: 'cherry', label: 'Cherry' }
|
|
172
|
+
];
|
|
173
|
+
el.addEventListener('change', (e) => console.log(e.detail));
|
|
174
|
+
</script>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
> **Note:** The `items` and `value` props are arrays — set them via JavaScript properties, not HTML attributes.
|