revotech-ui-kit 0.0.3-beta → 0.0.5-beta
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.ts +1 -1
- package/dist/sw.js +1 -1
- package/dist/sw.js.map +1 -1
- package/package.json +2 -1
- package/src/components/atoms/alert/alert.atom.ts +5 -1
- package/src/components/atoms/button/button.atom.ts +6 -0
- package/src/index.d.ts +1 -0
- package/src/index.ts +1 -1
- package/dist/183c6c38.js +0 -1
- package/dist/public/globals.css +0 -2215
- package/dist/public/tailwind-lib.css +0 -115
- package/dist/src/assets/icons/arrows.icon.js +0 -20
- package/dist/src/assets/icons/arrows.icon.js.map +0 -1
- package/dist/src/assets/icons/index.js +0 -4
- package/dist/src/assets/icons/index.js.map +0 -1
- package/dist/src/assets/icons/search.icon.js +0 -19
- package/dist/src/assets/icons/search.icon.js.map +0 -1
- package/dist/src/assets/icons/tick.icon.js +0 -20
- package/dist/src/assets/icons/tick.icon.js.map +0 -1
- package/dist/src/components/atoms/alert/alert-description.js +0 -18
- package/dist/src/components/atoms/alert/alert-description.js.map +0 -1
- package/dist/src/components/atoms/alert/alert-title.js +0 -20
- package/dist/src/components/atoms/alert/alert-title.js.map +0 -1
- package/dist/src/components/atoms/alert/alert.atom.js +0 -55
- package/dist/src/components/atoms/alert/alert.atom.js.map +0 -1
- package/dist/src/components/atoms/alert/alert.stories.js +0 -62
- package/dist/src/components/atoms/alert/alert.stories.js.map +0 -1
- package/dist/src/components/atoms/alert/alert.styles.js +0 -21
- package/dist/src/components/atoms/alert/alert.styles.js.map +0 -1
- package/dist/src/components/atoms/alert/alert.types.js +0 -2
- package/dist/src/components/atoms/alert/alert.types.js.map +0 -1
- package/dist/src/components/atoms/badge/badge.atom.js +0 -43
- package/dist/src/components/atoms/badge/badge.atom.js.map +0 -1
- package/dist/src/components/atoms/badge/badge.stories.js +0 -110
- package/dist/src/components/atoms/badge/badge.stories.js.map +0 -1
- package/dist/src/components/atoms/badge/badge.style.js +0 -17
- package/dist/src/components/atoms/badge/badge.style.js.map +0 -1
- package/dist/src/components/atoms/badge/badge.type.js +0 -2
- package/dist/src/components/atoms/badge/badge.type.js.map +0 -1
- package/dist/src/components/atoms/button/button.atom.js +0 -67
- package/dist/src/components/atoms/button/button.atom.js.map +0 -1
- package/dist/src/components/atoms/button/button.stories.js +0 -204
- package/dist/src/components/atoms/button/button.stories.js.map +0 -1
- package/dist/src/components/atoms/button/button.style.js +0 -24
- package/dist/src/components/atoms/button/button.style.js.map +0 -1
- package/dist/src/components/atoms/button/button.type.js +0 -2
- package/dist/src/components/atoms/button/button.type.js.map +0 -1
- package/dist/src/components/atoms/card/card-content.js +0 -17
- package/dist/src/components/atoms/card/card-content.js.map +0 -1
- package/dist/src/components/atoms/card/card-description.js +0 -17
- package/dist/src/components/atoms/card/card-description.js.map +0 -1
- package/dist/src/components/atoms/card/card-footer.js +0 -17
- package/dist/src/components/atoms/card/card-footer.js.map +0 -1
- package/dist/src/components/atoms/card/card-header.js +0 -17
- package/dist/src/components/atoms/card/card-header.js.map +0 -1
- package/dist/src/components/atoms/card/card-title.js +0 -17
- package/dist/src/components/atoms/card/card-title.js.map +0 -1
- package/dist/src/components/atoms/card/card.atom.js +0 -25
- package/dist/src/components/atoms/card/card.atom.js.map +0 -1
- package/dist/src/components/atoms/card/card.stories.js +0 -136
- package/dist/src/components/atoms/card/card.stories.js.map +0 -1
- package/dist/src/components/atoms/checkbox/checkbox.atom.js +0 -87
- package/dist/src/components/atoms/checkbox/checkbox.atom.js.map +0 -1
- package/dist/src/components/atoms/checkbox/checkbox.stories.js +0 -244
- package/dist/src/components/atoms/checkbox/checkbox.stories.js.map +0 -1
- package/dist/src/components/atoms/checkbox/checkbox.style.js +0 -3
- package/dist/src/components/atoms/checkbox/checkbox.style.js.map +0 -1
- package/dist/src/components/atoms/checkbox/checkbox.type.js +0 -2
- package/dist/src/components/atoms/checkbox/checkbox.type.js.map +0 -1
- package/dist/src/components/atoms/combo-box/combo-box-input.js +0 -47
- package/dist/src/components/atoms/combo-box/combo-box-input.js.map +0 -1
- package/dist/src/components/atoms/combo-box/combo-box-item.js +0 -85
- package/dist/src/components/atoms/combo-box/combo-box-item.js.map +0 -1
- package/dist/src/components/atoms/combo-box/combo-box-list.js +0 -67
- package/dist/src/components/atoms/combo-box/combo-box-list.js.map +0 -1
- package/dist/src/components/atoms/combo-box/combo-box.atom.js +0 -199
- package/dist/src/components/atoms/combo-box/combo-box.atom.js.map +0 -1
- package/dist/src/components/atoms/combo-box/combo-box.stories.js +0 -86
- package/dist/src/components/atoms/combo-box/combo-box.stories.js.map +0 -1
- package/dist/src/components/atoms/command-empty/command-empty.atom.js +0 -54
- package/dist/src/components/atoms/command-empty/command-empty.atom.js.map +0 -1
- package/dist/src/components/atoms/command-group/command-group.atom.js +0 -71
- package/dist/src/components/atoms/command-group/command-group.atom.js.map +0 -1
- package/dist/src/components/atoms/command-item/command-item.atom.js +0 -80
- package/dist/src/components/atoms/command-item/command-item.atom.js.map +0 -1
- package/dist/src/components/atoms/command-list/command-list.atom.js +0 -36
- package/dist/src/components/atoms/command-list/command-list.atom.js.map +0 -1
- package/dist/src/components/atoms/command-separator/command-separator.atom.js +0 -52
- package/dist/src/components/atoms/command-separator/command-separator.atom.js.map +0 -1
- package/dist/src/components/atoms/dialog/dialog-close.js +0 -47
- package/dist/src/components/atoms/dialog/dialog-close.js.map +0 -1
- package/dist/src/components/atoms/dialog/dialog-content.js +0 -72
- package/dist/src/components/atoms/dialog/dialog-content.js.map +0 -1
- package/dist/src/components/atoms/dialog/dialog-footer.js +0 -22
- package/dist/src/components/atoms/dialog/dialog-footer.js.map +0 -1
- package/dist/src/components/atoms/dialog/dialog-header.js +0 -40
- package/dist/src/components/atoms/dialog/dialog-header.js.map +0 -1
- package/dist/src/components/atoms/dialog/dialog-overly.js +0 -20
- package/dist/src/components/atoms/dialog/dialog-overly.js.map +0 -1
- package/dist/src/components/atoms/dialog/dialog-trigger.js +0 -54
- package/dist/src/components/atoms/dialog/dialog-trigger.js.map +0 -1
- package/dist/src/components/atoms/dialog/dialog.atom.js +0 -79
- package/dist/src/components/atoms/dialog/dialog.atom.js.map +0 -1
- package/dist/src/components/atoms/dialog/dialog.stories.js +0 -88
- package/dist/src/components/atoms/dialog/dialog.stories.js.map +0 -1
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-checkbox-Item.js +0 -117
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-checkbox-Item.js.map +0 -1
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-content.js +0 -81
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-content.js.map +0 -1
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-group.js +0 -71
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-group.js.map +0 -1
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-item.js +0 -80
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-item.js.map +0 -1
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-radio-item.js +0 -118
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-radio-item.js.map +0 -1
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-seperator.js +0 -52
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-seperator.js.map +0 -1
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-shortcut.js +0 -20
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu-shortcut.js.map +0 -1
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu.atom.js +0 -79
- package/dist/src/components/atoms/dropdownMenu/dropdown-menu.atom.js.map +0 -1
- package/dist/src/components/atoms/dropdownMenu/dropdownMenu.stories.js +0 -211
- package/dist/src/components/atoms/dropdownMenu/dropdownMenu.stories.js.map +0 -1
- package/dist/src/components/atoms/dropdownMenu/dropdownMenu.style.js +0 -4
- package/dist/src/components/atoms/dropdownMenu/dropdownMenu.style.js.map +0 -1
- package/dist/src/components/atoms/index.js +0 -14
- package/dist/src/components/atoms/index.js.map +0 -1
- package/dist/src/components/atoms/input/input.atom.js +0 -93
- package/dist/src/components/atoms/input/input.atom.js.map +0 -1
- package/dist/src/components/atoms/input/input.stories.js +0 -382
- package/dist/src/components/atoms/input/input.stories.js.map +0 -1
- package/dist/src/components/atoms/input/input.styles.js +0 -2
- package/dist/src/components/atoms/input/input.styles.js.map +0 -1
- package/dist/src/components/atoms/input/input.type.js +0 -2
- package/dist/src/components/atoms/input/input.type.js.map +0 -1
- package/dist/src/components/atoms/label/label.atom.js +0 -68
- package/dist/src/components/atoms/label/label.atom.js.map +0 -1
- package/dist/src/components/atoms/label/label.stories.js +0 -85
- package/dist/src/components/atoms/label/label.stories.js.map +0 -1
- package/dist/src/components/atoms/label/label.style.js +0 -3
- package/dist/src/components/atoms/label/label.style.js.map +0 -1
- package/dist/src/components/atoms/popover/popover-content.js +0 -64
- package/dist/src/components/atoms/popover/popover-content.js.map +0 -1
- package/dist/src/components/atoms/popover/popover-trigger.js +0 -51
- package/dist/src/components/atoms/popover/popover-trigger.js.map +0 -1
- package/dist/src/components/atoms/popover/popover.atom.js +0 -40
- package/dist/src/components/atoms/popover/popover.atom.js.map +0 -1
- package/dist/src/components/atoms/popover/popover.stories.js +0 -69
- package/dist/src/components/atoms/popover/popover.stories.js.map +0 -1
- package/dist/src/components/atoms/popover/popover.style.js +0 -21
- package/dist/src/components/atoms/popover/popover.style.js.map +0 -1
- package/dist/src/components/atoms/popover/popover.types.js +0 -4
- package/dist/src/components/atoms/popover/popover.types.js.map +0 -1
- package/dist/src/components/atoms/toggle/defs.js +0 -30
- package/dist/src/components/atoms/toggle/defs.js.map +0 -1
- package/dist/src/components/atoms/toggle/toggle.atom.js +0 -72
- package/dist/src/components/atoms/toggle/toggle.atom.js.map +0 -1
- package/dist/src/components/atoms/toggle/toggle.stories.js +0 -189
- package/dist/src/components/atoms/toggle/toggle.stories.js.map +0 -1
- package/dist/src/components/atoms/toggle/toggle.style.js +0 -19
- package/dist/src/components/atoms/toggle/toggle.style.js.map +0 -1
- package/dist/src/components/command/command.js +0 -410
- package/dist/src/components/command/command.js.map +0 -1
- package/dist/src/components/command/command.stories.js +0 -153
- package/dist/src/components/command/command.stories.js.map +0 -1
- package/dist/src/components/index.js +0 -3
- package/dist/src/components/index.js.map +0 -1
- package/dist/src/components/molecules/command/command.molecules.js +0 -27
- package/dist/src/components/molecules/command/command.molecules.js.map +0 -1
- package/dist/src/components/molecules/command-input/command-input.atom.js +0 -127
- package/dist/src/components/molecules/command-input/command-input.atom.js.map +0 -1
- package/dist/src/components/molecules/dropdownMenu/dropdownMenu.molecules.js +0 -2
- package/dist/src/components/molecules/dropdownMenu/dropdownMenu.molecules.js.map +0 -1
- package/dist/src/components/molecules/index.js +0 -2
- package/dist/src/components/molecules/index.js.map +0 -1
- package/dist/src/helpers/base-element.js +0 -64
- package/dist/src/helpers/base-element.js.map +0 -1
- package/dist/src/helpers/index.js +0 -4
- package/dist/src/helpers/index.js.map +0 -1
- package/dist/src/helpers/mouse-conroller.helper.js +0 -33
- package/dist/src/helpers/mouse-conroller.helper.js.map +0 -1
- package/dist/src/helpers/style.helpers.js +0 -6
- package/dist/src/helpers/style.helpers.js.map +0 -1
- package/dist/src/index.js +0 -2
- package/dist/src/index.js.map +0 -1
- package/dist/src/interfaces/actionable.interface.js +0 -2
- package/dist/src/interfaces/actionable.interface.js.map +0 -1
- package/dist/src/interfaces/atomic.interface.js +0 -2
- package/dist/src/interfaces/atomic.interface.js.map +0 -1
- package/dist/src/interfaces/changeable.interface.js +0 -2
- package/dist/src/interfaces/changeable.interface.js.map +0 -1
- package/dist/src/interfaces/child-support-atomic.interface.js +0 -2
- package/dist/src/interfaces/child-support-atomic.interface.js.map +0 -1
- package/dist/src/interfaces/index.js +0 -7
- package/dist/src/interfaces/index.js.map +0 -1
- package/dist/src/interfaces/intractable.interface.js +0 -2
- package/dist/src/interfaces/intractable.interface.js.map +0 -1
- package/dist/src/interfaces/variant.interface.js +0 -2
- package/dist/src/interfaces/variant.interface.js.map +0 -1
- package/dist/src/lib/index.js +0 -2
- package/dist/src/lib/index.js.map +0 -1
- package/dist/src/lib/next/next.lib.js +0 -2
- package/dist/src/lib/next/next.lib.js.map +0 -1
- package/dist/src/lib/react/react.lib.js +0 -16
- package/dist/src/lib/react/react.lib.js.map +0 -1
- package/dist/src/lib/tw-styles.js +0 -1956
- package/dist/src/lib/tw-styles.js.map +0 -1
- package/dist/src/styles/index.js +0 -2
- package/dist/src/styles/index.js.map +0 -1
- package/dist/src/styles/tw.styles.js +0 -2218
- package/dist/src/styles/tw.styles.js.map +0 -1
- package/dist/src/wc-ui-app.js +0 -88
- package/dist/src/wc-ui-app.js.map +0 -1
- package/dist/test/wc-ui-app.test.js +0 -18
- package/dist/test/wc-ui-app.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"card.stories.js","sourceRoot":"","sources":["../../../../../src/components/atoms/card/card.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAM,OAAO,EAAa,MAAM,iBAAiB,CAAC;AACzE,OAAO,aAAa,CAAC;AAErB,eAAe;IACb,SAAS,EAAE,iBAAiB;IAC5B,IAAI,EAAE,CAAC,UAAU,CAAC;CACX,CAAC;AAIV,MAAM,gBAAgB,GAAG,KAAK,EAAE,IAAS,EAAE,aAA0B,EAAE,EAAE;IACvE,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC7E,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WA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AC;QACF,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAU;IAC1B,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFjB;IACD,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,gBAAgB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit';\nimport type { Meta, StoryFn, StoryObj } from '@storybook/web-components';\nimport { expect, within, fn, waitFor, userEvent } from '@storybook/test';\nimport './card.atom';\n\nexport default {\n component: 'components/card',\n tags: ['autodocs'],\n} as Meta;\n\ntype Story = StoryObj;\n\nconst testCardBehavior = async (args: any, canvasElement: HTMLElement) => {\n const canvas = within(canvasElement);\n const card = await waitFor(() => canvas.getByTestId('card-id'));\n const cardHeader = await waitFor(() => canvas.getByTestId('card-header-id'));\n const cardTitle = await waitFor(() => canvas.getByTestId('card-title-id'));\n const cardDescription = await waitFor(() =>\n canvas.getByTestId('card-description-id')\n );\n const cardContent = await waitFor(() =>\n canvas.getByTestId('card-content-id')\n );\n const cardFooter = await waitFor(() => canvas.getByTestId('card-footer-id'));\n expect(card).toBeVisible();\n expect(cardHeader).toBeVisible();\n expect(cardTitle).toBeVisible();\n expect(cardDescription).toBeVisible();\n expect(cardContent).toBeVisible();\n expect(cardFooter).toBeVisible();\n\n if (card.shadowRoot) {\n const cardItem = await card.shadowRoot.getElementById('rtg-card-id');\n expect(cardItem).toHaveClass(\n 'rounded-lg border bg-card text-card-foreground shadow-sm p-6'\n );\n }\n if (cardTitle) {\n expect(cardTitle.textContent).toContain('Create project');\n expect(cardTitle.tagName.toLowerCase()).toEqual('cardtitle');\n }\n if (cardDescription) {\n expect(cardDescription.textContent).toContain(\n 'Deploy your new project in one-click.'\n );\n expect(cardDescription.tagName.toLowerCase()).toEqual('carddescription');\n }\n};\n\nexport const Cards: Story = {\n name: 'Cards',\n render: () => html`\n <rtg-card data-testid=\"card-id\">\n <CardHeader data-testid=\"card-header-id\">\n <CardTitle data-testid=\"card-title-id\">\n <h3>Create project</h3>\n </CardTitle>\n <CardDescription data-testid=\"card-description-id\">\n <p class=\"text-sm text-muted-foreground\">\n Deploy your new project in one-click.\n </p>\n </CardDescription>\n </CardHeader>\n <CardContent data-testid=\"card-content-id\">\n <form class=\"pt-4\">\n <div class=\"grid w-full items-center gap-4\">\n <div class=\"flex flex-col space-y-1.5\">\n <label\n class=\"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\"\n for=\"name\"\n >Name</label\n ><input\n class=\"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50\"\n id=\"name\"\n placeholder=\"Name of your project\"\n />\n </div>\n <div class=\"flex flex-col space-y-1.5\">\n <label\n class=\"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\"\n for=\"framework\"\n >Framework</label\n ><button\n type=\"button\"\n role=\"combobox\"\n aria-controls=\"radix-:r2b:\"\n aria-expanded=\"false\"\n aria-autocomplete=\"none\"\n dir=\"ltr\"\n data-state=\"closed\"\n data-placeholder=\"\"\n class=\"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1\"\n id=\"framework\"\n >\n <span style=\"pointer-events: none;\">Select</span\n ><svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-down h-4 w-4 opacity-50\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\"></path>\n </svg></button\n ><select\n aria-hidden=\"true\"\n tabindex=\"-1\"\n style=\"position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; overflow-wrap: normal;\"\n >\n <option value=\"\"></option>\n <option value=\"next\">Next.js</option>\n <option value=\"sveltekit\">SvelteKit</option>\n <option value=\"astro\">Astro</option>\n <option value=\"nuxt\">Nuxt.js</option>\n </select>\n </div>\n </div>\n </form>\n </CardContent>\n <CardFooter data-testid=\"card-footer-id\">\n <div class=\"items-center pt-4 flex justify-between\">\n <button\n class=\"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2\"\n >\n Cancel\n </button>\n <button\n class=\"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2\"\n >\n Deploy\n </button>\n </div>\n </CardFooter>\n </rtg-card>\n `,\n play: async ({ args, canvasElement }) => {\n try {\n await testCardBehavior(args, canvasElement);\n } catch (error) {\n console.error('An error occurred during the play function:', error);\n }\n },\n};\n"]}
|
@@ -1,87 +0,0 @@
|
|
1
|
-
import { __decorate } from "tslib";
|
2
|
-
import { LitElement, html, css, nothing } from 'lit';
|
3
|
-
import { property, customElement } from 'lit/decorators.js';
|
4
|
-
import { cn } from '../../../helpers';
|
5
|
-
import { TWStyles } from '../../../styles';
|
6
|
-
import { checkboxStyles, iconStyles } from './checkbox.style';
|
7
|
-
let Checkbox = class Checkbox extends LitElement {
|
8
|
-
constructor() {
|
9
|
-
super(...arguments);
|
10
|
-
this.disabled = false;
|
11
|
-
this.checked = false;
|
12
|
-
this.type = 'text';
|
13
|
-
this.value = '';
|
14
|
-
this.required = false;
|
15
|
-
}
|
16
|
-
_onClick(e) {
|
17
|
-
if (e.defaultPrevented)
|
18
|
-
return;
|
19
|
-
this.checked = !this.checked;
|
20
|
-
this.required = !this.required;
|
21
|
-
// Dispatch a custom change event when the state changes
|
22
|
-
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
23
|
-
}
|
24
|
-
click() {
|
25
|
-
this.checked = !this.checked;
|
26
|
-
this.required = !this.required;
|
27
|
-
}
|
28
|
-
render() {
|
29
|
-
const additionalProps = { ...this.dataset }; // Example of additional props
|
30
|
-
return html `
|
31
|
-
<button
|
32
|
-
data-testid="checkbox-atom"
|
33
|
-
type="button"
|
34
|
-
role="checkbox"
|
35
|
-
aria-checked="${this.checked || this.value === 'on'}"
|
36
|
-
data-state="${this.checked || this.value === 'on'
|
37
|
-
? 'checked'
|
38
|
-
: 'unchecked'}"
|
39
|
-
value="${this.value}"
|
40
|
-
?required=${this.required}
|
41
|
-
?disabled=${this.disabled}
|
42
|
-
@click="${this._onClick}"
|
43
|
-
class="${cn(checkboxStyles, this.className)}"
|
44
|
-
${Object.entries(additionalProps).map(([key, value]) => html ` ${key}="${value}" `)}
|
45
|
-
>
|
46
|
-
${this.checked || this.value === 'on'
|
47
|
-
? html `<span data-state="checked" class="${iconStyles}"
|
48
|
-
><svg
|
49
|
-
xmlns="http://www.w3.org/2000/svg"
|
50
|
-
width="24"
|
51
|
-
height="24"
|
52
|
-
viewBox="0 0 24 24"
|
53
|
-
fill="none"
|
54
|
-
stroke="currentColor"
|
55
|
-
stroke-width="3"
|
56
|
-
stroke-linecap="round"
|
57
|
-
stroke-linejoin="round"
|
58
|
-
class="h-4 w-4"
|
59
|
-
>
|
60
|
-
<polyline points="20 6 9 17 4 12"></polyline></svg
|
61
|
-
></span>`
|
62
|
-
: nothing}
|
63
|
-
</button>
|
64
|
-
`;
|
65
|
-
}
|
66
|
-
};
|
67
|
-
Checkbox.styles = [css ``, TWStyles];
|
68
|
-
__decorate([
|
69
|
-
property({ type: Boolean })
|
70
|
-
], Checkbox.prototype, "disabled", void 0);
|
71
|
-
__decorate([
|
72
|
-
property({ type: Boolean })
|
73
|
-
], Checkbox.prototype, "checked", void 0);
|
74
|
-
__decorate([
|
75
|
-
property({ type: String })
|
76
|
-
], Checkbox.prototype, "type", void 0);
|
77
|
-
__decorate([
|
78
|
-
property({ type: String })
|
79
|
-
], Checkbox.prototype, "value", void 0);
|
80
|
-
__decorate([
|
81
|
-
property({ type: Boolean })
|
82
|
-
], Checkbox.prototype, "required", void 0);
|
83
|
-
Checkbox = __decorate([
|
84
|
-
customElement('rtg-checkbox')
|
85
|
-
], Checkbox);
|
86
|
-
export { Checkbox };
|
87
|
-
//# sourceMappingURL=checkbox.atom.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"checkbox.atom.js","sourceRoot":"","sources":["../../../../../src/components/atoms/checkbox/checkbox.atom.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,QAAQ,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AW;iBACN,IAAI,CAAC,KAAK;oBACP,IAAI,CAAC,QAAQ;oBACb,IAAI,CAAC,QAAQ;kBACf,IAAI,CAAC,QAAQ;iBACd,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC;UACzC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG,CACnC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAA,IAAI,GAAG,KAAK,KAAK,IAAI,CAC5C;;UAEC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI;YACnC,CAAC,CAAC,IAAI,CAAA,qCAAqC,UAAU;;;;;;;;;;;;;;qBAc1C;YACX,CAAC,CAAC,OAAO;;KAEd,CAAC;IACJ,CAAC;;AAvDM,eAAM,GAAG,CAAC,GAAG,CAAA,EAAE,EAAE,QAAQ,CAAC,AAApB,CAAqB;AAVL;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAAiB;AAEjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAe;AAEd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAAY;AAEV;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAkB;AATnC,QAAQ;IADpB,aAAa,CAAC,cAAc,CAAC;GACjB,QAAQ,CAmEpB","sourcesContent":["import { LitElement, html, css, nothing } from 'lit';\nimport { property, customElement } from 'lit/decorators.js';\nimport { cn } from '../../../helpers';\nimport { TWStyles } from '../../../styles';\nimport { checkboxStyles, iconStyles } from './checkbox.style';\nimport { CheckboxProperties } from './checkbox.type';\n\n@customElement('rtg-checkbox')\nexport class Checkbox extends LitElement implements CheckboxProperties {\n @property({ type: Boolean }) disabled = false;\n\n @property({ type: Boolean }) checked = false;\n\n @property({ type: String }) type = 'text';\n\n @property({ type: String }) value = '';\n\n @property({ type: Boolean }) required = false;\n\n static styles = [css``, TWStyles];\n\n private _onClick(e: Event) {\n if (e.defaultPrevented) return;\n this.checked = !this.checked;\n this.required = !this.required;\n\n // Dispatch a custom change event when the state changes\n this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));\n }\n\n public click() {\n this.checked = !this.checked;\n this.required = !this.required;\n }\n\n render() {\n const additionalProps = { ...this.dataset }; // Example of additional props\n return html`\n <button\n data-testid=\"checkbox-atom\"\n type=\"button\"\n role=\"checkbox\"\n aria-checked=\"${this.checked || this.value === 'on'}\"\n data-state=\"${this.checked || this.value === 'on'\n ? 'checked'\n : 'unchecked'}\"\n value=\"${this.value}\"\n ?required=${this.required}\n ?disabled=${this.disabled}\n @click=\"${this._onClick}\"\n class=\"${cn(checkboxStyles, this.className)}\"\n ${Object.entries(additionalProps).map(\n ([key, value]) => html` ${key}=\"${value}\" `\n )}\n >\n ${this.checked || this.value === 'on'\n ? html`<span data-state=\"checked\" class=\"${iconStyles}\"\n ><svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"3\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"h-4 w-4\"\n >\n <polyline points=\"20 6 9 17 4 12\"></polyline></svg\n ></span>`\n : nothing}\n </button>\n `;\n }\n}\n"]}
|
@@ -1,244 +0,0 @@
|
|
1
|
-
import { html } from 'lit';
|
2
|
-
import './checkbox.atom';
|
3
|
-
import { expect, within, waitFor, fn } from '@storybook/test';
|
4
|
-
import '../button/button.atom';
|
5
|
-
const allowedTypes = ['checkbox'];
|
6
|
-
export default {
|
7
|
-
component: 'components/checkbox',
|
8
|
-
tags: ['autodocs'],
|
9
|
-
};
|
10
|
-
const mockOnClickHandler = fn(event => {
|
11
|
-
alert('submit data!');
|
12
|
-
});
|
13
|
-
const testCheckboxBehavior = async (args, canvasElement) => {
|
14
|
-
const canvas = within(canvasElement);
|
15
|
-
const checkbox = await waitFor(() => canvas.getByTestId('checkbox-id'));
|
16
|
-
if (checkbox.shadowRoot) {
|
17
|
-
const innerCheckbox = checkbox.shadowRoot.querySelector('[data-testid="checkbox-atom"]');
|
18
|
-
// 1. Test: Checkbox should have correct Role attribute
|
19
|
-
expect(innerCheckbox).toHaveRole('checkbox');
|
20
|
-
// 2. Test: Checkbox should have the correct `checked` state based on args
|
21
|
-
if (args.checked) {
|
22
|
-
expect(innerCheckbox).toBeChecked();
|
23
|
-
}
|
24
|
-
else {
|
25
|
-
expect(innerCheckbox).not.toBeChecked();
|
26
|
-
}
|
27
|
-
// 3. Test: Checkbox should be disabled when the `disabled` prop is true
|
28
|
-
if (args.disabled) {
|
29
|
-
expect(innerCheckbox).toBeDisabled();
|
30
|
-
}
|
31
|
-
else {
|
32
|
-
expect(innerCheckbox).not.toBeDisabled();
|
33
|
-
}
|
34
|
-
// 4. Test: Label should have correct `for` attribute linking to the checkbox
|
35
|
-
const label = await waitFor(() => canvas.getByText(args.label));
|
36
|
-
expect(label).toBeInTheDocument();
|
37
|
-
expect(label).toHaveAttribute('for', checkbox.getAttribute('id'));
|
38
|
-
}
|
39
|
-
};
|
40
|
-
const testCheckboxWithRequiredBehavior = async (args, canvasElement) => {
|
41
|
-
const canvas = within(canvasElement);
|
42
|
-
const checkbox = await waitFor(() => canvas.getByTestId('checkbox-id'));
|
43
|
-
const button = await waitFor(() => canvas.getByTestId('btn-id'));
|
44
|
-
if (checkbox.shadowRoot) {
|
45
|
-
const innerCheckbox = checkbox.shadowRoot.querySelector('[data-testid="checkbox-atom"]');
|
46
|
-
// Test: Checkbox should have the correct required attribute
|
47
|
-
if (args.required) {
|
48
|
-
expect(innerCheckbox).toHaveAttribute('required');
|
49
|
-
}
|
50
|
-
else {
|
51
|
-
expect(innerCheckbox).not.toHaveAttribute('required');
|
52
|
-
}
|
53
|
-
// Test: Button should be disabled when checkbox is unchecked and required is true
|
54
|
-
if (args.required && !args.checked) {
|
55
|
-
expect(button).toBeDisabled();
|
56
|
-
}
|
57
|
-
else if (args.required && args.checked) {
|
58
|
-
expect(button).not.toBeDisabled();
|
59
|
-
}
|
60
|
-
// Additional tests for the checked state
|
61
|
-
if (args.checked) {
|
62
|
-
expect(innerCheckbox).toBeChecked();
|
63
|
-
}
|
64
|
-
else {
|
65
|
-
expect(innerCheckbox).not.toBeChecked();
|
66
|
-
}
|
67
|
-
// Additional tests for the disabled state
|
68
|
-
if (args.disabled) {
|
69
|
-
expect(innerCheckbox).toBeDisabled();
|
70
|
-
}
|
71
|
-
else {
|
72
|
-
expect(innerCheckbox).not.toBeDisabled();
|
73
|
-
}
|
74
|
-
}
|
75
|
-
};
|
76
|
-
const testCheckboxWithValueBehavior = async (args, canvasElement) => {
|
77
|
-
const canvas = within(canvasElement);
|
78
|
-
const checkbox = await waitFor(() => canvas.getByTestId('checkbox-id'));
|
79
|
-
if (checkbox.shadowRoot) {
|
80
|
-
const innerCheckbox = checkbox.shadowRoot.querySelector('[data-testid="checkbox-atom"]');
|
81
|
-
// Test: Checkbox should have the correct value attribute
|
82
|
-
expect(innerCheckbox).toHaveAttribute('value', args.value);
|
83
|
-
// Additional tests for disabled state if needed
|
84
|
-
if (args.disabled) {
|
85
|
-
expect(innerCheckbox).toBeDisabled();
|
86
|
-
}
|
87
|
-
else {
|
88
|
-
expect(innerCheckbox).not.toBeDisabled();
|
89
|
-
}
|
90
|
-
}
|
91
|
-
};
|
92
|
-
const TemplatewithChecked = ({ disabled, checked, label }) => html `
|
93
|
-
<div style="display:flex">
|
94
|
-
<rtg-checkbox
|
95
|
-
id="terms"
|
96
|
-
data-testid="checkbox-id"
|
97
|
-
?disabled=${disabled}
|
98
|
-
?checked=${checked}
|
99
|
-
></rtg-checkbox>
|
100
|
-
<rtg-label style="margin:2px 0px 0px 4px" for="terms">${label}</rtg-label>
|
101
|
-
</div>
|
102
|
-
`;
|
103
|
-
const TemplatewithRequired = ({ disabled, checked, label, required, }) => html `
|
104
|
-
<div style="display: flex; flex-direction: column;">
|
105
|
-
<div style="display:flex">
|
106
|
-
<rtg-checkbox
|
107
|
-
id="terms"
|
108
|
-
data-testid="checkbox-id"
|
109
|
-
?disabled=${disabled}
|
110
|
-
?checked=${checked}
|
111
|
-
?required=${required}
|
112
|
-
@click=${(e) => {
|
113
|
-
const checkbox = e.target;
|
114
|
-
const button = document.querySelector('rtg-button');
|
115
|
-
if (button) {
|
116
|
-
button.disabled = required ? !checkbox.checked : false;
|
117
|
-
}
|
118
|
-
}}
|
119
|
-
></rtg-checkbox>
|
120
|
-
<rtg-label style="margin:2px 0px 0px 4px" for="terms"
|
121
|
-
>${label}</rtg-label
|
122
|
-
>
|
123
|
-
</div>
|
124
|
-
<div style="margin-top:16px">
|
125
|
-
<rtg-button
|
126
|
-
variant="default"
|
127
|
-
size="default"
|
128
|
-
data-testid="btn-id"
|
129
|
-
?disabled=${required ? !checked : false}
|
130
|
-
.click=${mockOnClickHandler}
|
131
|
-
>Submit</rtg-button
|
132
|
-
>
|
133
|
-
</div>
|
134
|
-
</div>
|
135
|
-
`;
|
136
|
-
const TemplateWithVlaue = ({ disabled, label, value }) => html `
|
137
|
-
<div style="display:flex">
|
138
|
-
<rtg-checkbox
|
139
|
-
id="terms"
|
140
|
-
data-testid="checkbox-id"
|
141
|
-
value=${value}
|
142
|
-
?disabled=${disabled}
|
143
|
-
></rtg-checkbox>
|
144
|
-
<rtg-label style="margin:2px 0px 0px 4px" for="terms">${label}</rtg-label>
|
145
|
-
</div>
|
146
|
-
`;
|
147
|
-
export const CheckboxWithReuired = TemplatewithRequired.bind({});
|
148
|
-
CheckboxWithReuired.args = {
|
149
|
-
disabled: false,
|
150
|
-
checked: false,
|
151
|
-
required: false,
|
152
|
-
label: 'Accept terms and conditions',
|
153
|
-
};
|
154
|
-
CheckboxWithReuired.parameters = {
|
155
|
-
docs: {
|
156
|
-
source: {
|
157
|
-
transform: (code, storyContext) => {
|
158
|
-
const args = storyContext.args;
|
159
|
-
// Handling boolean attributes: if true, render without value, if false, omit the attribute
|
160
|
-
const updatedCode = code
|
161
|
-
.replace(/disabled=""/g, 'disabled=true')
|
162
|
-
.replace(/checked=""/g, 'checked=true')
|
163
|
-
.replace(/required=""/g, 'required=true')
|
164
|
-
.replace(/disabled="false"/g, '')
|
165
|
-
.replace(/checked="false"/g, '')
|
166
|
-
.replace(/required="false"/g, '');
|
167
|
-
return updatedCode;
|
168
|
-
},
|
169
|
-
},
|
170
|
-
},
|
171
|
-
};
|
172
|
-
CheckboxWithReuired.argTypes = {
|
173
|
-
disabled: {
|
174
|
-
control: 'boolean',
|
175
|
-
description: 'Determines whether the checkbox is disabled (unclickable).',
|
176
|
-
table: {
|
177
|
-
defaultValue: { summary: 'false' },
|
178
|
-
},
|
179
|
-
docs: {
|
180
|
-
source: {
|
181
|
-
code: (args) => (args.disabled ? true : ''),
|
182
|
-
},
|
183
|
-
},
|
184
|
-
},
|
185
|
-
checked: {
|
186
|
-
control: 'boolean',
|
187
|
-
description: 'Specifies whether the checkbox is checked by default.',
|
188
|
-
table: {
|
189
|
-
defaultValue: { summary: 'false' },
|
190
|
-
},
|
191
|
-
},
|
192
|
-
required: {
|
193
|
-
control: 'boolean',
|
194
|
-
description: '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.',
|
195
|
-
table: {
|
196
|
-
defaultValue: { summary: 'false' },
|
197
|
-
},
|
198
|
-
},
|
199
|
-
label: {
|
200
|
-
control: 'text',
|
201
|
-
description: 'The text displayed next to the checkbox, describing its purpose.',
|
202
|
-
},
|
203
|
-
};
|
204
|
-
CheckboxWithReuired.play = async ({ args, canvasElement }) => {
|
205
|
-
await testCheckboxWithRequiredBehavior(args, canvasElement);
|
206
|
-
};
|
207
|
-
export const Checkbox = TemplatewithChecked.bind({});
|
208
|
-
Checkbox.args = {
|
209
|
-
disabled: false,
|
210
|
-
checked: false,
|
211
|
-
label: 'Accept terms and conditions',
|
212
|
-
};
|
213
|
-
Checkbox.argTypes = {
|
214
|
-
disabled: {
|
215
|
-
control: 'boolean',
|
216
|
-
},
|
217
|
-
checked: {
|
218
|
-
control: 'boolean',
|
219
|
-
},
|
220
|
-
label: {
|
221
|
-
control: 'text',
|
222
|
-
},
|
223
|
-
};
|
224
|
-
Checkbox.play = async ({ args, canvasElement }) => {
|
225
|
-
await testCheckboxBehavior(args, canvasElement);
|
226
|
-
};
|
227
|
-
export const CheckboxWithValue = TemplateWithVlaue.bind({});
|
228
|
-
CheckboxWithValue.args = {
|
229
|
-
disabled: false,
|
230
|
-
value: 'off',
|
231
|
-
label: 'Accept terms and conditions',
|
232
|
-
};
|
233
|
-
CheckboxWithValue.argTypes = {
|
234
|
-
disabled: { control: 'boolean' },
|
235
|
-
value: {
|
236
|
-
control: { type: 'select' },
|
237
|
-
options: ['on', 'off'],
|
238
|
-
},
|
239
|
-
label: { control: 'text' },
|
240
|
-
};
|
241
|
-
CheckboxWithValue.play = async ({ args, canvasElement }) => {
|
242
|
-
await testCheckboxWithValueBehavior(args, canvasElement);
|
243
|
-
};
|
244
|
-
//# sourceMappingURL=checkbox.stories.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"checkbox.stories.js","sourceRoot":"","sources":["../../../../../src/components/atoms/checkbox/checkbox.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAa,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAMzE,OAAO,uBAAuB,CAAC;AAE/B,MAAM,YAAY,GAAG,CAAC,UAAU,CAAC,CAAC;AAElC,eAAe;IACb,SAAS,EAAE,qBAAqB;IAChC,IAAI,EAAE,CAAC,UAAU,CAAC;CACX,CAAC;AAEV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AAC;AACrD,QAAQ,CAAC,IAAI,GAAG;IACd,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,6BAA6B;CACrC,CAAC;AAEF,QAAQ,CAAC,QAAQ,GAAG;IAClB,QAAQ,EAAE;QACR,OAAO,EAAE,SAAS;KACnB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,SAAS;KACnB;IACD,KAAK,EAAE;QACL,OAAO,EAAE,MAAM;KAChB;CACF,CAAC;AAEF,QAAQ,CAAC,IAAI,GAAG,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE;IAChD,MAAM,oBAAoB,CAAC,IAAoB,EAAE,aAAa,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5D,iBAAiB,CAAC,IAAI,GAAG;IACvB,QAAQ,EAAE,KAAK;IACf,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,6BAA6B;CACrC,CAAC;AAEF,iBAAiB,CAAC,QAAQ,GAAG;IAC3B,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;IAChC,KAAK,EAAE;QACL,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;KACvB;IACD,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;CAC3B,CAAC;AAEF,iBAAiB,CAAC,IAAI,GAAG,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE;IACzD,MAAM,6BAA6B,CACjC,IAA6B,EAC7B,aAAa,CACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Meta, StoryFn, StoryContext } from '@storybook/web-components';\nimport { html } from 'lit';\nimport './checkbox.atom';\nimport { expect, within, userEvent, waitFor, fn } from '@storybook/test';\nimport {\n CheckboxArgs,\n CheckboxWithRequiredArgs,\n CheckboxWithValueArgs,\n} from './checkbox.type';\nimport '../button/button.atom';\n\nconst allowedTypes = ['checkbox'];\n\nexport default {\n component: 'components/checkbox',\n tags: ['autodocs'],\n} as Meta;\n\nconst mockOnClickHandler = fn(event => {\n alert('submit data!');\n});\n\nconst testCheckboxBehavior = async (\n args: CheckboxArgs,\n canvasElement: HTMLElement\n) => {\n const canvas = within(canvasElement);\n const checkbox = await waitFor(() => canvas.getByTestId('checkbox-id'));\n\n if (checkbox.shadowRoot) {\n const innerCheckbox = checkbox.shadowRoot.querySelector(\n '[data-testid=\"checkbox-atom\"]'\n );\n\n // 1. Test: Checkbox should have correct Role attribute\n expect(innerCheckbox).toHaveRole('checkbox');\n\n // 2. Test: Checkbox should have the correct `checked` state based on args\n if (args.checked) {\n expect(innerCheckbox).toBeChecked();\n } else {\n expect(innerCheckbox).not.toBeChecked();\n }\n\n // 3. Test: Checkbox should be disabled when the `disabled` prop is true\n if (args.disabled) {\n expect(innerCheckbox).toBeDisabled();\n } else {\n expect(innerCheckbox).not.toBeDisabled();\n }\n\n // 4. Test: Label should have correct `for` attribute linking to the checkbox\n const label = await waitFor(() => canvas.getByText(args.label));\n expect(label).toBeInTheDocument();\n expect(label).toHaveAttribute('for', checkbox.getAttribute('id'));\n }\n};\n\nconst testCheckboxWithRequiredBehavior = async (\n args: CheckboxWithRequiredArgs,\n canvasElement: HTMLElement\n) => {\n const canvas = within(canvasElement);\n const checkbox = await waitFor(() => canvas.getByTestId('checkbox-id'));\n const button = await waitFor(() => canvas.getByTestId('btn-id'));\n\n if (checkbox.shadowRoot) {\n const innerCheckbox = checkbox.shadowRoot.querySelector(\n '[data-testid=\"checkbox-atom\"]'\n );\n\n // Test: Checkbox should have the correct required attribute\n if (args.required) {\n expect(innerCheckbox).toHaveAttribute('required');\n } else {\n expect(innerCheckbox).not.toHaveAttribute('required');\n }\n\n // Test: Button should be disabled when checkbox is unchecked and required is true\n if (args.required && !args.checked) {\n expect(button).toBeDisabled();\n } else if (args.required && args.checked) {\n expect(button).not.toBeDisabled();\n }\n\n // Additional tests for the checked state\n if (args.checked) {\n expect(innerCheckbox).toBeChecked();\n } else {\n expect(innerCheckbox).not.toBeChecked();\n }\n\n // Additional tests for the disabled state\n if (args.disabled) {\n expect(innerCheckbox).toBeDisabled();\n } else {\n expect(innerCheckbox).not.toBeDisabled();\n }\n }\n};\n\nconst testCheckboxWithValueBehavior = async (\n args: CheckboxWithValueArgs,\n canvasElement: HTMLElement\n) => {\n const canvas = within(canvasElement);\n const checkbox = await waitFor(() => canvas.getByTestId('checkbox-id'));\n\n if (checkbox.shadowRoot) {\n const innerCheckbox = checkbox.shadowRoot.querySelector(\n '[data-testid=\"checkbox-atom\"]'\n );\n\n // Test: Checkbox should have the correct value attribute\n expect(innerCheckbox).toHaveAttribute('value', args.value);\n\n // Additional tests for disabled state if needed\n if (args.disabled) {\n expect(innerCheckbox).toBeDisabled();\n } else {\n expect(innerCheckbox).not.toBeDisabled();\n }\n }\n};\n\nconst TemplatewithChecked: StoryFn = ({ disabled, checked, label }) =>\n html`\n <div style=\"display:flex\">\n <rtg-checkbox\n id=\"terms\"\n data-testid=\"checkbox-id\"\n ?disabled=${disabled}\n ?checked=${checked}\n ></rtg-checkbox>\n <rtg-label style=\"margin:2px 0px 0px 4px\" for=\"terms\">${label}</rtg-label>\n </div>\n `;\n\nconst TemplatewithRequired: StoryFn = ({\n disabled,\n checked,\n label,\n required,\n}) =>\n html`\n <div style=\"display: flex; flex-direction: column;\">\n <div style=\"display:flex\">\n <rtg-checkbox\n id=\"terms\"\n data-testid=\"checkbox-id\"\n ?disabled=${disabled}\n ?checked=${checked}\n ?required=${required}\n @click=${(e: Event) => {\n const checkbox = e.target as HTMLInputElement;\n const button = document.querySelector(\n 'rtg-button'\n ) as HTMLButtonElement;\n if (button) {\n button.disabled = required ? !checkbox.checked : false;\n }\n }}\n ></rtg-checkbox>\n <rtg-label style=\"margin:2px 0px 0px 4px\" for=\"terms\"\n >${label}</rtg-label\n >\n </div>\n <div style=\"margin-top:16px\">\n <rtg-button\n variant=\"default\"\n size=\"default\"\n data-testid=\"btn-id\"\n ?disabled=${required ? !checked : false}\n .click=${mockOnClickHandler}\n >Submit</rtg-button\n >\n </div>\n </div>\n `;\n\nconst TemplateWithVlaue: StoryFn = ({ disabled, label, value }) =>\n html`\n <div style=\"display:flex\">\n <rtg-checkbox\n id=\"terms\"\n data-testid=\"checkbox-id\"\n value=${value}\n ?disabled=${disabled}\n ></rtg-checkbox>\n <rtg-label style=\"margin:2px 0px 0px 4px\" for=\"terms\">${label}</rtg-label>\n </div>\n `;\n\nexport const CheckboxWithReuired = TemplatewithRequired.bind({});\nCheckboxWithReuired.args = {\n disabled: false,\n checked: false,\n required: false,\n label: 'Accept terms and conditions',\n};\n\nCheckboxWithReuired.parameters = {\n docs: {\n source: {\n transform: (code: string, storyContext: StoryContext) => {\n const args = storyContext.args;\n\n // Handling boolean attributes: if true, render without value, if false, omit the attribute\n const updatedCode = code\n .replace(/disabled=\"\"/g, 'disabled=true')\n .replace(/checked=\"\"/g, 'checked=true')\n .replace(/required=\"\"/g, 'required=true')\n .replace(/disabled=\"false\"/g, '')\n .replace(/checked=\"false\"/g, '')\n .replace(/required=\"false\"/g, '');\n\n return updatedCode;\n },\n },\n },\n};\n\nCheckboxWithReuired.argTypes = {\n disabled: {\n control: 'boolean',\n description: 'Determines whether the checkbox is disabled (unclickable).',\n table: {\n defaultValue: { summary: 'false' },\n },\n docs: {\n source: {\n code: (args: { disabled: boolean }) => (args.disabled ? true : ''),\n },\n },\n },\n checked: {\n control: 'boolean',\n description: 'Specifies whether the checkbox is checked by default.',\n table: {\n defaultValue: { summary: 'false' },\n },\n },\n required: {\n control: 'boolean',\n description:\n '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.',\n table: {\n defaultValue: { summary: 'false' },\n },\n },\n label: {\n control: 'text',\n description:\n 'The text displayed next to the checkbox, describing its purpose.',\n },\n};\n\nCheckboxWithReuired.play = async ({ args, canvasElement }) => {\n await testCheckboxWithRequiredBehavior(\n args as CheckboxWithRequiredArgs,\n canvasElement\n );\n};\n\nexport const Checkbox = TemplatewithChecked.bind({});\nCheckbox.args = {\n disabled: false,\n checked: false,\n label: 'Accept terms and conditions',\n};\n\nCheckbox.argTypes = {\n disabled: {\n control: 'boolean',\n },\n checked: {\n control: 'boolean',\n },\n label: {\n control: 'text',\n },\n};\n\nCheckbox.play = async ({ args, canvasElement }) => {\n await testCheckboxBehavior(args as CheckboxArgs, canvasElement);\n};\n\nexport const CheckboxWithValue = TemplateWithVlaue.bind({});\nCheckboxWithValue.args = {\n disabled: false,\n value: 'off',\n label: 'Accept terms and conditions',\n};\n\nCheckboxWithValue.argTypes = {\n disabled: { control: 'boolean' },\n value: {\n control: { type: 'select' },\n options: ['on', 'off'],\n },\n label: { control: 'text' },\n};\n\nCheckboxWithValue.play = async ({ args, canvasElement }) => {\n await testCheckboxWithValueBehavior(\n args as CheckboxWithValueArgs,\n canvasElement\n );\n};\n"]}
|
@@ -1,3 +0,0 @@
|
|
1
|
-
export const checkboxStyles = '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';
|
2
|
-
export const iconStyles = 'flex items-center justify-center text-current pointer-events-none';
|
3
|
-
//# sourceMappingURL=checkbox.style.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"checkbox.style.js","sourceRoot":"","sources":["../../../../../src/components/atoms/checkbox/checkbox.style.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GACzB,iSAAiS,CAAC;AAEpS,MAAM,CAAC,MAAM,UAAU,GACrB,mEAAmE,CAAC","sourcesContent":["export const checkboxStyles =\n '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';\n\nexport const iconStyles =\n 'flex items-center justify-center text-current pointer-events-none';\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"checkbox.type.js","sourceRoot":"","sources":["../../../../../src/components/atoms/checkbox/checkbox.type.ts"],"names":[],"mappings":"","sourcesContent":["export type CheckboxProperties = {\n disabled: boolean;\n checked: boolean;\n};\n\nexport type CheckboxArgs = {\n disabled: boolean;\n checked: boolean;\n label: string;\n};\n\nexport type CheckboxWithRequiredArgs = {\n disabled: boolean;\n checked: boolean;\n required: boolean;\n label: string;\n value?: string;\n};\n\nexport type CheckboxWithValueArgs = {\n disabled: boolean;\n value: string;\n label: string;\n};\n"]}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
import { __decorate } from "tslib";
|
2
|
-
import { LitElement, html, css } from 'lit';
|
3
|
-
import { customElement, property } from 'lit/decorators.js';
|
4
|
-
import { TWStyles } from '../../../styles';
|
5
|
-
let ComboBoxInput = class ComboBoxInput extends LitElement {
|
6
|
-
constructor() {
|
7
|
-
super(...arguments);
|
8
|
-
this.value = '';
|
9
|
-
this.handleClick = () => { };
|
10
|
-
this.handleKeyDown = () => { };
|
11
|
-
}
|
12
|
-
render() {
|
13
|
-
return html `
|
14
|
-
<input
|
15
|
-
class="inline-flex justify-between items-center w-full h-10 px-4 py-2 whitespace-nowrap rounded-md
|
16
|
-
text-sm font-medium border border-input cursor-pointer
|
17
|
-
ring-offset-background
|
18
|
-
transition-colors disabled:pointer-events-none
|
19
|
-
disabled:opacity-50
|
20
|
-
bg-background hover:bg-accent
|
21
|
-
hover:text-accent-foreground
|
22
|
-
outline-none"
|
23
|
-
role="combobox"
|
24
|
-
aria-expanded="false"
|
25
|
-
readonly="true"
|
26
|
-
.value=${this.value}
|
27
|
-
@click=${this.handleClick}
|
28
|
-
@keydown=${this.handleKeyDown}
|
29
|
-
/>
|
30
|
-
`;
|
31
|
-
}
|
32
|
-
};
|
33
|
-
ComboBoxInput.styles = [css ``, TWStyles];
|
34
|
-
__decorate([
|
35
|
-
property({ type: String })
|
36
|
-
], ComboBoxInput.prototype, "value", void 0);
|
37
|
-
__decorate([
|
38
|
-
property({ type: Function })
|
39
|
-
], ComboBoxInput.prototype, "handleClick", void 0);
|
40
|
-
__decorate([
|
41
|
-
property({ type: Function })
|
42
|
-
], ComboBoxInput.prototype, "handleKeyDown", void 0);
|
43
|
-
ComboBoxInput = __decorate([
|
44
|
-
customElement('combo-box-input')
|
45
|
-
], ComboBoxInput);
|
46
|
-
export { ComboBoxInput };
|
47
|
-
//# sourceMappingURL=combo-box-input.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"combo-box-input.js","sourceRoot":"","sources":["../../../../../src/components/atoms/combo-box/combo-box-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGpC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;;QACuB,UAAK,GAAG,EAAE,CAAC;QACT,gBAAW,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QACvB,kBAAa,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;IAwBzD,CAAC;IApBC,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;;;;iBAaE,IAAI,CAAC,KAAK;iBACV,IAAI,CAAC,WAAW;mBACd,IAAI,CAAC,aAAa;;KAEhC,CAAC;IACJ,CAAC;;AArBM,oBAAM,GAAG,CAAC,GAAG,CAAA,EAAE,EAAE,QAAQ,CAAC,AAApB,CAAqB;AAJN;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAY;AACT;IAA7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;kDAAwB;AACvB;IAA7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;oDAA0B;AAH5C,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CA2BzB","sourcesContent":["import { LitElement, html, css } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { TWStyles } from '../../../styles';\n\n@customElement('combo-box-input')\nexport class ComboBoxInput extends LitElement {\n @property({ type: String }) value = '';\n @property({ type: Function }) handleClick = () => {};\n @property({ type: Function }) handleKeyDown = () => {};\n\n static styles = [css``, TWStyles];\n\n render() {\n return html`\n <input\n class=\"inline-flex justify-between items-center w-full h-10 px-4 py-2 whitespace-nowrap rounded-md \n text-sm font-medium border border-input cursor-pointer \n ring-offset-background \n transition-colors disabled:pointer-events-none \n disabled:opacity-50 \n bg-background hover:bg-accent \n hover:text-accent-foreground \n outline-none\"\n role=\"combobox\"\n aria-expanded=\"false\"\n readonly=\"true\"\n .value=${this.value}\n @click=${this.handleClick}\n @keydown=${this.handleKeyDown}\n />\n `;\n }\n}\n"]}
|
@@ -1,85 +0,0 @@
|
|
1
|
-
import { __decorate } from "tslib";
|
2
|
-
import { LitElement, css, html } from 'lit';
|
3
|
-
import { customElement, property } from 'lit/decorators.js';
|
4
|
-
import { tickIcon } from '../../../assets/icons';
|
5
|
-
import { TWStyles } from '../../../styles';
|
6
|
-
let ComboBoxItem = class ComboBoxItem extends LitElement {
|
7
|
-
constructor() {
|
8
|
-
super(...arguments);
|
9
|
-
this.key = '';
|
10
|
-
this.searchText = '';
|
11
|
-
this.value = '';
|
12
|
-
this.tabindex = 0;
|
13
|
-
this.isSelected = false;
|
14
|
-
this.class = '';
|
15
|
-
this.onSelect = () => { };
|
16
|
-
}
|
17
|
-
render() {
|
18
|
-
console.log('this', this.class);
|
19
|
-
return html `
|
20
|
-
<div
|
21
|
-
key="${this.key}"
|
22
|
-
class="flex items-center cursor-pointer py-2 px-4 w-full text-sm text-gray-800
|
23
|
-
rounded-lg
|
24
|
-
hover:bg-gray-100
|
25
|
-
focus:outline-none
|
26
|
-
focus:bg-gray-100
|
27
|
-
dark:bg-neutral-900
|
28
|
-
dark:hover:bg-neutral-800
|
29
|
-
dark:text-neutral-200
|
30
|
-
dark:focus:bg-neutral-800
|
31
|
-
${this.class}
|
32
|
-
"
|
33
|
-
tabindex="${this.tabindex}"
|
34
|
-
aria-selected="${this.isSelected}"
|
35
|
-
data-selected="${this.isSelected}"
|
36
|
-
data-hs-combo-box-output-item=""
|
37
|
-
role="option"
|
38
|
-
@click="${this.onSelect}"
|
39
|
-
>
|
40
|
-
<span
|
41
|
-
class="${this.isSelected
|
42
|
-
? 'visible'
|
43
|
-
: 'invisible'} hs-combo-box-selected:block mr-2"
|
44
|
-
>
|
45
|
-
${tickIcon()}
|
46
|
-
</span>
|
47
|
-
<div class="flex justify-between items-center w-full">
|
48
|
-
<span
|
49
|
-
data-hs-combo-box-search-text="${this.searchText}"
|
50
|
-
data-hs-combo-box-value="${this.value}"
|
51
|
-
>
|
52
|
-
${this.searchText}
|
53
|
-
</span>
|
54
|
-
</div>
|
55
|
-
</div>
|
56
|
-
`;
|
57
|
-
}
|
58
|
-
};
|
59
|
-
ComboBoxItem.styles = [css ``, TWStyles];
|
60
|
-
__decorate([
|
61
|
-
property({ type: String })
|
62
|
-
], ComboBoxItem.prototype, "key", void 0);
|
63
|
-
__decorate([
|
64
|
-
property({ type: String })
|
65
|
-
], ComboBoxItem.prototype, "searchText", void 0);
|
66
|
-
__decorate([
|
67
|
-
property({ type: String })
|
68
|
-
], ComboBoxItem.prototype, "value", void 0);
|
69
|
-
__decorate([
|
70
|
-
property({ type: Number })
|
71
|
-
], ComboBoxItem.prototype, "tabindex", void 0);
|
72
|
-
__decorate([
|
73
|
-
property({ type: Boolean })
|
74
|
-
], ComboBoxItem.prototype, "isSelected", void 0);
|
75
|
-
__decorate([
|
76
|
-
property({ type: String })
|
77
|
-
], ComboBoxItem.prototype, "class", void 0);
|
78
|
-
__decorate([
|
79
|
-
property({ type: Function })
|
80
|
-
], ComboBoxItem.prototype, "onSelect", void 0);
|
81
|
-
ComboBoxItem = __decorate([
|
82
|
-
customElement('combo-box-item')
|
83
|
-
], ComboBoxItem);
|
84
|
-
export { ComboBoxItem };
|
85
|
-
//# sourceMappingURL=combo-box-item.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"combo-box-item.js","sourceRoot":"","sources":["../../../../../src/components/atoms/combo-box/combo-box-item.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGpC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QACuB,QAAG,GAAG,EAAE,CAAC;QACT,eAAU,GAAG,EAAE,CAAC;QAChB,UAAK,GAAG,EAAE,CAAC;QACX,aAAQ,GAAG,CAAC,CAAC;QACZ,eAAU,GAAG,KAAK,CAAC;QACpB,UAAK,GAAG,EAAE,CAAC;QACT,aAAQ,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;IA6CpD,CAAC;IAzCC,MAAM;QACJ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,OAAO,IAAI,CAAA;;eAEA,IAAI,CAAC,GAAG;;;;;;;;;;UAUb,IAAI,CAAC,KAAK;;oBAEA,IAAI,CAAC,QAAQ;yBACR,IAAI,CAAC,UAAU;yBACf,IAAI,CAAC,UAAU;;;kBAGtB,IAAI,CAAC,QAAQ;;;mBAGZ,IAAI,CAAC,UAAU;YACtB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,WAAW;;YAEb,QAAQ,EAAE;;;;6CAIuB,IAAI,CAAC,UAAU;uCACrB,IAAI,CAAC,KAAK;;cAEnC,IAAI,CAAC,UAAU;;;;KAIxB,CAAC;IACJ,CAAC;;AA1CM,mBAAM,GAAG,CAAC,GAAG,CAAA,EAAE,EAAE,QAAQ,CAAC,AAApB,CAAqB;AARN;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAU;AACT;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAY;AACX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAc;AACZ;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAoB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAY;AACT;IAA7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;8CAAqB;AAPvC,YAAY;IADxB,aAAa,CAAC,gBAAgB,CAAC;GACnB,YAAY,CAoDxB","sourcesContent":["import { LitElement, css, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { tickIcon } from '../../../assets/icons';\nimport { TWStyles } from '../../../styles';\n\n@customElement('combo-box-item')\nexport class ComboBoxItem extends LitElement {\n @property({ type: String }) key = '';\n @property({ type: String }) searchText = '';\n @property({ type: String }) value = '';\n @property({ type: Number }) tabindex = 0;\n @property({ type: Boolean }) isSelected = false;\n @property({ type: String }) class = '';\n @property({ type: Function }) onSelect = () => {};\n\n static styles = [css``, TWStyles];\n\n render() {\n console.log('this', this.class);\n return html`\n <div\n key=\"${this.key}\"\n class=\"flex items-center cursor-pointer py-2 px-4 w-full text-sm text-gray-800 \n rounded-lg \n hover:bg-gray-100\n focus:outline-none \n focus:bg-gray-100 \n dark:bg-neutral-900 \n dark:hover:bg-neutral-800 \n dark:text-neutral-200 \n dark:focus:bg-neutral-800\n ${this.class}\n \"\n tabindex=\"${this.tabindex}\"\n aria-selected=\"${this.isSelected}\"\n data-selected=\"${this.isSelected}\"\n data-hs-combo-box-output-item=\"\"\n role=\"option\"\n @click=\"${this.onSelect}\"\n >\n <span\n class=\"${this.isSelected\n ? 'visible'\n : 'invisible'} hs-combo-box-selected:block mr-2\"\n >\n ${tickIcon()}\n </span>\n <div class=\"flex justify-between items-center w-full\">\n <span\n data-hs-combo-box-search-text=\"${this.searchText}\"\n data-hs-combo-box-value=\"${this.value}\"\n >\n ${this.searchText}\n </span>\n </div>\n </div>\n `;\n }\n}\n"]}
|
@@ -1,67 +0,0 @@
|
|
1
|
-
import { __decorate } from "tslib";
|
2
|
-
import { LitElement, css, html } from 'lit';
|
3
|
-
import { customElement, property, state } from 'lit/decorators.js';
|
4
|
-
import { searchIcon } from '../../../assets/icons';
|
5
|
-
import { TWStyles } from '../../../styles';
|
6
|
-
import { STATE_CLOSED, STATE_OPEN } from '../popover/popover.types';
|
7
|
-
import { ComboBox } from './combo-box.atom';
|
8
|
-
let ComboBoxList = class ComboBoxList extends LitElement {
|
9
|
-
constructor() {
|
10
|
-
super(...arguments);
|
11
|
-
this.state = STATE_CLOSED;
|
12
|
-
this.isOpen = false;
|
13
|
-
}
|
14
|
-
get _popover() {
|
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
|
-
render() {
|
23
|
-
console.log('this.state', this.state);
|
24
|
-
// @keydown="${this.handleKeyDown}"
|
25
|
-
// @input="${this.handleSearch}"
|
26
|
-
// @keydown="${this.handleKeyDown}"
|
27
|
-
return html `
|
28
|
-
<div
|
29
|
-
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"
|
30
|
-
data-hs-combo-box-output=""
|
31
|
-
style="display: ${this.state === STATE_OPEN
|
32
|
-
? 'block'
|
33
|
-
: 'none'}; top:115%"
|
34
|
-
>
|
35
|
-
<div
|
36
|
-
class="flex items-center justify-center px-3 border-b border-gray-300 mb-1"
|
37
|
-
>
|
38
|
-
${searchIcon()}
|
39
|
-
<input
|
40
|
-
type="text"
|
41
|
-
class="w-full px-2 py-2 rounded focus:outline-none"
|
42
|
-
placeholder="Search..."
|
43
|
-
autocomplete="off"
|
44
|
-
autocorrect="off"
|
45
|
-
spellcheck="false"
|
46
|
-
aria-autocomplete="list"
|
47
|
-
aria-expanded="true"
|
48
|
-
role="combobox"
|
49
|
-
/>
|
50
|
-
</div>
|
51
|
-
<slot></slot>
|
52
|
-
</div>
|
53
|
-
`;
|
54
|
-
}
|
55
|
-
};
|
56
|
-
ComboBoxList.styles = [css ``, TWStyles];
|
57
|
-
__decorate([
|
58
|
-
property({ attribute: 'data-state', type: String })
|
59
|
-
], ComboBoxList.prototype, "state", void 0);
|
60
|
-
__decorate([
|
61
|
-
state()
|
62
|
-
], ComboBoxList.prototype, "isOpen", void 0);
|
63
|
-
ComboBoxList = __decorate([
|
64
|
-
customElement('combo-box-list')
|
65
|
-
], ComboBoxList);
|
66
|
-
export { ComboBoxList };
|
67
|
-
//# sourceMappingURL=combo-box-list.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"combo-box-list.js","s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AAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAsB;AAEjE;IAAR,KAAK,EAAE;4CAAgB;AAJb,YAAY;IADxB,aAAa,CAAC,gBAAgB,CAAC;GACnB,YAAY,CAgDxB","sourcesContent":["import { LitElement, PropertyValues, css, html } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { searchIcon } from '../../../assets/icons';\nimport { TWStyles } from '../../../styles';\nimport { STATE_CLOSED, STATE_OPEN } from '../popover/popover.types';\nimport { ComboBox } from './combo-box.atom';\n\n@customElement('combo-box-list')\nexport class ComboBoxList extends LitElement {\n static styles = [css``, TWStyles];\n @property({ attribute: 'data-state', type: String }) state = STATE_CLOSED;\n\n @state() isOpen = false;\n get _popover(): ComboBox | null {\n let parent = this.parentElement;\n // Traverse up the DOM tree to find the parent `Popover`\n while (parent && !(parent instanceof ComboBox)) {\n parent = parent.parentElement;\n }\n return parent;\n }\n\n render() {\n console.log('this.state', this.state);\n // @keydown=\"${this.handleKeyDown}\"\n\n // @input=\"${this.handleSearch}\"\n // @keydown=\"${this.handleKeyDown}\"\n return html`\n <div\n 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\"\n data-hs-combo-box-output=\"\"\n style=\"display: ${this.state === STATE_OPEN\n ? 'block'\n : 'none'}; top:115%\"\n >\n <div\n class=\"flex items-center justify-center px-3 border-b border-gray-300 mb-1\"\n >\n ${searchIcon()}\n <input\n type=\"text\"\n class=\"w-full px-2 py-2 rounded focus:outline-none\"\n placeholder=\"Search...\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n aria-autocomplete=\"list\"\n aria-expanded=\"true\"\n role=\"combobox\"\n />\n </div>\n <slot></slot>\n </div>\n `;\n }\n}\n"]}
|