@florid-kit/components 0.0.1-next.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/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@florid-kit/components",
3
+ "version": "0.0.1-next.1",
4
+ "main": "index.js",
5
+ "module": "index.mjs",
6
+ "typings": "index.d.ts",
7
+ "description": "This library was generated with [Nx](https://nx.dev).",
8
+ "dependencies": {
9
+ "@florid-kit/tokens": "^0.0.0-next.4"
10
+ },
11
+ "devDependencies": {
12
+ "@storybook/addon-essentials": "^8.1.5",
13
+ "@storybook/addon-interactions": "^8.1.5",
14
+ "@storybook/core-server": "^8.1.5",
15
+ "@storybook/web-components": "^8.1.5",
16
+ "@storybook/web-components-vite": "^8.1.5",
17
+ "@swc-node/register": "^1.6.8",
18
+ "storybook": "^8.1.5"
19
+ },
20
+ "author": "",
21
+ "license": "ISC",
22
+ "publishConfig": {
23
+ "directory": "dist"
24
+ }
25
+ }
@@ -0,0 +1,76 @@
1
+ import { ReactiveController } from 'lit';
2
+
3
+ /**
4
+ * An element that supports single-selection with `SingleSelectionController`.
5
+ */
6
+ export interface SingleSelectionElement extends HTMLElement {
7
+ /**
8
+ * Whether or not the element is selected.
9
+ */
10
+ checked: boolean;
11
+ }
12
+ /**
13
+ * A `ReactiveController` that provides root node-scoped single selection for
14
+ * elements, similar to native `<input type="radio">` selection.
15
+ *
16
+ * To use, elements should add the controller and call
17
+ * `selectionController.handleCheckedChange()` in a getter/setter. This must
18
+ * be synchronous to match native behavior.
19
+ *
20
+ * @example
21
+ * const CHECKED = Symbol('checked');
22
+ *
23
+ * class MyToggle extends LitElement {
24
+ * get checked() { return this[CHECKED]; }
25
+ * set checked(checked: boolean) {
26
+ * const oldValue = this.checked;
27
+ * if (oldValue === checked) {
28
+ * return;
29
+ * }
30
+ *
31
+ * this[CHECKED] = checked;
32
+ * this.selectionController.handleCheckedChange();
33
+ * this.requestUpdate('checked', oldValue);
34
+ * }
35
+ *
36
+ * [CHECKED] = false;
37
+ *
38
+ * private selectionController = new SingleSelectionController(this);
39
+ *
40
+ * constructor() {
41
+ * super();
42
+ * this.addController(this.selectionController);
43
+ * }
44
+ * }
45
+ */
46
+ export declare class SingleSelectionController implements ReactiveController {
47
+ private readonly host;
48
+ private focused;
49
+ private root;
50
+ constructor(host: SingleSelectionElement);
51
+ hostConnected(): void;
52
+ hostDisconnected(): void;
53
+ /**
54
+ * Should be called whenever the host's `checked` property changes
55
+ * synchronously.
56
+ */
57
+ handleCheckedChange(): void;
58
+ private readonly handleFocusIn;
59
+ private readonly handleFocusOut;
60
+ private uncheckSiblings;
61
+ /**
62
+ * Updates the `tabindex` of the host and its siblings.
63
+ */
64
+ private updateTabIndices;
65
+ /**
66
+ * Retrieves all siblings in the host element's root with the same `name`
67
+ * attribute.
68
+ */
69
+ private getNamedSiblings;
70
+ /**
71
+ * Handles arrow key events from the host. Using the arrow keys will
72
+ * select and check the next or previous sibling with the host's
73
+ * `name` attribute.
74
+ */
75
+ private readonly handleKeyDown;
76
+ }