revotech-ui-kit 0.0.0 → 0.0.2-beta
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/deploy-storybook.yml +107 -0
- package/.storybook/main.ts +3 -3
- package/assume_role.sh +18 -0
- package/dist/183c6c38.js +1 -0
- package/dist/f28fd4b1.js +1 -0
- package/dist/index.ts +1 -0
- package/dist/public/globals.css +2215 -0
- package/dist/public/tailwind-lib.css +115 -0
- package/dist/src/assets/icons/arrows.icon.js +20 -0
- package/dist/src/assets/icons/arrows.icon.js.map +1 -0
- package/dist/src/assets/icons/index.js +4 -0
- package/dist/src/assets/icons/index.js.map +1 -0
- package/dist/src/assets/icons/search.icon.js +19 -0
- package/dist/src/assets/icons/search.icon.js.map +1 -0
- package/dist/src/assets/icons/tick.icon.js +20 -0
- package/dist/src/assets/icons/tick.icon.js.map +1 -0
- package/dist/src/components/atoms/alert/alert-description.js +18 -0
- package/dist/src/components/atoms/alert/alert-description.js.map +1 -0
- package/dist/src/components/atoms/alert/alert-title.js +20 -0
- package/dist/src/components/atoms/alert/alert-title.js.map +1 -0
- package/dist/src/components/atoms/alert/alert.atom.js +55 -0
- package/dist/src/components/atoms/alert/alert.atom.js.map +1 -0
- package/dist/src/components/atoms/alert/alert.stories.js +62 -0
- package/dist/src/components/atoms/alert/alert.stories.js.map +1 -0
- package/dist/src/components/atoms/alert/alert.styles.js +21 -0
- package/dist/src/components/atoms/alert/alert.styles.js.map +1 -0
- package/dist/src/components/atoms/alert/alert.types.js +2 -0
- package/dist/src/components/atoms/alert/alert.types.js.map +1 -0
- package/dist/src/components/atoms/badge/badge.atom.js +43 -0
- package/dist/src/components/atoms/badge/badge.atom.js.map +1 -0
- package/dist/src/components/atoms/badge/badge.stories.js +110 -0
- package/dist/src/components/atoms/badge/badge.stories.js.map +1 -0
- package/dist/src/components/atoms/badge/badge.style.js +17 -0
- package/dist/src/components/atoms/badge/badge.style.js.map +1 -0
- package/dist/src/components/atoms/badge/badge.type.js +2 -0
- package/dist/src/components/atoms/badge/badge.type.js.map +1 -0
- package/dist/src/components/atoms/button/button.atom.js +67 -0
- package/dist/src/components/atoms/button/button.atom.js.map +1 -0
- package/dist/src/components/atoms/button/button.stories.js +204 -0
- package/dist/src/components/atoms/button/button.stories.js.map +1 -0
- package/dist/src/components/atoms/button/button.style.js +24 -0
- package/dist/src/components/atoms/button/button.style.js.map +1 -0
- package/dist/src/components/atoms/button/button.type.js +2 -0
- package/dist/src/components/atoms/button/button.type.js.map +1 -0
- package/dist/src/components/atoms/card/card-content.js +17 -0
- package/dist/src/components/atoms/card/card-content.js.map +1 -0
- package/dist/src/components/atoms/card/card-description.js +17 -0
- package/dist/src/components/atoms/card/card-description.js.map +1 -0
- package/dist/src/components/atoms/card/card-footer.js +17 -0
- package/dist/src/components/atoms/card/card-footer.js.map +1 -0
- package/dist/src/components/atoms/card/card-header.js +17 -0
- package/dist/src/components/atoms/card/card-header.js.map +1 -0
- package/dist/src/components/atoms/card/card-title.js +17 -0
- package/dist/src/components/atoms/card/card-title.js.map +1 -0
- package/dist/src/components/atoms/card/card.atom.js +25 -0
- package/dist/src/components/atoms/card/card.atom.js.map +1 -0
- package/dist/src/components/atoms/card/card.stories.js +136 -0
- package/dist/src/components/atoms/card/card.stories.js.map +1 -0
- package/dist/src/components/atoms/checkbox/checkbox.atom.js +87 -0
- package/dist/src/components/atoms/checkbox/checkbox.atom.js.map +1 -0
- package/dist/src/components/atoms/checkbox/checkbox.stories.js +244 -0
- package/dist/src/components/atoms/checkbox/checkbox.stories.js.map +1 -0
- package/dist/src/components/atoms/checkbox/checkbox.style.js +3 -0
- package/dist/src/components/atoms/checkbox/checkbox.style.js.map +1 -0
- package/dist/src/components/atoms/checkbox/checkbox.type.js +2 -0
- package/dist/src/components/atoms/checkbox/checkbox.type.js.map +1 -0
- package/dist/src/components/atoms/combo-box/combo-box-input.js +47 -0
- package/dist/src/components/atoms/combo-box/combo-box-input.js.map +1 -0
- package/dist/src/components/atoms/combo-box/combo-box-item.js +85 -0
- package/dist/src/components/atoms/combo-box/combo-box-item.js.map +1 -0
- package/dist/src/components/atoms/combo-box/combo-box-list.js +67 -0
- package/dist/src/components/atoms/combo-box/combo-box-list.js.map +1 -0
- package/dist/src/components/atoms/combo-box/combo-box.atom.js +199 -0
- package/dist/src/components/atoms/combo-box/combo-box.atom.js.map +1 -0
- package/dist/src/components/atoms/combo-box/combo-box.stories.js +86 -0
- package/dist/src/components/atoms/combo-box/combo-box.stories.js.map +1 -0
- package/dist/src/components/atoms/command-empty/command-empty.atom.js +54 -0
- package/dist/src/components/atoms/command-empty/command-empty.atom.js.map +1 -0
- package/dist/src/components/atoms/command-group/command-group.atom.js +71 -0
- package/dist/src/components/atoms/command-group/command-group.atom.js.map +1 -0
- package/dist/src/components/atoms/command-item/command-item.atom.js +80 -0
- package/dist/src/components/atoms/command-item/command-item.atom.js.map +1 -0
- package/dist/src/components/atoms/command-list/command-list.atom.js +36 -0
- package/dist/src/components/atoms/command-list/command-list.atom.js.map +1 -0
- package/dist/src/components/atoms/command-separator/command-separator.atom.js +52 -0
- package/dist/src/components/atoms/command-separator/command-separator.atom.js.map +1 -0
- package/dist/src/components/atoms/dialog/dialog-close.js +47 -0
- package/dist/src/components/atoms/dialog/dialog-close.js.map +1 -0
- package/dist/src/components/atoms/dialog/dialog-content.js +72 -0
- package/dist/src/components/atoms/dialog/dialog-content.js.map +1 -0
- package/dist/src/components/atoms/dialog/dialog-footer.js +22 -0
- package/dist/src/components/atoms/dialog/dialog-footer.js.map +1 -0
- package/dist/src/components/atoms/dialog/dialog-header.js +40 -0
- package/dist/src/components/atoms/dialog/dialog-header.js.map +1 -0
- package/dist/src/components/atoms/dialog/dialog-overly.js +20 -0
- package/dist/src/components/atoms/dialog/dialog-overly.js.map +1 -0
- package/dist/src/components/atoms/dialog/dialog-trigger.js +54 -0
- package/dist/src/components/atoms/dialog/dialog-trigger.js.map +1 -0
- package/dist/src/components/atoms/dialog/dialog.atom.js +79 -0
- package/dist/src/components/atoms/dialog/dialog.atom.js.map +1 -0
- package/dist/src/components/atoms/dialog/dialog.stories.js +88 -0
- package/dist/src/components/atoms/dialog/dialog.stories.js.map +1 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-checkbox-Item.js +117 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-checkbox-Item.js.map +1 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-content.js +81 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-content.js.map +1 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-group.js +71 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-group.js.map +1 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-item.js +80 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-item.js.map +1 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-radio-item.js +118 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-radio-item.js.map +1 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-seperator.js +52 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-seperator.js.map +1 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-shortcut.js +20 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-shortcut.js.map +1 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu.atom.js +79 -0
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu.atom.js.map +1 -0
- package/dist/src/components/atoms/dropdownMenu/dropdownMenu.stories.js +211 -0
- package/dist/src/components/atoms/dropdownMenu/dropdownMenu.stories.js.map +1 -0
- package/dist/src/components/atoms/dropdownMenu/dropdownMenu.style.js +4 -0
- package/dist/src/components/atoms/dropdownMenu/dropdownMenu.style.js.map +1 -0
- package/dist/src/components/atoms/index.js +14 -0
- package/dist/src/components/atoms/index.js.map +1 -0
- package/dist/src/components/atoms/input/input.atom.js +93 -0
- package/dist/src/components/atoms/input/input.atom.js.map +1 -0
- package/dist/src/components/atoms/input/input.stories.js +382 -0
- package/dist/src/components/atoms/input/input.stories.js.map +1 -0
- package/dist/src/components/atoms/input/input.styles.js +2 -0
- package/dist/src/components/atoms/input/input.styles.js.map +1 -0
- package/dist/src/components/atoms/input/input.type.js +2 -0
- package/dist/src/components/atoms/input/input.type.js.map +1 -0
- package/dist/src/components/atoms/label/label.atom.js +68 -0
- package/dist/src/components/atoms/label/label.atom.js.map +1 -0
- package/dist/src/components/atoms/label/label.stories.js +85 -0
- package/dist/src/components/atoms/label/label.stories.js.map +1 -0
- package/dist/src/components/atoms/label/label.style.js +3 -0
- package/dist/src/components/atoms/label/label.style.js.map +1 -0
- package/dist/src/components/atoms/popover/popover-content.js +64 -0
- package/dist/src/components/atoms/popover/popover-content.js.map +1 -0
- package/dist/src/components/atoms/popover/popover-trigger.js +51 -0
- package/dist/src/components/atoms/popover/popover-trigger.js.map +1 -0
- package/dist/src/components/atoms/popover/popover.atom.js +40 -0
- package/dist/src/components/atoms/popover/popover.atom.js.map +1 -0
- package/dist/src/components/atoms/popover/popover.stories.js +69 -0
- package/dist/src/components/atoms/popover/popover.stories.js.map +1 -0
- package/dist/src/components/atoms/popover/popover.style.js +21 -0
- package/dist/src/components/atoms/popover/popover.style.js.map +1 -0
- package/dist/src/components/atoms/popover/popover.types.js +4 -0
- package/dist/src/components/atoms/popover/popover.types.js.map +1 -0
- package/dist/src/components/atoms/toggle/defs.js +30 -0
- package/dist/src/components/atoms/toggle/defs.js.map +1 -0
- package/dist/src/components/atoms/toggle/toggle.atom.js +72 -0
- package/dist/src/components/atoms/toggle/toggle.atom.js.map +1 -0
- package/dist/src/components/atoms/toggle/toggle.stories.js +189 -0
- package/dist/src/components/atoms/toggle/toggle.stories.js.map +1 -0
- package/dist/src/components/atoms/toggle/toggle.style.js +19 -0
- package/dist/src/components/atoms/toggle/toggle.style.js.map +1 -0
- package/dist/src/components/command/command.js +410 -0
- package/dist/src/components/command/command.js.map +1 -0
- package/dist/src/components/command/command.stories.js +153 -0
- package/dist/src/components/command/command.stories.js.map +1 -0
- package/dist/src/components/index.js +3 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/molecules/command/command.molecules.js +27 -0
- package/dist/src/components/molecules/command/command.molecules.js.map +1 -0
- package/dist/src/components/molecules/command-input/command-input.atom.js +127 -0
- package/dist/src/components/molecules/command-input/command-input.atom.js.map +1 -0
- package/dist/src/components/molecules/dropdownMenu/dropdownMenu.molecules.js +2 -0
- package/dist/src/components/molecules/dropdownMenu/dropdownMenu.molecules.js.map +1 -0
- package/dist/src/components/molecules/index.js +2 -0
- package/dist/src/components/molecules/index.js.map +1 -0
- package/dist/src/helpers/base-element.js +64 -0
- package/dist/src/helpers/base-element.js.map +1 -0
- package/dist/src/helpers/index.js +4 -0
- package/dist/src/helpers/index.js.map +1 -0
- package/dist/src/helpers/mouse-conroller.helper.js +33 -0
- package/dist/src/helpers/mouse-conroller.helper.js.map +1 -0
- package/dist/src/helpers/style.helpers.js +6 -0
- package/dist/src/helpers/style.helpers.js.map +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/actionable.interface.js +2 -0
- package/dist/src/interfaces/actionable.interface.js.map +1 -0
- package/dist/src/interfaces/atomic.interface.js +2 -0
- package/dist/src/interfaces/atomic.interface.js.map +1 -0
- package/dist/src/interfaces/changeable.interface.js +2 -0
- package/dist/src/interfaces/changeable.interface.js.map +1 -0
- package/dist/src/interfaces/child-support-atomic.interface.js +2 -0
- package/dist/src/interfaces/child-support-atomic.interface.js.map +1 -0
- package/dist/src/interfaces/index.js +7 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/interfaces/intractable.interface.js +2 -0
- package/dist/src/interfaces/intractable.interface.js.map +1 -0
- package/dist/src/interfaces/variant.interface.js +2 -0
- package/dist/src/interfaces/variant.interface.js.map +1 -0
- package/dist/src/lib/index.js +2 -0
- package/dist/src/lib/index.js.map +1 -0
- package/dist/src/lib/next/next.lib.js +2 -0
- package/dist/src/lib/next/next.lib.js.map +1 -0
- package/dist/src/lib/react/react.lib.js +16 -0
- package/dist/src/lib/react/react.lib.js.map +1 -0
- package/dist/src/lib/tw-styles.js +1956 -0
- package/dist/src/lib/tw-styles.js.map +1 -0
- package/dist/src/styles/index.js +2 -0
- package/dist/src/styles/index.js.map +1 -0
- package/dist/src/styles/tw.styles.js +2218 -0
- package/dist/src/styles/tw.styles.js.map +1 -0
- package/dist/src/wc-ui-app.js +88 -0
- package/dist/src/wc-ui-app.js.map +1 -0
- package/dist/sw.js +2 -0
- package/dist/sw.js.map +1 -0
- package/dist/test/wc-ui-app.test.js +18 -0
- package/dist/test/wc-ui-app.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/workbox-a523fd56.js +2 -0
- package/dist/workbox-a523fd56.js.map +1 -0
- package/index.html +18 -66
- package/package.json +41 -18
- package/rollup.config.js +25 -13
- package/src/assets/icons/arrows.icon.ts +20 -0
- package/src/assets/icons/index.ts +3 -0
- package/src/assets/icons/search.icon.ts +19 -0
- package/src/assets/icons/tick.icon.ts +20 -0
- package/src/chai-custom.d.ts +0 -0
- package/src/components/atoms/alert/alert-description.ts +15 -0
- package/src/components/atoms/alert/alert-title.ts +17 -0
- package/src/components/atoms/alert/alert.atom.ts +51 -0
- package/src/components/atoms/alert/alert.stories.ts +71 -0
- package/src/components/atoms/alert/alert.styles.ts +21 -0
- package/src/components/atoms/alert/alert.types.ts +1 -0
- package/src/components/atoms/badge/badge.atom.ts +40 -0
- package/src/components/atoms/badge/badge.stories.ts +118 -0
- package/src/components/atoms/badge/badge.style.ts +24 -0
- package/src/components/atoms/badge/badge.type.ts +7 -0
- package/src/components/atoms/button/button.atom.ts +22 -8
- package/src/components/atoms/button/button.stories.ts +177 -139
- package/src/components/atoms/card/card-content.ts +15 -0
- package/src/components/atoms/card/card-description.ts +15 -0
- package/src/components/atoms/card/card-footer.ts +15 -0
- package/src/components/atoms/card/card-header.ts +15 -0
- package/src/components/atoms/card/card-title.ts +15 -0
- package/src/components/atoms/card/card.atom.ts +31 -0
- package/src/components/atoms/card/card.stories.ts +149 -0
- package/src/components/atoms/checkbox/checkbox.atom.ts +30 -16
- package/src/components/atoms/checkbox/checkbox.stories.ts +292 -25
- package/src/components/atoms/checkbox/checkbox.style.ts +5 -0
- package/src/components/atoms/checkbox/checkbox.type.ts +24 -0
- package/src/components/atoms/combo-box/combo-box-input.ts +33 -0
- package/src/components/atoms/combo-box/combo-box-item.ts +59 -0
- package/src/components/atoms/combo-box/combo-box-list.ts +57 -0
- package/src/components/atoms/combo-box/combo-box.atom.ts +187 -0
- package/src/components/atoms/combo-box/combo-box.stories.ts +95 -0
- package/src/components/atoms/command-empty/command-empty.atom.ts +2 -2
- package/src/components/atoms/command-group/command-group.atom.ts +1 -1
- package/src/components/atoms/command-item/command-item.atom.ts +2 -2
- package/src/components/atoms/command-list/command-list.atom.ts +2 -2
- package/src/components/atoms/command-separator/command-separator.atom.ts +2 -2
- package/src/components/atoms/dialog/dialog-close.ts +50 -0
- package/src/components/atoms/dialog/dialog-content.ts +71 -0
- package/src/components/atoms/dialog/dialog-footer.ts +22 -0
- package/src/components/atoms/dialog/dialog-header.ts +36 -0
- package/src/components/atoms/dialog/dialog-overly.ts +20 -0
- package/src/components/atoms/dialog/dialog-trigger.ts +54 -0
- package/src/components/atoms/dialog/dialog.atom.ts +3 -226
- package/src/components/atoms/dialog/dialog.stories.ts +11 -4
- package/src/components/atoms/dropdownMenu/dropdown-menu-checkbox-Item.ts +106 -0
- package/src/components/atoms/dropdownMenu/dropdown-menu-content.ts +79 -0
- package/src/components/atoms/dropdownMenu/dropdown-menu-group.ts +60 -0
- package/src/components/atoms/dropdownMenu/dropdown-menu-item.ts +74 -0
- package/src/components/atoms/dropdownMenu/dropdown-menu-radio-item.ts +107 -0
- package/src/components/atoms/dropdownMenu/dropdown-menu-seperator.ts +44 -0
- package/src/components/atoms/dropdownMenu/dropdown-menu-shortcut.ts +17 -0
- package/src/components/atoms/dropdownMenu/dropdown-menu.atom.ts +84 -0
- package/src/components/atoms/dropdownMenu/dropdownMenu.stories.ts +220 -0
- package/src/components/atoms/dropdownMenu/dropdownMenu.style.ts +7 -0
- package/src/components/atoms/index.ts +3 -0
- package/src/components/atoms/input/input.atom.ts +64 -10
- package/src/components/atoms/input/input.stories.ts +426 -64
- package/src/components/atoms/input/input.styles.ts +2 -0
- package/src/components/atoms/input/input.type.ts +42 -8
- package/src/components/atoms/label/label.atom.ts +31 -7
- package/src/components/atoms/label/label.stories.ts +87 -3
- package/src/components/atoms/popover/popover-content.ts +58 -0
- package/src/components/atoms/popover/popover-trigger.ts +50 -0
- package/src/components/atoms/popover/popover.atom.ts +34 -0
- package/src/components/atoms/popover/popover.stories.ts +79 -0
- package/src/components/atoms/popover/popover.style.ts +25 -0
- package/src/components/atoms/popover/popover.types.ts +3 -0
- package/src/components/atoms/toggle/defs.ts +29 -0
- package/src/components/atoms/toggle/toggle.atom.ts +58 -0
- package/src/components/atoms/toggle/toggle.stories.ts +204 -0
- package/src/components/atoms/toggle/toggle.style.ts +22 -0
- package/src/components/molecules/command/command.molecules.ts +2 -2
- package/src/components/molecules/command-input/command-input.atom.ts +3 -3
- package/src/components/molecules/dropdownMenu/dropdownMenu.molecules.ts +0 -0
- package/src/globals.css +475 -66
- package/src/helpers/base-element.ts +79 -0
- package/src/helpers/index.ts +1 -0
- package/src/index.ts +0 -0
- package/src/lib/react/react.lib.ts +18 -0
- package/src/lib/tw-styles.ts +1957 -0
- package/src/styles/tw.styles.ts +2051 -1699
- package/src/tailwind-lib.css +26 -6
- package/tailwind.config.js +174 -38
- package/tsconfig.json +6 -1
- package/src/components/popover.ts +0 -247
@@ -1,46 +1,60 @@
|
|
1
1
|
import { LitElement, html, css, nothing } from 'lit';
|
2
2
|
import { property, customElement } from 'lit/decorators.js';
|
3
|
-
import { cn } from '
|
4
|
-
import { TWStyles } from '
|
3
|
+
import { cn } from '../../../helpers';
|
4
|
+
import { TWStyles } from '../../../styles';
|
5
|
+
import { checkboxStyles, iconStyles } from './checkbox.style';
|
6
|
+
import { CheckboxProperties } from './checkbox.type';
|
5
7
|
|
6
8
|
@customElement('rtg-checkbox')
|
7
|
-
export class Checkbox extends LitElement {
|
9
|
+
export class Checkbox extends LitElement implements CheckboxProperties {
|
8
10
|
@property({ type: Boolean }) disabled = false;
|
9
11
|
|
10
12
|
@property({ type: Boolean }) checked = false;
|
11
13
|
|
14
|
+
@property({ type: String }) type = 'text';
|
15
|
+
|
16
|
+
@property({ type: String }) value = '';
|
17
|
+
|
18
|
+
@property({ type: Boolean }) required = false;
|
19
|
+
|
12
20
|
static styles = [css``, TWStyles];
|
13
21
|
|
14
22
|
private _onClick(e: Event) {
|
15
23
|
if (e.defaultPrevented) return;
|
16
24
|
this.checked = !this.checked;
|
25
|
+
this.required = !this.required;
|
26
|
+
|
27
|
+
// Dispatch a custom change event when the state changes
|
28
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
17
29
|
}
|
18
30
|
|
19
31
|
public click() {
|
20
32
|
this.checked = !this.checked;
|
33
|
+
this.required = !this.required;
|
21
34
|
}
|
22
35
|
|
23
|
-
//
|
24
36
|
render() {
|
37
|
+
const additionalProps = { ...this.dataset }; // Example of additional props
|
25
38
|
return html`
|
26
39
|
<button
|
40
|
+
data-testid="checkbox-atom"
|
27
41
|
type="button"
|
28
42
|
role="checkbox"
|
29
|
-
aria-checked="${this.checked}"
|
30
|
-
data-state="${this.checked
|
31
|
-
|
43
|
+
aria-checked="${this.checked || this.value === 'on'}"
|
44
|
+
data-state="${this.checked || this.value === 'on'
|
45
|
+
? 'checked'
|
46
|
+
: 'unchecked'}"
|
47
|
+
value="${this.value}"
|
48
|
+
?required=${this.required}
|
32
49
|
?disabled=${this.disabled}
|
33
50
|
@click="${this._onClick}"
|
34
|
-
class="${cn(
|
35
|
-
|
36
|
-
|
37
|
-
)}
|
51
|
+
class="${cn(checkboxStyles, this.className)}"
|
52
|
+
${Object.entries(additionalProps).map(
|
53
|
+
([key, value]) => html` ${key}="${value}" `
|
54
|
+
)}
|
38
55
|
>
|
39
|
-
${this.checked
|
40
|
-
? html`<span
|
41
|
-
data-state="checked"
|
42
|
-
class="flex items-center justify-center text-current"
|
43
|
-
style="pointer-events: none;"
|
56
|
+
${this.checked || this.value === 'on'
|
57
|
+
? html`<span data-state="checked" class="${iconStyles}"
|
44
58
|
><svg
|
45
59
|
xmlns="http://www.w3.org/2000/svg"
|
46
60
|
width="24"
|
@@ -1,42 +1,309 @@
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/web-components';
|
1
|
+
import type { Meta, StoryFn, StoryContext } from '@storybook/web-components';
|
2
2
|
import { html } from 'lit';
|
3
3
|
import './checkbox.atom';
|
4
|
+
import { expect, within, userEvent, waitFor, fn } from '@storybook/test';
|
5
|
+
import {
|
6
|
+
CheckboxArgs,
|
7
|
+
CheckboxWithRequiredArgs,
|
8
|
+
CheckboxWithValueArgs,
|
9
|
+
} from './checkbox.type';
|
10
|
+
import '../button/button.atom';
|
11
|
+
|
12
|
+
const allowedTypes = ['checkbox'];
|
4
13
|
|
5
14
|
export default {
|
6
|
-
|
7
|
-
component: 'rtg-checkbox',
|
15
|
+
component: 'components/checkbox',
|
8
16
|
tags: ['autodocs'],
|
9
|
-
argTypes: {
|
10
|
-
disabled: { control: 'boolean' },
|
11
|
-
checked: { control: 'boolean' },
|
12
|
-
},
|
13
17
|
} as Meta;
|
14
18
|
|
15
|
-
const
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
const mockOnClickHandler = fn(event => {
|
20
|
+
alert('submit data!');
|
21
|
+
});
|
22
|
+
|
23
|
+
const testCheckboxBehavior = async (
|
24
|
+
args: CheckboxArgs,
|
25
|
+
canvasElement: HTMLElement
|
26
|
+
) => {
|
27
|
+
const canvas = within(canvasElement);
|
28
|
+
const checkbox = await waitFor(() => canvas.getByTestId('checkbox-id'));
|
29
|
+
|
30
|
+
if (checkbox.shadowRoot) {
|
31
|
+
const innerCheckbox = checkbox.shadowRoot.querySelector(
|
32
|
+
'[data-testid="checkbox-atom"]'
|
33
|
+
);
|
34
|
+
|
35
|
+
// 1. Test: Checkbox should have correct Role attribute
|
36
|
+
expect(innerCheckbox).toHaveRole('checkbox');
|
37
|
+
|
38
|
+
// 2. Test: Checkbox should have the correct `checked` state based on args
|
39
|
+
if (args.checked) {
|
40
|
+
expect(innerCheckbox).toBeChecked();
|
41
|
+
} else {
|
42
|
+
expect(innerCheckbox).not.toBeChecked();
|
43
|
+
}
|
44
|
+
|
45
|
+
// 3. Test: Checkbox should be disabled when the `disabled` prop is true
|
46
|
+
if (args.disabled) {
|
47
|
+
expect(innerCheckbox).toBeDisabled();
|
48
|
+
} else {
|
49
|
+
expect(innerCheckbox).not.toBeDisabled();
|
50
|
+
}
|
51
|
+
|
52
|
+
// 4. Test: Label should have correct `for` attribute linking to the checkbox
|
53
|
+
const label = await waitFor(() => canvas.getByText(args.label));
|
54
|
+
expect(label).toBeInTheDocument();
|
55
|
+
expect(label).toHaveAttribute('for', checkbox.getAttribute('id'));
|
56
|
+
}
|
57
|
+
};
|
58
|
+
|
59
|
+
const testCheckboxWithRequiredBehavior = async (
|
60
|
+
args: CheckboxWithRequiredArgs,
|
61
|
+
canvasElement: HTMLElement
|
62
|
+
) => {
|
63
|
+
const canvas = within(canvasElement);
|
64
|
+
const checkbox = await waitFor(() => canvas.getByTestId('checkbox-id'));
|
65
|
+
const button = await waitFor(() => canvas.getByTestId('btn-id'));
|
66
|
+
|
67
|
+
if (checkbox.shadowRoot) {
|
68
|
+
const innerCheckbox = checkbox.shadowRoot.querySelector(
|
69
|
+
'[data-testid="checkbox-atom"]'
|
70
|
+
);
|
71
|
+
|
72
|
+
// Test: Checkbox should have the correct required attribute
|
73
|
+
if (args.required) {
|
74
|
+
expect(innerCheckbox).toHaveAttribute('required');
|
75
|
+
} else {
|
76
|
+
expect(innerCheckbox).not.toHaveAttribute('required');
|
77
|
+
}
|
78
|
+
|
79
|
+
// Test: Button should be disabled when checkbox is unchecked and required is true
|
80
|
+
if (args.required && !args.checked) {
|
81
|
+
expect(button).toBeDisabled();
|
82
|
+
} else if (args.required && args.checked) {
|
83
|
+
expect(button).not.toBeDisabled();
|
84
|
+
}
|
85
|
+
|
86
|
+
// Additional tests for the checked state
|
87
|
+
if (args.checked) {
|
88
|
+
expect(innerCheckbox).toBeChecked();
|
89
|
+
} else {
|
90
|
+
expect(innerCheckbox).not.toBeChecked();
|
91
|
+
}
|
22
92
|
|
23
|
-
|
24
|
-
|
93
|
+
// Additional tests for the disabled state
|
94
|
+
if (args.disabled) {
|
95
|
+
expect(innerCheckbox).toBeDisabled();
|
96
|
+
} else {
|
97
|
+
expect(innerCheckbox).not.toBeDisabled();
|
98
|
+
}
|
99
|
+
}
|
100
|
+
};
|
101
|
+
|
102
|
+
const testCheckboxWithValueBehavior = async (
|
103
|
+
args: CheckboxWithValueArgs,
|
104
|
+
canvasElement: HTMLElement
|
105
|
+
) => {
|
106
|
+
const canvas = within(canvasElement);
|
107
|
+
const checkbox = await waitFor(() => canvas.getByTestId('checkbox-id'));
|
108
|
+
|
109
|
+
if (checkbox.shadowRoot) {
|
110
|
+
const innerCheckbox = checkbox.shadowRoot.querySelector(
|
111
|
+
'[data-testid="checkbox-atom"]'
|
112
|
+
);
|
113
|
+
|
114
|
+
// Test: Checkbox should have the correct value attribute
|
115
|
+
expect(innerCheckbox).toHaveAttribute('value', args.value);
|
116
|
+
|
117
|
+
// Additional tests for disabled state if needed
|
118
|
+
if (args.disabled) {
|
119
|
+
expect(innerCheckbox).toBeDisabled();
|
120
|
+
} else {
|
121
|
+
expect(innerCheckbox).not.toBeDisabled();
|
122
|
+
}
|
123
|
+
}
|
124
|
+
};
|
125
|
+
|
126
|
+
const TemplatewithChecked: StoryFn = ({ disabled, checked, label }) =>
|
127
|
+
html`
|
128
|
+
<div style="display:flex">
|
129
|
+
<rtg-checkbox
|
130
|
+
id="terms"
|
131
|
+
data-testid="checkbox-id"
|
132
|
+
?disabled=${disabled}
|
133
|
+
?checked=${checked}
|
134
|
+
></rtg-checkbox>
|
135
|
+
<rtg-label style="margin:2px 0px 0px 4px" for="terms">${label}</rtg-label>
|
136
|
+
</div>
|
137
|
+
`;
|
138
|
+
|
139
|
+
const TemplatewithRequired: StoryFn = ({
|
140
|
+
disabled,
|
141
|
+
checked,
|
142
|
+
label,
|
143
|
+
required,
|
144
|
+
}) =>
|
145
|
+
html`
|
146
|
+
<div style="display: flex; flex-direction: column;">
|
147
|
+
<div style="display:flex">
|
148
|
+
<rtg-checkbox
|
149
|
+
id="terms"
|
150
|
+
data-testid="checkbox-id"
|
151
|
+
?disabled=${disabled}
|
152
|
+
?checked=${checked}
|
153
|
+
?required=${required}
|
154
|
+
@click=${(e: Event) => {
|
155
|
+
const checkbox = e.target as HTMLInputElement;
|
156
|
+
const button = document.querySelector(
|
157
|
+
'rtg-button'
|
158
|
+
) as HTMLButtonElement;
|
159
|
+
if (button) {
|
160
|
+
button.disabled = required ? !checkbox.checked : false;
|
161
|
+
}
|
162
|
+
}}
|
163
|
+
></rtg-checkbox>
|
164
|
+
<rtg-label style="margin:2px 0px 0px 4px" for="terms"
|
165
|
+
>${label}</rtg-label
|
166
|
+
>
|
167
|
+
</div>
|
168
|
+
<div style="margin-top:16px">
|
169
|
+
<rtg-button
|
170
|
+
variant="default"
|
171
|
+
size="default"
|
172
|
+
data-testid="btn-id"
|
173
|
+
?disabled=${required ? !checked : false}
|
174
|
+
.click=${mockOnClickHandler}
|
175
|
+
>Submit</rtg-button
|
176
|
+
>
|
177
|
+
</div>
|
178
|
+
</div>
|
179
|
+
`;
|
180
|
+
|
181
|
+
const TemplateWithVlaue: StoryFn = ({ disabled, label, value }) =>
|
182
|
+
html`
|
183
|
+
<div style="display:flex">
|
184
|
+
<rtg-checkbox
|
185
|
+
id="terms"
|
186
|
+
data-testid="checkbox-id"
|
187
|
+
value=${value}
|
188
|
+
?disabled=${disabled}
|
189
|
+
></rtg-checkbox>
|
190
|
+
<rtg-label style="margin:2px 0px 0px 4px" for="terms">${label}</rtg-label>
|
191
|
+
</div>
|
192
|
+
`;
|
193
|
+
|
194
|
+
export const CheckboxWithReuired = TemplatewithRequired.bind({});
|
195
|
+
CheckboxWithReuired.args = {
|
25
196
|
disabled: false,
|
26
197
|
checked: false,
|
198
|
+
required: false,
|
27
199
|
label: 'Accept terms and conditions',
|
28
200
|
};
|
29
201
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
202
|
+
CheckboxWithReuired.parameters = {
|
203
|
+
docs: {
|
204
|
+
source: {
|
205
|
+
transform: (code: string, storyContext: StoryContext) => {
|
206
|
+
const args = storyContext.args;
|
207
|
+
|
208
|
+
// Handling boolean attributes: if true, render without value, if false, omit the attribute
|
209
|
+
const updatedCode = code
|
210
|
+
.replace(/disabled=""/g, 'disabled=true')
|
211
|
+
.replace(/checked=""/g, 'checked=true')
|
212
|
+
.replace(/required=""/g, 'required=true')
|
213
|
+
.replace(/disabled="false"/g, '')
|
214
|
+
.replace(/checked="false"/g, '')
|
215
|
+
.replace(/required="false"/g, '');
|
216
|
+
|
217
|
+
return updatedCode;
|
218
|
+
},
|
219
|
+
},
|
220
|
+
},
|
221
|
+
};
|
222
|
+
|
223
|
+
CheckboxWithReuired.argTypes = {
|
224
|
+
disabled: {
|
225
|
+
control: 'boolean',
|
226
|
+
description: 'Determines whether the checkbox is disabled (unclickable).',
|
227
|
+
table: {
|
228
|
+
defaultValue: { summary: 'false' },
|
229
|
+
},
|
230
|
+
docs: {
|
231
|
+
source: {
|
232
|
+
code: (args: { disabled: boolean }) => (args.disabled ? true : ''),
|
233
|
+
},
|
234
|
+
},
|
235
|
+
},
|
236
|
+
checked: {
|
237
|
+
control: 'boolean',
|
238
|
+
description: 'Specifies whether the checkbox is checked by default.',
|
239
|
+
table: {
|
240
|
+
defaultValue: { summary: 'false' },
|
241
|
+
},
|
242
|
+
},
|
243
|
+
required: {
|
244
|
+
control: 'boolean',
|
245
|
+
description:
|
246
|
+
'Marks the checkbox as a required field. When true, the checkbox must be checked for form submission, and related actions such as enabling a submit button are dependent on this state.',
|
247
|
+
table: {
|
248
|
+
defaultValue: { summary: 'false' },
|
249
|
+
},
|
250
|
+
},
|
251
|
+
label: {
|
252
|
+
control: 'text',
|
253
|
+
description:
|
254
|
+
'The text displayed next to the checkbox, describing its purpose.',
|
255
|
+
},
|
35
256
|
};
|
36
257
|
|
37
|
-
|
38
|
-
|
39
|
-
|
258
|
+
CheckboxWithReuired.play = async ({ args, canvasElement }) => {
|
259
|
+
await testCheckboxWithRequiredBehavior(
|
260
|
+
args as CheckboxWithRequiredArgs,
|
261
|
+
canvasElement
|
262
|
+
);
|
263
|
+
};
|
264
|
+
|
265
|
+
export const Checkbox = TemplatewithChecked.bind({});
|
266
|
+
Checkbox.args = {
|
267
|
+
disabled: false,
|
40
268
|
checked: false,
|
41
|
-
label: '
|
269
|
+
label: 'Accept terms and conditions',
|
270
|
+
};
|
271
|
+
|
272
|
+
Checkbox.argTypes = {
|
273
|
+
disabled: {
|
274
|
+
control: 'boolean',
|
275
|
+
},
|
276
|
+
checked: {
|
277
|
+
control: 'boolean',
|
278
|
+
},
|
279
|
+
label: {
|
280
|
+
control: 'text',
|
281
|
+
},
|
282
|
+
};
|
283
|
+
|
284
|
+
Checkbox.play = async ({ args, canvasElement }) => {
|
285
|
+
await testCheckboxBehavior(args as CheckboxArgs, canvasElement);
|
286
|
+
};
|
287
|
+
|
288
|
+
export const CheckboxWithValue = TemplateWithVlaue.bind({});
|
289
|
+
CheckboxWithValue.args = {
|
290
|
+
disabled: false,
|
291
|
+
value: 'off',
|
292
|
+
label: 'Accept terms and conditions',
|
293
|
+
};
|
294
|
+
|
295
|
+
CheckboxWithValue.argTypes = {
|
296
|
+
disabled: { control: 'boolean' },
|
297
|
+
value: {
|
298
|
+
control: { type: 'select' },
|
299
|
+
options: ['on', 'off'],
|
300
|
+
},
|
301
|
+
label: { control: 'text' },
|
302
|
+
};
|
303
|
+
|
304
|
+
CheckboxWithValue.play = async ({ args, canvasElement }) => {
|
305
|
+
await testCheckboxWithValueBehavior(
|
306
|
+
args as CheckboxWithValueArgs,
|
307
|
+
canvasElement
|
308
|
+
);
|
42
309
|
};
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export const checkboxStyles =
|
2
|
+
'peer h-4 w-4 align-middle shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground';
|
3
|
+
|
4
|
+
export const iconStyles =
|
5
|
+
'flex items-center justify-center text-current pointer-events-none';
|
@@ -0,0 +1,24 @@
|
|
1
|
+
export type CheckboxProperties = {
|
2
|
+
disabled: boolean;
|
3
|
+
checked: boolean;
|
4
|
+
};
|
5
|
+
|
6
|
+
export type CheckboxArgs = {
|
7
|
+
disabled: boolean;
|
8
|
+
checked: boolean;
|
9
|
+
label: string;
|
10
|
+
};
|
11
|
+
|
12
|
+
export type CheckboxWithRequiredArgs = {
|
13
|
+
disabled: boolean;
|
14
|
+
checked: boolean;
|
15
|
+
required: boolean;
|
16
|
+
label: string;
|
17
|
+
value?: string;
|
18
|
+
};
|
19
|
+
|
20
|
+
export type CheckboxWithValueArgs = {
|
21
|
+
disabled: boolean;
|
22
|
+
value: string;
|
23
|
+
label: string;
|
24
|
+
};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
3
|
+
import { TWStyles } from '../../../styles';
|
4
|
+
|
5
|
+
@customElement('combo-box-input')
|
6
|
+
export class ComboBoxInput extends LitElement {
|
7
|
+
@property({ type: String }) value = '';
|
8
|
+
@property({ type: Function }) handleClick = () => {};
|
9
|
+
@property({ type: Function }) handleKeyDown = () => {};
|
10
|
+
|
11
|
+
static styles = [css``, TWStyles];
|
12
|
+
|
13
|
+
render() {
|
14
|
+
return html`
|
15
|
+
<input
|
16
|
+
class="inline-flex justify-between items-center w-full h-10 px-4 py-2 whitespace-nowrap rounded-md
|
17
|
+
text-sm font-medium border border-input cursor-pointer
|
18
|
+
ring-offset-background
|
19
|
+
transition-colors disabled:pointer-events-none
|
20
|
+
disabled:opacity-50
|
21
|
+
bg-background hover:bg-accent
|
22
|
+
hover:text-accent-foreground
|
23
|
+
outline-none"
|
24
|
+
role="combobox"
|
25
|
+
aria-expanded="false"
|
26
|
+
readonly="true"
|
27
|
+
.value=${this.value}
|
28
|
+
@click=${this.handleClick}
|
29
|
+
@keydown=${this.handleKeyDown}
|
30
|
+
/>
|
31
|
+
`;
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { LitElement, css, html } from 'lit';
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
3
|
+
import { tickIcon } from '../../../assets/icons';
|
4
|
+
import { TWStyles } from '../../../styles';
|
5
|
+
|
6
|
+
@customElement('combo-box-item')
|
7
|
+
export class ComboBoxItem extends LitElement {
|
8
|
+
@property({ type: String }) key = '';
|
9
|
+
@property({ type: String }) searchText = '';
|
10
|
+
@property({ type: String }) value = '';
|
11
|
+
@property({ type: Number }) tabindex = 0;
|
12
|
+
@property({ type: Boolean }) isSelected = false;
|
13
|
+
@property({ type: String }) class = '';
|
14
|
+
@property({ type: Function }) onSelect = () => {};
|
15
|
+
|
16
|
+
static styles = [css``, TWStyles];
|
17
|
+
|
18
|
+
render() {
|
19
|
+
console.log('this', this.class);
|
20
|
+
return html`
|
21
|
+
<div
|
22
|
+
key="${this.key}"
|
23
|
+
class="flex items-center cursor-pointer py-2 px-4 w-full text-sm text-gray-800
|
24
|
+
rounded-lg
|
25
|
+
hover:bg-gray-100
|
26
|
+
focus:outline-none
|
27
|
+
focus:bg-gray-100
|
28
|
+
dark:bg-neutral-900
|
29
|
+
dark:hover:bg-neutral-800
|
30
|
+
dark:text-neutral-200
|
31
|
+
dark:focus:bg-neutral-800
|
32
|
+
${this.class}
|
33
|
+
"
|
34
|
+
tabindex="${this.tabindex}"
|
35
|
+
aria-selected="${this.isSelected}"
|
36
|
+
data-selected="${this.isSelected}"
|
37
|
+
data-hs-combo-box-output-item=""
|
38
|
+
role="option"
|
39
|
+
@click="${this.onSelect}"
|
40
|
+
>
|
41
|
+
<span
|
42
|
+
class="${this.isSelected
|
43
|
+
? 'visible'
|
44
|
+
: 'invisible'} hs-combo-box-selected:block mr-2"
|
45
|
+
>
|
46
|
+
${tickIcon()}
|
47
|
+
</span>
|
48
|
+
<div class="flex justify-between items-center w-full">
|
49
|
+
<span
|
50
|
+
data-hs-combo-box-search-text="${this.searchText}"
|
51
|
+
data-hs-combo-box-value="${this.value}"
|
52
|
+
>
|
53
|
+
${this.searchText}
|
54
|
+
</span>
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
`;
|
58
|
+
}
|
59
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { LitElement, PropertyValues, css, html } from 'lit';
|
2
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
3
|
+
import { searchIcon } from '../../../assets/icons';
|
4
|
+
import { TWStyles } from '../../../styles';
|
5
|
+
import { STATE_CLOSED, STATE_OPEN } from '../popover/popover.types';
|
6
|
+
import { ComboBox } from './combo-box.atom';
|
7
|
+
|
8
|
+
@customElement('combo-box-list')
|
9
|
+
export class ComboBoxList extends LitElement {
|
10
|
+
static styles = [css``, TWStyles];
|
11
|
+
@property({ attribute: 'data-state', type: String }) state = STATE_CLOSED;
|
12
|
+
|
13
|
+
@state() isOpen = false;
|
14
|
+
get _popover(): ComboBox | null {
|
15
|
+
let parent = this.parentElement;
|
16
|
+
// Traverse up the DOM tree to find the parent `Popover`
|
17
|
+
while (parent && !(parent instanceof ComboBox)) {
|
18
|
+
parent = parent.parentElement;
|
19
|
+
}
|
20
|
+
return parent;
|
21
|
+
}
|
22
|
+
|
23
|
+
render() {
|
24
|
+
console.log('this.state', this.state);
|
25
|
+
// @keydown="${this.handleKeyDown}"
|
26
|
+
|
27
|
+
// @input="${this.handleSearch}"
|
28
|
+
// @keydown="${this.handleKeyDown}"
|
29
|
+
return html`
|
30
|
+
<div
|
31
|
+
class="absolute z-50 w-full max-h-72 p-1 bg-white border border-gray-200 rounded-lg overflow-hidden overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500 dark:bg-neutral-900 dark:border-neutral-700"
|
32
|
+
data-hs-combo-box-output=""
|
33
|
+
style="display: ${this.state === STATE_OPEN
|
34
|
+
? 'block'
|
35
|
+
: 'none'}; top:115%"
|
36
|
+
>
|
37
|
+
<div
|
38
|
+
class="flex items-center justify-center px-3 border-b border-gray-300 mb-1"
|
39
|
+
>
|
40
|
+
${searchIcon()}
|
41
|
+
<input
|
42
|
+
type="text"
|
43
|
+
class="w-full px-2 py-2 rounded focus:outline-none"
|
44
|
+
placeholder="Search..."
|
45
|
+
autocomplete="off"
|
46
|
+
autocorrect="off"
|
47
|
+
spellcheck="false"
|
48
|
+
aria-autocomplete="list"
|
49
|
+
aria-expanded="true"
|
50
|
+
role="combobox"
|
51
|
+
/>
|
52
|
+
</div>
|
53
|
+
<slot></slot>
|
54
|
+
</div>
|
55
|
+
`;
|
56
|
+
}
|
57
|
+
}
|