@warp-ds/elements 2.2.0-next.9 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +188 -26
- package/dist/.storybook/utilities.js +52 -0
- package/dist/api.js.map +1 -1
- package/dist/custom-elements.json +1381 -2711
- package/dist/index.d.ts +942 -25
- package/dist/packages/affix/affix.react.stories.d.ts +9 -0
- package/dist/packages/affix/affix.react.stories.js +10 -0
- package/dist/packages/affix/affix.stories.js +25 -0
- package/dist/packages/affix/affix.test.js +9 -0
- package/dist/packages/affix/index.d.ts +0 -17
- package/dist/packages/affix/index.js +5 -5
- package/dist/packages/affix/index.js.map +4 -4
- package/dist/packages/affix/react.d.ts +1 -1
- package/dist/packages/affix/react.js +15 -2482
- package/dist/packages/affix/styles.js +2 -0
- package/dist/packages/alert/alert.react.stories.d.ts +13 -0
- package/dist/packages/alert/alert.react.stories.js +44 -0
- package/dist/packages/alert/alert.stories.js +68 -0
- package/dist/packages/alert/alert.test.js +18 -0
- package/dist/packages/alert/index.d.ts +1 -6
- package/dist/packages/alert/index.js +4 -4
- package/dist/packages/alert/index.js.map +4 -4
- package/dist/packages/alert/react.d.ts +1 -1
- package/dist/packages/alert/react.js +11 -2492
- package/dist/packages/alert/styles.js +2 -0
- package/dist/packages/attention/attention.react.stories.d.ts +15 -0
- package/dist/packages/attention/attention.react.stories.js +92 -0
- package/dist/packages/attention/attention.stories.d.ts +1 -0
- package/dist/packages/attention/attention.stories.js +180 -0
- package/dist/packages/attention/attention.test.js +11 -0
- package/dist/packages/attention/index.d.ts +3 -29
- package/dist/packages/attention/index.js +249 -19
- package/dist/packages/attention/index.js.map +4 -4
- package/dist/packages/attention/layout-styles.js +905 -0
- package/dist/packages/attention/locales/da/messages.mjs +1 -0
- package/dist/packages/attention/locales/en/messages.mjs +1 -0
- package/dist/packages/attention/locales/fi/messages.mjs +1 -0
- package/dist/packages/attention/locales/nb/messages.mjs +1 -0
- package/dist/packages/attention/locales/sv/messages.mjs +1 -0
- package/dist/packages/attention/react.d.ts +15 -1
- package/dist/packages/attention/react.js +17 -3405
- package/dist/packages/attention/styles.js +2 -0
- package/dist/packages/badge/badge.react.stories.d.ts +18 -0
- package/dist/packages/badge/badge.react.stories.js +60 -0
- package/dist/packages/badge/badge.stories.js +68 -0
- package/dist/packages/badge/badge.test.js +9 -0
- package/dist/packages/badge/index.d.ts +0 -5
- package/dist/packages/badge/index.js +1 -1
- package/dist/packages/badge/index.js.map +4 -4
- package/dist/packages/badge/react.d.ts +1 -1
- package/dist/packages/badge/react.js +11 -2465
- package/dist/packages/badge/styles.js +2 -0
- package/dist/packages/box/box.react.stories.d.ts +15 -0
- package/dist/packages/box/box.react.stories.js +45 -0
- package/dist/packages/box/box.stories.js +59 -0
- package/dist/packages/box/box.test.js +9 -0
- package/dist/packages/box/index.d.ts +0 -5
- package/dist/packages/box/index.js +11 -4
- package/dist/packages/box/index.js.map +4 -4
- package/dist/packages/box/react.d.ts +1 -1
- package/dist/packages/box/react.js +11 -2465
- package/dist/packages/box/slot.test.js +9 -0
- package/dist/packages/box/styles.js +2 -0
- package/dist/packages/breadcrumbs/breadcrumbs.react.stories.d.ts +13 -0
- package/dist/packages/breadcrumbs/breadcrumbs.react.stories.js +40 -0
- package/dist/packages/breadcrumbs/breadcrumbs.stories.js +60 -0
- package/dist/packages/breadcrumbs/breadcrumbs.test.js +16 -0
- package/dist/packages/breadcrumbs/index.d.ts +0 -12
- package/dist/packages/breadcrumbs/index.js +6 -6
- package/dist/packages/breadcrumbs/index.js.map +4 -4
- package/dist/packages/breadcrumbs/locales/da/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/en/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/fi/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/nb/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/sv/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/react.d.ts +1 -1
- package/dist/packages/breadcrumbs/react.js +11 -2475
- package/dist/packages/breadcrumbs/styles.js +2 -0
- package/dist/packages/button/button.react.stories.d.ts +22 -0
- package/dist/packages/button/button.react.stories.js +102 -0
- package/dist/packages/button/button.stories.d.ts +4 -0
- package/dist/packages/button/button.stories.js +151 -0
- package/dist/packages/button/button.test.js +25 -0
- package/dist/packages/button/index.d.ts +0 -66
- package/dist/packages/button/index.js +17 -11
- package/dist/packages/button/index.js.map +4 -4
- package/dist/packages/button/locales/da/messages.mjs +1 -0
- package/dist/packages/button/locales/en/messages.mjs +1 -0
- package/dist/packages/button/locales/fi/messages.mjs +1 -0
- package/dist/packages/button/locales/nb/messages.mjs +1 -0
- package/dist/packages/button/locales/sv/messages.mjs +1 -0
- package/dist/packages/button/react.d.ts +1 -1
- package/dist/packages/button/react.js +10 -2684
- package/dist/packages/button/styles.js +2 -0
- package/dist/packages/card/card.react.stories.d.ts +16 -0
- package/dist/packages/card/card.react.stories.js +63 -0
- package/dist/packages/card/card.stories.js +82 -0
- package/dist/packages/card/card.test.js +9 -0
- package/dist/packages/card/index.d.ts +1 -18
- package/dist/packages/card/index.js +4 -4
- package/dist/packages/card/index.js.map +4 -4
- package/dist/packages/card/locales/da/messages.mjs +1 -0
- package/dist/packages/card/locales/en/messages.mjs +1 -0
- package/dist/packages/card/locales/fi/messages.mjs +1 -0
- package/dist/packages/card/locales/nb/messages.mjs +1 -0
- package/dist/packages/card/locales/sv/messages.mjs +1 -0
- package/dist/packages/card/react.d.ts +1 -1
- package/dist/packages/card/react.js +11 -2487
- package/dist/packages/card/styles.js +2 -0
- package/dist/packages/expandable/expandable.react.stories.d.ts +18 -0
- package/dist/packages/expandable/expandable.react.stories.js +103 -0
- package/dist/packages/expandable/expandable.stories.js +132 -0
- package/dist/packages/expandable/expandable.test.js +24 -0
- package/dist/packages/expandable/index.d.ts +2 -33
- package/dist/packages/expandable/index.js +20 -11
- package/dist/packages/expandable/index.js.map +4 -4
- package/dist/packages/expandable/react.d.ts +1 -1
- package/dist/packages/expandable/react.js +11 -2495
- package/dist/packages/expandable/styles.js +2 -0
- package/dist/packages/i18n.js +45 -0
- package/dist/packages/link/index.d.ts +0 -5
- package/dist/packages/link/index.js +93 -2640
- package/dist/packages/link/styles.js +200 -0
- package/dist/packages/modal/index.js +24 -41
- package/dist/packages/modal/index.js.map +4 -4
- package/dist/packages/modal/locales/da/messages.mjs +1 -0
- package/dist/packages/modal/locales/en/messages.mjs +1 -0
- package/dist/packages/modal/locales/fi/messages.mjs +1 -0
- package/dist/packages/modal/locales/nb/messages.mjs +1 -0
- package/dist/packages/modal/locales/sv/messages.mjs +1 -0
- package/dist/packages/modal/modal-footer.d.ts +0 -5
- package/dist/packages/{dead-toggle/index.js → modal/modal-footer.js} +20 -47
- package/dist/packages/modal/modal-footer.js.map +7 -0
- package/dist/packages/modal/modal-header.d.ts +0 -5
- package/dist/packages/{steps/index.js → modal/modal-header.js} +122 -20
- package/dist/packages/modal/modal-header.js.map +7 -0
- package/dist/packages/modal/modal-main.d.ts +0 -5
- package/dist/packages/{dead-toggle/react.js → modal/modal-main.js} +124 -59
- package/dist/packages/{box/react.js.map → modal/modal-main.js.map} +4 -4
- package/dist/packages/modal/modal.react.stories.d.ts +14 -0
- package/dist/packages/modal/modal.react.stories.js +27 -0
- package/dist/packages/modal/modal.stories.d.ts +3 -3
- package/dist/packages/modal/modal.stories.js +254 -0
- package/dist/packages/modal/react.d.ts +11 -3
- package/dist/packages/modal/react.js +31 -2754
- package/dist/packages/modal/util.js +21 -0
- package/dist/packages/pill/index.d.ts +0 -17
- package/dist/packages/pill/index.js +5 -5
- package/dist/packages/pill/index.js.map +2 -2
- package/dist/packages/pill/locales/da/messages.mjs +1 -0
- package/dist/packages/pill/locales/en/messages.mjs +1 -0
- package/dist/packages/pill/locales/fi/messages.mjs +1 -0
- package/dist/packages/pill/locales/nb/messages.mjs +1 -0
- package/dist/packages/pill/locales/sv/messages.mjs +1 -0
- package/dist/packages/pill/pill.react.stories.d.ts +23 -0
- package/dist/packages/pill/pill.react.stories.js +22 -0
- package/dist/packages/pill/pill.stories.js +33 -0
- package/dist/packages/pill/pill.test.js +25 -0
- package/dist/packages/pill/react.d.ts +7 -0
- package/dist/packages/pill/react.js +17 -0
- package/dist/packages/pill/styles.js +2 -0
- package/dist/packages/select/index.d.ts +4 -29
- package/dist/packages/select/index.js +25 -18
- package/dist/packages/select/index.js.map +3 -3
- package/dist/packages/select/locales/da/messages.mjs +1 -0
- package/dist/packages/select/locales/en/messages.mjs +1 -0
- package/dist/packages/select/locales/fi/messages.mjs +1 -0
- package/dist/packages/select/locales/nb/messages.mjs +1 -0
- package/dist/packages/select/locales/sv/messages.mjs +1 -0
- package/dist/packages/select/react.d.ts +6 -2
- package/dist/packages/select/react.js +20 -2494
- package/dist/packages/select/select.react.stories.d.ts +18 -0
- package/dist/packages/select/select.react.stories.js +28 -0
- package/dist/packages/select/select.stories.d.ts +7 -0
- package/dist/packages/select/select.stories.js +100 -0
- package/dist/packages/select/select.test.js +31 -0
- package/dist/packages/select/styles.js +2 -0
- package/dist/packages/{switch/index.js → styles.js} +5 -18
- package/dist/packages/textfield/index.d.ts +12 -26
- package/dist/packages/textfield/index.js +86 -28
- package/dist/packages/textfield/index.js.map +4 -4
- package/dist/packages/textfield/react.d.ts +11 -2
- package/dist/packages/textfield/react.js +21 -2490
- package/dist/packages/textfield/styles/w-textfield.styles.d.ts +1 -0
- package/dist/packages/textfield/styles/w-textfield.styles.js +55 -0
- package/dist/packages/textfield/styles.js +2 -0
- package/dist/packages/textfield/textfield.react.stories.d.ts +37 -0
- package/dist/packages/textfield/textfield.react.stories.js +88 -0
- package/dist/packages/textfield/textfield.stories.d.ts +1 -0
- package/dist/packages/textfield/textfield.stories.js +105 -0
- package/dist/packages/textfield/textfield.test.d.ts +1 -0
- package/dist/packages/textfield/textfield.test.js +68 -0
- package/dist/packages/toast/api.d.ts +1 -1
- package/dist/packages/toast/api.js +41 -0
- package/dist/packages/toast/index.d.ts +1 -1
- package/dist/packages/toast/index.js +17 -17
- package/dist/packages/toast/index.js.map +4 -4
- package/dist/packages/toast/locales/da/messages.mjs +1 -0
- package/dist/packages/toast/locales/en/messages.mjs +1 -0
- package/dist/packages/toast/locales/fi/messages.mjs +1 -0
- package/dist/packages/toast/locales/nb/messages.mjs +1 -0
- package/dist/packages/toast/locales/sv/messages.mjs +1 -0
- package/dist/packages/toast/styles.js +2 -0
- package/dist/packages/toast/toast-container.d.ts +1 -1
- package/dist/packages/{switch/react.js → toast/toast-container.js} +21 -38
- package/dist/packages/toast/toast-container.js.map +7 -0
- package/dist/packages/{pagination/index.js → toast/toast.js} +21 -49
- package/dist/packages/toast/toast.js.map +7 -0
- package/dist/packages/toast/toast.stories.js +50 -0
- package/dist/packages/toast/types.js +1 -0
- package/dist/packages/utils/expand-transition.d.ts +3 -3
- package/dist/packages/utils/expand-transition.js +59 -0
- package/dist/packages/utils/index.js +37 -0
- package/dist/packages/utils/unstyled-heading.d.ts +2 -3
- package/dist/packages/utils/unstyled-heading.js +22 -0
- package/dist/packages/utils/window-exists.js +1 -0
- package/dist/setup-tests.js +1 -0
- package/dist/web-types.json +150 -438
- package/package.json +39 -32
- package/dist/index.css +0 -2
- package/dist/index.css.map +0 -7
- package/dist/index.js +0 -4285
- package/dist/index.js.map +0 -7
- package/dist/packages/affix/react.js.map +0 -7
- package/dist/packages/alert/react.js.map +0 -7
- package/dist/packages/attention/react.js.map +0 -7
- package/dist/packages/badge/react.js.map +0 -7
- package/dist/packages/breadcrumbs/react.js.map +0 -7
- package/dist/packages/button/react.js.map +0 -7
- package/dist/packages/card/react.js.map +0 -7
- package/dist/packages/datepicker/DatePicker.test.d.ts +0 -1
- package/dist/packages/datepicker/datepicker.d.ts +0 -107
- package/dist/packages/datepicker/datepicker.stories.d.ts +0 -11
- package/dist/packages/datepicker/datepicker.test.d.ts +0 -2
- package/dist/packages/datepicker/index.d.ts +0 -1
- package/dist/packages/datepicker/index.js +0 -2785
- package/dist/packages/datepicker/index.js.map +0 -7
- package/dist/packages/datepicker/locales/da/messages.d.mts +0 -1
- package/dist/packages/datepicker/locales/en/messages.d.mts +0 -1
- package/dist/packages/datepicker/locales/fi/messages.d.mts +0 -1
- package/dist/packages/datepicker/locales/nb/messages.d.mts +0 -1
- package/dist/packages/datepicker/locales/sv/messages.d.mts +0 -1
- package/dist/packages/datepicker/react.d.ts +0 -2
- package/dist/packages/datepicker/react.js +0 -2805
- package/dist/packages/datepicker/react.js.map +0 -7
- package/dist/packages/datepicker/styles/w-datepicker-calendar.styles.d.ts +0 -1
- package/dist/packages/datepicker/styles/w-datepicker-day.styles.d.ts +0 -1
- package/dist/packages/datepicker/styles/w-datepicker-month.styles.d.ts +0 -1
- package/dist/packages/datepicker/styles/w-datepicker.styles.d.ts +0 -1
- package/dist/packages/datepicker/utils.d.ts +0 -13
- package/dist/packages/dead-toggle/dead-toggle.stories.d.ts +0 -10
- package/dist/packages/dead-toggle/dead-toggle.test.d.ts +0 -1
- package/dist/packages/dead-toggle/index.d.ts +0 -21
- package/dist/packages/dead-toggle/index.js.map +0 -7
- package/dist/packages/dead-toggle/react.d.ts +0 -2
- package/dist/packages/dead-toggle/react.js.map +0 -7
- package/dist/packages/expandable/react.js.map +0 -7
- package/dist/packages/link/index.js.map +0 -7
- package/dist/packages/link/link.stories.d.ts +0 -20
- package/dist/packages/link/link.test.d.ts +0 -1
- package/dist/packages/link/react.d.ts +0 -2
- package/dist/packages/link/react.js +0 -2666
- package/dist/packages/link/react.js.map +0 -7
- package/dist/packages/modal/react.js.map +0 -7
- package/dist/packages/pageindicator/index.d.ts +0 -14
- package/dist/packages/pageindicator/index.js +0 -32
- package/dist/packages/pageindicator/index.js.map +0 -7
- package/dist/packages/pageindicator/pageindicator.stories.d.ts +0 -32
- package/dist/packages/pageindicator/react.d.ts +0 -2
- package/dist/packages/pageindicator/react.js +0 -52
- package/dist/packages/pageindicator/react.js.map +0 -7
- package/dist/packages/pageindicator/style.d.ts +0 -1
- package/dist/packages/pagination/index.d.ts +0 -37
- package/dist/packages/pagination/index.js.map +0 -7
- package/dist/packages/pagination/locales/da/messages.d.mts +0 -1
- package/dist/packages/pagination/locales/en/messages.d.mts +0 -1
- package/dist/packages/pagination/locales/fi/messages.d.mts +0 -1
- package/dist/packages/pagination/locales/nb/messages.d.mts +0 -1
- package/dist/packages/pagination/locales/sv/messages.d.mts +0 -1
- package/dist/packages/pagination/pagination.stories.d.ts +0 -14
- package/dist/packages/pagination/pagination.test.d.ts +0 -1
- package/dist/packages/pagination/react.d.ts +0 -2
- package/dist/packages/pagination/react.js +0 -2514
- package/dist/packages/pagination/react.js.map +0 -7
- package/dist/packages/pagination/styles.d.ts +0 -1
- package/dist/packages/rip-and-tear-checkbox/checkbox.d.ts +0 -64
- package/dist/packages/rip-and-tear-checkbox/index.css +0 -2
- package/dist/packages/rip-and-tear-checkbox/index.css.map +0 -7
- package/dist/packages/rip-and-tear-checkbox/index.d.ts +0 -6
- package/dist/packages/rip-and-tear-checkbox/index.js +0 -36
- package/dist/packages/rip-and-tear-checkbox/index.js.map +0 -7
- package/dist/packages/rip-and-tear-radio/base-element.d.ts +0 -46
- package/dist/packages/rip-and-tear-radio/custom-error-validator.d.ts +0 -6
- package/dist/packages/rip-and-tear-radio/form-associated-element.d.ts +0 -103
- package/dist/packages/rip-and-tear-radio/index.css +0 -2
- package/dist/packages/rip-and-tear-radio/index.css.map +0 -7
- package/dist/packages/rip-and-tear-radio/index.d.ts +0 -8
- package/dist/packages/rip-and-tear-radio/index.js +0 -34
- package/dist/packages/rip-and-tear-radio/index.js.map +0 -7
- package/dist/packages/rip-and-tear-radio/invalid.d.ts +0 -8
- package/dist/packages/rip-and-tear-radio/math.d.ts +0 -1
- package/dist/packages/rip-and-tear-radio/radio-group.d.ts +0 -72
- package/dist/packages/rip-and-tear-radio/radio.d.ts +0 -38
- package/dist/packages/rip-and-tear-radio/required-validator.d.ts +0 -11
- package/dist/packages/rip-and-tear-radio/slot.d.ts +0 -20
- package/dist/packages/rip-and-tear-radio/watch.d.ts +0 -26
- package/dist/packages/select/react.js.map +0 -7
- package/dist/packages/steps/index.d.ts +0 -43
- package/dist/packages/steps/index.js.map +0 -7
- package/dist/packages/steps/locales/da/messages.d.mts +0 -1
- package/dist/packages/steps/locales/en/messages.d.mts +0 -1
- package/dist/packages/steps/locales/fi/messages.d.mts +0 -1
- package/dist/packages/steps/locales/nb/messages.d.mts +0 -1
- package/dist/packages/steps/locales/sv/messages.d.mts +0 -1
- package/dist/packages/steps/react.d.ts +0 -3
- package/dist/packages/steps/react.js +0 -2485
- package/dist/packages/steps/react.js.map +0 -7
- package/dist/packages/steps/steps.stories.d.ts +0 -12
- package/dist/packages/steps/styles.d.ts +0 -1
- package/dist/packages/switch/index.d.ts +0 -20
- package/dist/packages/switch/index.js.map +0 -7
- package/dist/packages/switch/react.d.ts +0 -2
- package/dist/packages/switch/react.js.map +0 -7
- package/dist/packages/switch/styles.d.ts +0 -1
- package/dist/packages/switch/switch.stories.d.ts +0 -9
- package/dist/packages/textfield/react.js.map +0 -7
- package/dist/vscode.css-custom-data.json +0 -6
- package/dist/vscode.html-custom-data.json +0 -421
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StoryObj } from '@storybook/react';
|
|
3
|
+
import { Select } from './react';
|
|
4
|
+
declare const _default: {
|
|
5
|
+
title: string;
|
|
6
|
+
render(args: Omit<React.HTMLAttributes<import(".").WarpSelect>, "label" | "onchange" | "autoFocus" | "onChange" | "render" | "renderOptions" | "connectedCallback" | "disconnectedCallback" | "renderRoot" | "isUpdatePending" | "hasUpdated" | "addController" | "removeController" | "attributeChangedCallback" | "requestUpdate" | "updateComplete" | "form" | "disabled" | "name" | "value" | "validationTarget" | "internals" | "showError" | "validationMessage" | "validity" | "validationComplete" | "checkValidity" | "formResetCallback" | "resetFormControl" | "valueChangedCallback" | "validityCallback" | "validationMessageCallback" | "setValue" | "shouldFormValueUpdate" | "invalid" | "always" | "hint" | "optional" | "readOnly" | "_options" | "_setValue" | "handleKeyDown"> & {
|
|
7
|
+
onChange?: (e: Event) => void;
|
|
8
|
+
onchange?: (e: Event) => void;
|
|
9
|
+
} & Partial<Omit<import(".").WarpSelect, keyof HTMLElement>> & React.RefAttributes<import(".").WarpSelect>): React.JSX.Element;
|
|
10
|
+
component: import("@lit/react").ReactWebComponent<import(".").WarpSelect, {
|
|
11
|
+
onChange: string;
|
|
12
|
+
onchange: string;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
16
|
+
export type Story = StoryObj<typeof Select>;
|
|
17
|
+
export declare const Default: Story;
|
|
18
|
+
export declare const ChangeEvent: (args: any) => React.JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Select, Option } from './react';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Forms/Select',
|
|
5
|
+
render(args) {
|
|
6
|
+
return (React.createElement(Select, { ...args },
|
|
7
|
+
React.createElement(Option, { value: "strawberries" }, "Strawberries"),
|
|
8
|
+
React.createElement(Option, { value: "raspberries", selected: true }, "Raspberries"),
|
|
9
|
+
React.createElement(Option, { value: "cloudberries" }, "Cloudberries")));
|
|
10
|
+
},
|
|
11
|
+
component: Select,
|
|
12
|
+
};
|
|
13
|
+
export const Default = {
|
|
14
|
+
args: {
|
|
15
|
+
label: 'Berries',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export const ChangeEvent = (args) => {
|
|
19
|
+
const [selectedValue, setSelectedValue] = useState('');
|
|
20
|
+
return (React.createElement(React.Fragment, null,
|
|
21
|
+
React.createElement("div", null,
|
|
22
|
+
"Selected Value: ",
|
|
23
|
+
selectedValue),
|
|
24
|
+
React.createElement(Select, { ...args, onChange: (e) => setSelectedValue(e.detail) },
|
|
25
|
+
React.createElement(Option, { value: "strawberries" }, "Strawberries"),
|
|
26
|
+
React.createElement(Option, { value: "raspberries", selected: true }, "Raspberries"),
|
|
27
|
+
React.createElement(Option, { value: "cloudberries" }, "Cloudberries"))));
|
|
28
|
+
};
|
|
@@ -8,3 +8,10 @@ declare const meta: Meta<typeof args>;
|
|
|
8
8
|
export default meta;
|
|
9
9
|
type Story = StoryObj<typeof args>;
|
|
10
10
|
export declare const Default: Story;
|
|
11
|
+
export declare const Hint: Story;
|
|
12
|
+
export declare const Invalid: Story;
|
|
13
|
+
export declare const Disabled: Story;
|
|
14
|
+
export declare const ReadOnly: Story;
|
|
15
|
+
export declare const NoLabel: Story;
|
|
16
|
+
export declare const Optional: Story;
|
|
17
|
+
export declare const Placeholder: Story;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { spread } from '@open-wc/lit-helpers';
|
|
2
|
+
import { getStorybookHelpers } from '@wc-toolkit/storybook-helpers';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import { prespread } from '../../.storybook/utilities.js';
|
|
5
|
+
import './index.js';
|
|
6
|
+
const { events, args, argTypes } = getStorybookHelpers('w-select');
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Forms/Select',
|
|
9
|
+
render(args) {
|
|
10
|
+
return html `
|
|
11
|
+
<w-select ${spread(prespread(args))}>
|
|
12
|
+
<option value="raspberries">Raspberries</option>
|
|
13
|
+
<option value="strawberries" selected>Strawberries</option>
|
|
14
|
+
<option value="cloudberries">Cloudberries</option>
|
|
15
|
+
</w-select>
|
|
16
|
+
`;
|
|
17
|
+
},
|
|
18
|
+
args,
|
|
19
|
+
argTypes,
|
|
20
|
+
parameters: {
|
|
21
|
+
actions: {
|
|
22
|
+
handles: events,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export default meta;
|
|
27
|
+
export const Default = {
|
|
28
|
+
args: {
|
|
29
|
+
label: 'Berries',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
export const Hint = {
|
|
33
|
+
args: {
|
|
34
|
+
label: 'Berries',
|
|
35
|
+
always: true,
|
|
36
|
+
hint: 'We assume this is your jam preference'
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export const Invalid = {
|
|
40
|
+
args: {
|
|
41
|
+
label: 'Berries',
|
|
42
|
+
invalid: true,
|
|
43
|
+
hint: 'Wrong choice'
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
export const Disabled = {
|
|
47
|
+
args: {
|
|
48
|
+
label: 'Berries',
|
|
49
|
+
disabled: true,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
export const ReadOnly = {
|
|
53
|
+
args: {
|
|
54
|
+
label: 'Berries',
|
|
55
|
+
'read-only': true,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
export const NoLabel = {
|
|
59
|
+
render(args) {
|
|
60
|
+
return html `
|
|
61
|
+
<div style="display: flex; flex-direction: column; gap: 32px;">
|
|
62
|
+
<w-select ${spread(prespread(args))} aria-label="Your selection is berry nice!">
|
|
63
|
+
<option value="raspberries">Raspberries</option>
|
|
64
|
+
<option value="strawberries" selected>Strawberries</option>
|
|
65
|
+
<option value="cloudberries">Cloudberries</option>
|
|
66
|
+
</w-select>
|
|
67
|
+
|
|
68
|
+
<label id="select-label" htmlFor="warp-aria-labelledby-example">
|
|
69
|
+
You're berry good at selecting!
|
|
70
|
+
</label>
|
|
71
|
+
<w-select ${spread(prespread(args))} id="warp-aria-labelledby-example">
|
|
72
|
+
<option value="raspberries">Raspberries</option>
|
|
73
|
+
<option value="strawberries" selected>Strawberries</option>
|
|
74
|
+
<option value="cloudberries">Cloudberries</option>
|
|
75
|
+
</w-select>
|
|
76
|
+
</div>
|
|
77
|
+
`;
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
export const Optional = {
|
|
81
|
+
args: {
|
|
82
|
+
label: 'Berries',
|
|
83
|
+
optional: true,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
export const Placeholder = {
|
|
87
|
+
args: {
|
|
88
|
+
label: 'Berries',
|
|
89
|
+
},
|
|
90
|
+
render(args) {
|
|
91
|
+
return html `
|
|
92
|
+
<w-select ${spread(prespread(args))}>
|
|
93
|
+
<option value="">Select an option</option>
|
|
94
|
+
<option value="raspberries">Raspberries</option>
|
|
95
|
+
<option value="strawberries">Strawberries</option>
|
|
96
|
+
<option value="cloudberries">Cloudberries</option>
|
|
97
|
+
</w-select>
|
|
98
|
+
`;
|
|
99
|
+
},
|
|
100
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { userEvent } from '@vitest/browser/context';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { expect, test } from 'vitest';
|
|
4
|
+
import { render } from 'vitest-browser-lit';
|
|
5
|
+
import './index.js';
|
|
6
|
+
test('works in a form', async () => {
|
|
7
|
+
const component = html `
|
|
8
|
+
<form data-testid="flavour">
|
|
9
|
+
<w-select label="Berries" name="berry">
|
|
10
|
+
<option value="strawberries">Strawberries</option>
|
|
11
|
+
<option value="raspberries">Raspberries</option>
|
|
12
|
+
<option value="cloudberries">Cloudberries</option>
|
|
13
|
+
</w-select>
|
|
14
|
+
|
|
15
|
+
<button>Submit</button>
|
|
16
|
+
</form>
|
|
17
|
+
`;
|
|
18
|
+
const page = render(component);
|
|
19
|
+
// Confirm we have a form associated field berry
|
|
20
|
+
const form = page.getByTestId('flavour');
|
|
21
|
+
expect(form).toHaveFormValues({
|
|
22
|
+
berry: undefined,
|
|
23
|
+
});
|
|
24
|
+
// Select Raspberries
|
|
25
|
+
await expect.element(page.getByLabelText('Berries')).toBeVisible();
|
|
26
|
+
await userEvent.selectOptions(page.getByLabelText('Berries').element(), 'Raspberries');
|
|
27
|
+
// Confirm the form has a field berry with value raspberries
|
|
28
|
+
expect(form).toHaveFormValues({
|
|
29
|
+
berry: 'raspberries',
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `*,:before,:after{--w-rotate:0;--w-rotate-x:0;--w-rotate-y:0;--w-rotate-z:0;--w-scale-x:1;--w-scale-y:1;--w-scale-z:1;--w-skew-x:0;--w-skew-y:0;--w-translate-x:0;--w-translate-y:0;--w-translate-z:0}.focus\\:\\[--w-outline-offset\\:-2px\\]:focus{--w-outline-offset:-2px}.bg-transparent{background-color:#0000}.appearance-none{-webkit-appearance:none;appearance:none}.border-0{border-width:0}.border-1{border-width:1px}.rounded-4{border-radius:4px}.caret-current{caret-color:currentColor}.opacity-25{opacity:.25}.block,.before\\:block:before{display:block}.before\\:hidden:before{display:none}.focusable:focus{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:focus-visible{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:not(:focus-visible){outline:none}.outline-\\[--w-s-color-border-negative\\]\\!{outline-color:var(--w-s-color-border-negative)!important}.bottom-0{bottom:0}.right-0{right:0}.before\\:bottom-0:before{bottom:0}.before\\:right-0:before{right:0}.top-\\[30\\%\\]{top:30%}.absolute{position:absolute}.relative{position:relative}.static{position:static}.before\\:absolute:before{position:absolute}.s-bg{background-color:var(--w-s-color-background)}.s-bg-disabled-subtle{background-color:var(--w-s-color-background-disabled-subtle)}.s-text{color:var(--w-s-color-text)}.s-text-disabled{color:var(--w-s-color-text-disabled)}.s-text-negative{color:var(--w-s-color-text-negative)}.s-text-subtle{color:var(--w-s-color-text-subtle)}.s-icon{color:var(--w-s-color-icon)}.s-border-disabled{border-color:var(--w-s-color-border-disabled)}.s-border-negative{border-color:var(--w-s-color-border-negative)}.s-border-strong{border-color:var(--w-s-color-border-strong)}.hover\\:s-border-disabled:hover{border-color:var(--w-s-color-border-disabled)}.hover\\:s-border-negative-hover:hover{border-color:var(--w-s-color-border-negative-hover)}.hover\\:s-border-strong-hover:hover{border-color:var(--w-s-color-border-strong-hover)}.active\\:s-border-active:active{border-color:var(--w-s-color-border-active)}.active\\:s-border-disabled:active{border-color:var(--w-s-color-border-disabled)}.h-full{height:100%}.w-32{width:3.2rem}.w-full{width:100%}.before\\:h-full:before{height:100%}.before\\:w-32:before{width:3.2rem}.mb-0{margin-bottom:0}.mt-4{margin-top:.4rem}.py-12{padding-top:1.2rem;padding-bottom:1.2rem}.pb-4{padding-bottom:.4rem}.pl-0{padding-left:0}.pl-8{padding-left:.8rem}.pr-32{padding-right:3.2rem}.cursor-pointer{cursor:pointer}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-smoothing:grayscale}.font-bold{font-weight:700}.font-normal{font-weight:400}.pointer-events-none,.before\\:pointer-events-none:before{pointer-events:none}.text-m{font-size:var(--w-font-size-m);line-height:var(--w-line-height-m)}.text-s{font-size:var(--w-font-size-s);line-height:var(--w-line-height-s)}.text-xs{font-size:var(--w-font-size-xs);line-height:var(--w-line-height-xs)}`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const reset = css `
|
|
2
3
|
*,
|
|
3
4
|
:before,
|
|
4
5
|
:after {
|
|
@@ -271,7 +272,8 @@ var h=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var c=(a,t,n,r
|
|
|
271
272
|
svg {
|
|
272
273
|
pointer-events: none;
|
|
273
274
|
}
|
|
274
|
-
|
|
275
|
+
`;
|
|
276
|
+
export const components = css `*, :before, :after {
|
|
275
277
|
--w-rotate: 0;
|
|
276
278
|
--w-rotate-x: 0;
|
|
277
279
|
--w-rotate-y: 0;
|
|
@@ -2437,19 +2439,4 @@ var h=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var c=(a,t,n,r
|
|
|
2437
2439
|
display: none
|
|
2438
2440
|
}
|
|
2439
2441
|
}
|
|
2440
|
-
`;
|
|
2441
|
-
<div>
|
|
2442
|
-
<button
|
|
2443
|
-
type="button"
|
|
2444
|
-
role="switch"
|
|
2445
|
-
aria-checked=${this.value}
|
|
2446
|
-
class=${this._baseClasses}
|
|
2447
|
-
aria-disabled=${this.disabled}
|
|
2448
|
-
?disabled=${this.disabled}
|
|
2449
|
-
@click=${this._handleClick}>
|
|
2450
|
-
<span data-testid="track" class=${this._trackClasses}></span>
|
|
2451
|
-
<span data-testid="handle" class=${this._handleClasses}></span>
|
|
2452
|
-
</button>
|
|
2453
|
-
</div>
|
|
2454
|
-
`}};i.styles=[p,g],c([v({type:Boolean,reflect:!0})],i.prototype,"value",2),c([v({type:Boolean,reflect:!0})],i.prototype,"disabled",2);customElements.get("w-switch")||customElements.define("w-switch",i);export{i as WarpSwitch};
|
|
2455
|
-
//# sourceMappingURL=index.js.map
|
|
2442
|
+
`;
|
|
@@ -1,25 +1,4 @@
|
|
|
1
1
|
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
-
export declare const ccinput: {
|
|
3
|
-
wrapper: string;
|
|
4
|
-
base: string;
|
|
5
|
-
default: string;
|
|
6
|
-
disabled: string;
|
|
7
|
-
invalid: string;
|
|
8
|
-
readOnly: string;
|
|
9
|
-
placeholder: string;
|
|
10
|
-
suffix: string;
|
|
11
|
-
prefix: string;
|
|
12
|
-
textArea: string;
|
|
13
|
-
};
|
|
14
|
-
export declare const ccLabel: {
|
|
15
|
-
base: string;
|
|
16
|
-
optional: string;
|
|
17
|
-
};
|
|
18
|
-
export declare const ccHelpText: {
|
|
19
|
-
base: string;
|
|
20
|
-
color: string;
|
|
21
|
-
colorInvalid: string;
|
|
22
|
-
};
|
|
23
2
|
declare const WarpTextField_base: import("@open-wc/form-control").Constructor<import("@open-wc/form-control").FormControlInterface> & typeof LitElement;
|
|
24
3
|
/**
|
|
25
4
|
* A single line text input element.
|
|
@@ -50,6 +29,18 @@ declare class WarpTextField extends WarpTextField_base {
|
|
|
50
29
|
type: string;
|
|
51
30
|
value: string;
|
|
52
31
|
name: string;
|
|
32
|
+
/**
|
|
33
|
+
* Function to format value when the input field.
|
|
34
|
+
*
|
|
35
|
+
* Only active when the input field does not have focus,
|
|
36
|
+
* similar to the accessible input masking example from Filament Group
|
|
37
|
+
*
|
|
38
|
+
* https://css-tricks.com/input-masking/
|
|
39
|
+
* https://filamentgroup.github.io/politespace/demo/demo.html
|
|
40
|
+
*/
|
|
41
|
+
formatter: (value: string) => string;
|
|
42
|
+
/** @internal */
|
|
43
|
+
mask: HTMLDivElement;
|
|
53
44
|
/** @internal */
|
|
54
45
|
_hasPrefix: boolean;
|
|
55
46
|
/** @internal */
|
|
@@ -74,8 +65,3 @@ declare class WarpTextField extends WarpTextField_base {
|
|
|
74
65
|
render(): import("lit").TemplateResult<1>;
|
|
75
66
|
}
|
|
76
67
|
export { WarpTextField };
|
|
77
|
-
declare global {
|
|
78
|
-
interface HTMLElementTagNameMap {
|
|
79
|
-
'w-textfield': WarpTextField;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var K=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var l=(h,o,i,r)=>{for(var n=r>1?void 0:r?Q(o,i):o,g=h.length-1,w;g>=0;g--)(w=h[g])&&(n=(r?w(o,i,n):w(n))||n);return r&&n&&K(o,i,n),n};var Y=function(){for(var h=[],o=arguments.length;o--;)h[o]=arguments[o];return h.reduce(function(i,r){return i.concat(typeof r=="string"?r:Array.isArray(r)?Y.apply(void 0,r):typeof r=="object"&&r?Object.keys(r).map(function(n){return r[n]?n:""}):"")},[]).join(" ")};var a=function(h,o,i,r){if(i==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?h!==o||!r:!o.has(h))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?r:i==="a"?r.call(h):r?r.value:o.get(h)},b=function(h,o,i,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof o=="function"?h!==o||!n:!o.has(h))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(h,i):n?n.value=i:o.set(h,i),i};function R(h){var o,i,r,n,g,w,k,T,_,P,F,A,V,z,E,f,L,X,O;class J extends h{constructor(...e){var t,c,p;super(...e),o.add(this),this.internals=this.attachInternals(),i.set(this,!1),r.set(this,!1),n.set(this,!1),g.set(this,void 0),w.set(this,void 0),k.set(this,!0),_.set(this,""),P.set(this,()=>{b(this,n,!0,"f"),b(this,i,!0,"f"),a(this,o,"m",f).call(this)}),F.set(this,()=>{b(this,i,!1,"f"),a(this,o,"m",L).call(this,this.shouldFormValueUpdate()?a(this,_,"f"):""),!this.validity.valid&&a(this,n,"f")&&b(this,r,!0,"f");let m=a(this,o,"m",f).call(this);this.validationMessageCallback&&this.validationMessageCallback(m?this.internals.validationMessage:"")}),A.set(this,()=>{var m;a(this,k,"f")&&this.validationTarget&&(this.internals.setValidity(this.validity,this.validationMessage,this.validationTarget),b(this,k,!1,"f")),b(this,n,!0,"f"),b(this,r,!0,"f"),a(this,o,"m",f).call(this),(m=this===null||this===void 0?void 0:this.validationMessageCallback)===null||m===void 0||m.call(this,this.showError?this.internals.validationMessage:"")}),V.set(this,void 0),z.set(this,!1),E.set(this,Promise.resolve()),(t=this.addEventListener)===null||t===void 0||t.call(this,"focus",a(this,P,"f")),(c=this.addEventListener)===null||c===void 0||c.call(this,"blur",a(this,F,"f")),(p=this.addEventListener)===null||p===void 0||p.call(this,"invalid",a(this,A,"f")),this.setValue(null)}static get formAssociated(){return!0}static get validators(){return this.formControlValidators||[]}static get observedAttributes(){let e=this.validators.map(p=>p.attribute).flat(),t=super.observedAttributes||[];return[...new Set([...t,...e])]}static getValidator(e){return this.validators.find(t=>t.attribute===e)||null}static getValidators(e){return this.validators.filter(t=>{var c;if(t.attribute===e||!((c=t.attribute)===null||c===void 0)&&c.includes(e))return!0})}get form(){return this.internals.form}get showError(){return a(this,o,"m",f).call(this)}checkValidity(){return this.internals.checkValidity()}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}attributeChangedCallback(e,t,c){var p;(p=super.attributeChangedCallback)===null||p===void 0||p.call(this,e,t,c);let $=this.constructor.getValidators(e);$!=null&&$.length&&this.validationTarget&&this.setValue(a(this,_,"f"))}setValue(e){var t;b(this,r,!1,"f"),(t=this.validationMessageCallback)===null||t===void 0||t.call(this,""),b(this,_,e,"f");let p=this.shouldFormValueUpdate()?e:null;this.internals.setFormValue(p),a(this,o,"m",L).call(this,p),this.valueChangedCallback&&this.valueChangedCallback(p),a(this,o,"m",f).call(this)}shouldFormValueUpdate(){return!0}get validationComplete(){return new Promise(e=>e(a(this,E,"f")))}formResetCallback(){var e,t;b(this,n,!1,"f"),b(this,r,!1,"f"),a(this,o,"m",f).call(this),(e=this.resetFormControl)===null||e===void 0||e.call(this),(t=this.validationMessageCallback)===null||t===void 0||t.call(this,a(this,o,"m",f).call(this)?this.validationMessage:"")}}return i=new WeakMap,r=new WeakMap,n=new WeakMap,g=new WeakMap,w=new WeakMap,k=new WeakMap,_=new WeakMap,P=new WeakMap,F=new WeakMap,A=new WeakMap,V=new WeakMap,z=new WeakMap,E=new WeakMap,o=new WeakSet,T=function(){let e=this.getRootNode(),t=`${this.localName}[name="${this.getAttribute("name")}"]`;return e.querySelectorAll(t)},f=function(){if(this.hasAttribute("disabled"))return!1;let e=a(this,r,"f")||a(this,n,"f")&&!this.validity.valid&&!a(this,i,"f");return e&&this.internals.states?this.internals.states.add("--show-error"):this.internals.states&&this.internals.states.delete("--show-error"),e},L=function(e){let t=this.constructor,c={},p=t.validators,m=[],$=p.some(v=>v.isValid instanceof Promise);a(this,z,"f")||(b(this,E,new Promise(v=>{b(this,V,v,"f")}),"f"),b(this,z,!0,"f")),a(this,g,"f")&&(a(this,g,"f").abort(),b(this,w,a(this,g,"f"),"f"));let M=new AbortController;b(this,g,M,"f");let S,q=!1;p.length&&(p.forEach(v=>{let Z=v.key||"customError",y=v.isValid(this,e,M.signal);y instanceof Promise?(m.push(y),y.then(I=>{I!=null&&(c[Z]=!I,S=a(this,o,"m",O).call(this,v,e),a(this,o,"m",X).call(this,c,S))})):(c[Z]=!y,this.validity[Z]!==!y&&(q=!0),!y&&!S&&(S=a(this,o,"m",O).call(this,v,e)))}),Promise.allSettled(m).then(()=>{var v;M!=null&&M.signal.aborted||(b(this,z,!1,"f"),(v=a(this,V,"f"))===null||v===void 0||v.call(this))}),(q||!$)&&a(this,o,"m",X).call(this,c,S))},X=function(e,t){if(this.validationTarget)this.internals.setValidity(e,t,this.validationTarget),b(this,k,!1,"f");else{if(this.internals.setValidity(e,t),this.internals.validity.valid)return;b(this,k,!0,"f")}},O=function(e,t){if(this.validityCallback){let c=this.validityCallback(e.key||"customError");if(c)return c}return e.message instanceof Function?e.message(this,t):e.message},J}import{html as j,LitElement as G,nothing as re}from"lit";import{property as d,query as oe}from"lit/decorators.js";import{classMap as te}from"lit/directives/class-map.js";import{ifDefined as u}from"lit/directives/if-defined.js";import{css as B}from"lit";var H=B`
|
|
2
2
|
*,
|
|
3
3
|
:before,
|
|
4
4
|
:after {
|
|
@@ -271,7 +271,7 @@ var D=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var l=(h,o,i,r
|
|
|
271
271
|
svg {
|
|
272
272
|
pointer-events: none;
|
|
273
273
|
}
|
|
274
|
-
`,
|
|
274
|
+
`,ce=B`*, :before, :after {
|
|
275
275
|
--w-rotate: 0;
|
|
276
276
|
--w-rotate-x: 0;
|
|
277
277
|
--w-rotate-y: 0;
|
|
@@ -2437,34 +2437,92 @@ var D=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var l=(h,o,i,r
|
|
|
2437
2437
|
display: none
|
|
2438
2438
|
}
|
|
2439
2439
|
}
|
|
2440
|
-
`;import{css as
|
|
2440
|
+
`;import{css as W}from"lit";var U=W`
|
|
2441
|
+
.w-textfield {
|
|
2442
|
+
--_input-padding-top: 12px;
|
|
2443
|
+
--_input-padding-left: 8px;
|
|
2444
|
+
--_input-padding-right: 8px;
|
|
2445
|
+
position: relative;
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
.w-textfield--has-prefix {
|
|
2449
|
+
--_input-padding-left: 40px;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
.w-textfield--has-suffix {
|
|
2453
|
+
--_input-padding-right: var(--w-prefix-width, 40px);
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
.w-textfield__input-wrapper {
|
|
2457
|
+
position: relative;
|
|
2458
|
+
overflow: hidden;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
.w-textfield__input-wrapper:focus-within .w-textfield__mask {
|
|
2462
|
+
display: none;
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
/* Hide the native browser controls */
|
|
2466
|
+
input[type="number"] {
|
|
2467
|
+
-moz-appearance:textfield;
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
input[type="number"]::-webkit-inner-spin-button {
|
|
2471
|
+
display: none;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
/* Could also consider giving the input mask a background color instead of this */
|
|
2475
|
+
.w-textfield__input-wrapper:has(.w-textfield__mask):not(:focus-within) input {
|
|
2476
|
+
color: transparent;
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
.w-textfield__mask {
|
|
2480
|
+
display: block;
|
|
2481
|
+
border: 1px solid transparent;
|
|
2482
|
+
top: var(--_input-padding-top);
|
|
2483
|
+
left: var(--_input-padding-left);
|
|
2484
|
+
right: var(--_input-padding-right);
|
|
2485
|
+
position: absolute;
|
|
2486
|
+
pointer-events: none;
|
|
2487
|
+
white-space: nowrap;
|
|
2488
|
+
overflow: hidden;
|
|
2489
|
+
text-overflow: ellipsis;
|
|
2490
|
+
z-index: 1;
|
|
2491
|
+
}
|
|
2492
|
+
`;import{css as ee}from"lit";var D=ee`*,:before,:after{--w-rotate:0;--w-rotate-x:0;--w-rotate-y:0;--w-rotate-z:0;--w-scale-x:1;--w-scale-y:1;--w-scale-z:1;--w-skew-x:0;--w-skew-y:0;--w-translate-x:0;--w-translate-y:0;--w-translate-z:0}.focus\\:\\[--w-outline-offset\\:-2px\\]:focus{--w-outline-offset:-2px}.bg-transparent{background-color:#0000}.border-1{border-width:1px}.rounded-4{border-radius:4px}.caret-current{caret-color:currentColor}.block{display:block}.focusable:focus{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:focus-visible{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:not(:focus-visible){outline:none}.outline-\\[--w-s-color-border-negative\\]\\!{outline-color:var(--w-s-color-border-negative)!important}.relative{position:relative}.static{position:static}.s-bg{background-color:var(--w-s-color-background)}.s-bg-disabled-subtle{background-color:var(--w-s-color-background-disabled-subtle)}.s-text{color:var(--w-s-color-text)}.s-text-disabled{color:var(--w-s-color-text-disabled)}.s-text-negative{color:var(--w-s-color-text-negative)}.s-text-subtle{color:var(--w-s-color-text-subtle)}.placeholder\\:s-text-placeholder::placeholder{color:var(--w-s-color-text-placeholder)}.s-border-disabled{border-color:var(--w-s-color-border-disabled)}.s-border-negative{border-color:var(--w-s-color-border-negative)}.s-border-strong{border-color:var(--w-s-color-border-strong)}.hover\\:s-border-negative-hover:hover{border-color:var(--w-s-color-border-negative-hover)}.hover\\:s-border-strong-hover:hover{border-color:var(--w-s-color-border-strong-hover)}.active\\:s-border-selected:active{border-color:var(--w-s-color-border-selected)}.w-full{width:100%}.min-h-\\[42\\]{min-height:4.2rem}.mb-0{margin-bottom:0}.mt-4{margin-top:.4rem}.px-8{padding-left:.8rem;padding-right:.8rem}.py-12{padding-top:1.2rem;padding-bottom:1.2rem}.pb-4{padding-bottom:.4rem}.pl-0{padding-left:0}.pl-8{padding-left:.8rem}.pr-40{padding-right:4rem}.pl-\\[var\\(--w-prefix-width\\,_40px\\)\\]{padding-left:var(--w-prefix-width,40px)}.cursor-pointer{cursor:pointer}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-smoothing:grayscale}.font-bold{font-weight:700}.font-normal{font-weight:400}.pointer-events-none{pointer-events:none}.sr-only{clip:rect(0,0,0,0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.text-m{font-size:var(--w-font-size-m);line-height:var(--w-line-height-m)}.text-s{font-size:var(--w-font-size-s);line-height:var(--w-line-height-s)}.text-xs{font-size:var(--w-font-size-xs);line-height:var(--w-line-height-xs)}.leading-m{line-height:var(--w-line-height-m)}@media (min-width:480px){.sm\\:min-h-\\[45\\]{min-height:4.5rem}}`;var x={base:"block text-m leading-m mb-0 px-8 py-12 rounded-4 w-full focusable focus:[--w-outline-offset:-2px] caret-current",default:"border-1 s-text s-bg s-border-strong hover:s-border-strong-hover active:s-border-selected",disabled:"border-1 s-text-disabled s-bg-disabled-subtle s-border-disabled pointer-events-none",invalid:"border-1 s-text-negative s-bg s-border-negative hover:s-border-negative-hover outline-[--w-s-color-border-negative]!",readOnly:"pl-0 bg-transparent pointer-events-none",placeholder:"placeholder:s-text-placeholder",suffix:"pr-40",prefix:"pl-[var(--w-prefix-width,_40px)]",textArea:"min-h-[42] sm:min-h-[45]"},ae={base:"antialiased block relative text-s font-bold pb-4 cursor-pointer s-text",optional:"pl-8 font-normal text-s s-text-subtle"},N={base:"text-xs mt-4 block",color:"s-text-subtle",colorInvalid:"s-text-negative"},s=class extends R(G){constructor(){super(...arguments);this.type="text";this._hasPrefix=!1;this._hasSuffix=!1}updated(i){i.has("value")&&this.setValue(this.value),this.formatter&&this.value&&(this.mask.innerText=this.formatter(this.value))}get _inputstyles(){return Y([x.base,this._hasSuffix&&x.suffix,this._hasPrefix&&x.prefix,!this.invalid&&!this.disabled&&!this.readOnly&&x.default,this.invalid&&!this.disabled&&!this.readOnly&&x.invalid,!this.invalid&&this.disabled&&!this.readOnly&&x.disabled,!this.invalid&&!this.disabled&&this.readOnly&&x.readOnly])}get _helptextstyles(){return Y([N.base,this.invalid?N.colorInvalid:N.color])}get _label(){if(this.label)return j`<label for="${this._id}" class=${ae.base}>${this.label}</label>`}get _helpId(){if(this.helpText)return`${this._id}__hint`}get _id(){return"textfield"}get _error(){if(this.invalid&&this._helpId)return this._helpId}handler(i){let{name:r,value:n}=i.currentTarget;this.value=n;let g=new CustomEvent(i.type,{detail:{name:r,value:n,target:i.target}});this.dispatchEvent(g)}prefixSlotChange(){this.renderRoot.querySelector("slot[name=prefix]").assignedElements().length&&(this._hasPrefix=!0)}suffixSlotChange(){this.renderRoot.querySelector("slot[name=suffix]").assignedElements().length&&(this._hasSuffix=!0)}render(){return j`
|
|
2441
2493
|
${this._label}
|
|
2442
|
-
<div
|
|
2494
|
+
<div
|
|
2495
|
+
class="${te({"w-textfield":!0,"w-textfield--has-prefix":this._hasPrefix,"w-textfield--has-suffix":this._hasSuffix})}">
|
|
2443
2496
|
<slot @slotchange="${this.prefixSlotChange}" name="prefix"></slot>
|
|
2444
|
-
<
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2497
|
+
<div class="w-textfield__input-wrapper">
|
|
2498
|
+
${this.formatter?j`<div class="w-textfield__mask"></div>`:re}
|
|
2499
|
+
<input
|
|
2500
|
+
class="${this._inputstyles}"
|
|
2501
|
+
type="${this.type}"
|
|
2502
|
+
min="${u(this.min)}"
|
|
2503
|
+
max="${u(this.max)}"
|
|
2504
|
+
size="${u(this.size)}"
|
|
2505
|
+
minlength="${u(this.minLength)}"
|
|
2506
|
+
maxlength="${u(this.maxLength)}"
|
|
2507
|
+
name="${u(this.name)}"
|
|
2508
|
+
pattern="${u(this.pattern)}"
|
|
2509
|
+
placeholder="${u(this.placeholder)}"
|
|
2510
|
+
.value="${this.value||""}"
|
|
2511
|
+
aria-describedby="${u(this._helpId||(this.ariaDescription?"aria-description":void 0))}"
|
|
2512
|
+
aria-errormessage="${u(this._error)}"
|
|
2513
|
+
aria-invalid="${u(this.invalid)}"
|
|
2514
|
+
id="${this._id}"
|
|
2515
|
+
?disabled="${this.disabled}"
|
|
2516
|
+
?readonly="${this.readOnly}"
|
|
2517
|
+
?required="${this.required}"
|
|
2518
|
+
@blur="${this.handler}"
|
|
2519
|
+
@change="${this.handler}"
|
|
2520
|
+
@input="${this.handler}"
|
|
2521
|
+
@focus="${this.handler}" />
|
|
2522
|
+
</div>
|
|
2466
2523
|
<slot @slotchange="${this.suffixSlotChange}" name="suffix"></slot>
|
|
2467
2524
|
</div>
|
|
2468
|
-
|
|
2469
|
-
|
|
2525
|
+
<span class="sr-only" id="aria-description">${this.ariaDescription}</span>
|
|
2526
|
+
${this.helpText&&j`<div class="${this._helptextstyles}" id="${this._helpId}">${this.helpText}</div>`}
|
|
2527
|
+
`}};s.shadowRootOptions={...G.shadowRootOptions,delegatesFocus:!0},s.styles=[H,D,U],l([d({type:Boolean,reflect:!0})],s.prototype,"disabled",2),l([d({type:Boolean,reflect:!0})],s.prototype,"invalid",2),l([d({type:String,reflect:!0})],s.prototype,"id",2),l([d({type:String,reflect:!0})],s.prototype,"label",2),l([d({type:String,reflect:!0,attribute:"help-text"})],s.prototype,"helpText",2),l([d({type:String,reflect:!0})],s.prototype,"size",2),l([d({type:Number,reflect:!0})],s.prototype,"max",2),l([d({type:Number,reflect:!0})],s.prototype,"min",2),l([d({type:Number,reflect:!0,attribute:"min-length"})],s.prototype,"minLength",2),l([d({type:Number,reflect:!0,attribute:"max-length"})],s.prototype,"maxLength",2),l([d({type:String,reflect:!0})],s.prototype,"pattern",2),l([d({type:String,reflect:!0})],s.prototype,"placeholder",2),l([d({type:Boolean,reflect:!0,attribute:"read-only"})],s.prototype,"readOnly",2),l([d({type:Boolean,reflect:!0})],s.prototype,"required",2),l([d({type:String,reflect:!0})],s.prototype,"type",2),l([d({type:String,reflect:!0})],s.prototype,"value",2),l([d({type:String,reflect:!0})],s.prototype,"name",2),l([d({attribute:!1})],s.prototype,"formatter",2),l([oe(".w-textfield__mask")],s.prototype,"mask",2),l([d({type:Boolean})],s.prototype,"_hasPrefix",2),l([d({type:Boolean})],s.prototype,"_hasSuffix",2);customElements.get("w-textfield")||customElements.define("w-textfield",s);export{s as WarpTextField};
|
|
2470
2528
|
//# sourceMappingURL=index.js.map
|