@greypan/web-ui 1.4.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.CN.md +674 -232
- package/README.md +683 -237
- package/dist/_virtual/{_@oxc-project_runtime@0.138.0 → _@oxc-project_runtime@0.140.0}/helpers/esm/decorate.js +1 -1
- package/dist/assets/glass.js +6 -0
- package/dist/assets/glass.js.map +1 -0
- package/dist/assets/menu-portal.js +6 -0
- package/dist/assets/menu-portal.js.map +1 -0
- package/dist/assets/overlay-motion.js +6 -0
- package/dist/assets/overlay-motion.js.map +1 -0
- package/dist/assets/toast-containers.js +6 -0
- package/dist/assets/toast-containers.js.map +1 -0
- package/dist/components/avatar/index.d.ts +30 -0
- package/dist/components/avatar/index.js +112 -0
- package/dist/components/avatar/index.js.map +1 -0
- package/dist/components/avatar/style.js +6 -0
- package/dist/components/avatar/style.js.map +1 -0
- package/dist/components/back-top/index.d.ts +8 -7
- package/dist/components/back-top/index.js +37 -32
- package/dist/components/back-top/index.js.map +1 -1
- package/dist/components/back-top/style.js +1 -1
- package/dist/components/back-top/style.js.map +1 -1
- package/dist/components/badge/index.d.ts +27 -0
- package/dist/components/badge/index.js +121 -0
- package/dist/components/badge/index.js.map +1 -0
- package/dist/components/badge/style.js +6 -0
- package/dist/components/badge/style.js.map +1 -0
- package/dist/components/button/index.d.ts +16 -3
- package/dist/components/button/index.js +56 -17
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button/style.js +1 -1
- package/dist/components/button/style.js.map +1 -1
- package/dist/components/button-group/index.d.ts +16 -0
- package/dist/components/button-group/index.js +49 -0
- package/dist/components/button-group/index.js.map +1 -0
- package/dist/components/button-group/style.js +6 -0
- package/dist/components/button-group/style.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +39 -0
- package/dist/components/checkbox/index.js +111 -0
- package/dist/components/checkbox/index.js.map +1 -0
- package/dist/components/checkbox/style.js +6 -0
- package/dist/components/checkbox/style.js.map +1 -0
- package/dist/components/checkbox-group/index.d.ts +35 -0
- package/dist/components/checkbox-group/index.js +99 -0
- package/dist/components/checkbox-group/index.js.map +1 -0
- package/dist/components/checkbox-group/style.js +6 -0
- package/dist/components/checkbox-group/style.js.map +1 -0
- package/dist/components/context-menu/index.d.ts +84 -0
- package/dist/components/context-menu/index.js +294 -0
- package/dist/components/context-menu/index.js.map +1 -0
- package/dist/components/context-menu/style.js +6 -0
- package/dist/components/context-menu/style.js.map +1 -0
- package/dist/components/dialog/index.d.ts +41 -0
- package/dist/components/dialog/index.js +118 -0
- package/dist/components/dialog/index.js.map +1 -0
- package/dist/components/dialog/style.js +6 -0
- package/dist/components/dialog/style.js.map +1 -0
- package/dist/components/drawer/index.d.ts +57 -0
- package/dist/components/drawer/index.js +172 -0
- package/dist/components/drawer/index.js.map +1 -0
- package/dist/components/drawer/style.js +6 -0
- package/dist/components/drawer/style.js.map +1 -0
- package/dist/components/dropdown/index.d.ts +87 -0
- package/dist/components/dropdown/index.js +324 -0
- package/dist/components/dropdown/index.js.map +1 -0
- package/dist/components/dropdown/style.js +6 -0
- package/dist/components/dropdown/style.js.map +1 -0
- package/dist/components/dropdown-divider/index.d.ts +11 -0
- package/dist/components/dropdown-divider/index.js +18 -0
- package/dist/components/dropdown-divider/index.js.map +1 -0
- package/dist/components/dropdown-divider/style.js +6 -0
- package/dist/components/dropdown-divider/style.js.map +1 -0
- package/dist/components/dropdown-header/index.d.ts +11 -0
- package/dist/components/dropdown-header/index.js +18 -0
- package/dist/components/dropdown-header/index.js.map +1 -0
- package/dist/components/dropdown-header/style.js +6 -0
- package/dist/components/dropdown-header/style.js.map +1 -0
- package/dist/components/dropdown-item/index.d.ts +17 -0
- package/dist/components/dropdown-item/index.js +44 -0
- package/dist/components/dropdown-item/index.js.map +1 -0
- package/dist/components/dropdown-item/style.js +6 -0
- package/dist/components/dropdown-item/style.js.map +1 -0
- package/dist/components/empty/index.d.ts +23 -0
- package/dist/components/empty/index.js +83 -0
- package/dist/components/empty/index.js.map +1 -0
- package/dist/components/empty/style.js +6 -0
- package/dist/components/empty/style.js.map +1 -0
- package/dist/components/icon/index.d.ts +16 -0
- package/dist/components/icon/index.js +45 -0
- package/dist/components/icon/index.js.map +1 -0
- package/dist/components/icon/style.js +6 -0
- package/dist/components/icon/style.js.map +1 -0
- package/dist/components/index.d.ts +34 -0
- package/dist/components/index.js +37 -0
- package/dist/components/input/index.d.ts +47 -0
- package/dist/components/input/index.js +140 -0
- package/dist/components/input/index.js.map +1 -0
- package/dist/components/input/style.js +6 -0
- package/dist/components/input/style.js.map +1 -0
- package/dist/components/input-number/index.d.ts +52 -0
- package/dist/components/input-number/index.js +178 -0
- package/dist/components/input-number/index.js.map +1 -0
- package/dist/components/input-number/style.js +6 -0
- package/dist/components/input-number/style.js.map +1 -0
- package/dist/components/layout/index.d.ts +11 -1
- package/dist/components/layout/index.js +55 -21
- package/dist/components/layout/index.js.map +1 -1
- package/dist/components/layout/style.js +1 -1
- package/dist/components/layout/style.js.map +1 -1
- package/dist/components/option/index.d.ts +33 -0
- package/dist/components/option/index.js +78 -0
- package/dist/components/option/index.js.map +1 -0
- package/dist/components/option/style.js +6 -0
- package/dist/components/option/style.js.map +1 -0
- package/dist/components/popover/index.d.ts +69 -0
- package/dist/components/popover/index.js +231 -0
- package/dist/components/popover/index.js.map +1 -0
- package/dist/components/popover/style.js +6 -0
- package/dist/components/popover/style.js.map +1 -0
- package/dist/components/radio/index.d.ts +39 -0
- package/dist/components/radio/index.js +105 -0
- package/dist/components/radio/index.js.map +1 -0
- package/dist/components/radio/style.js +6 -0
- package/dist/components/radio/style.js.map +1 -0
- package/dist/components/radio-group/index.d.ts +35 -0
- package/dist/components/radio-group/index.js +87 -0
- package/dist/components/radio-group/index.js.map +1 -0
- package/dist/components/radio-group/style.js +6 -0
- package/dist/components/radio-group/style.js.map +1 -0
- package/dist/components/segmented/index.d.ts +33 -0
- package/dist/components/segmented/index.js +95 -0
- package/dist/components/segmented/index.js.map +1 -0
- package/dist/components/segmented/style.js +6 -0
- package/dist/components/segmented/style.js.map +1 -0
- package/dist/components/segmented-trigger/index.d.ts +18 -0
- package/dist/components/segmented-trigger/index.js +52 -0
- package/dist/components/segmented-trigger/index.js.map +1 -0
- package/dist/components/segmented-trigger/style.js +6 -0
- package/dist/components/segmented-trigger/style.js.map +1 -0
- package/dist/components/select/index.d.ts +80 -0
- package/dist/components/select/index.js +291 -0
- package/dist/components/select/index.js.map +1 -0
- package/dist/components/select/style.js +6 -0
- package/dist/components/select/style.js.map +1 -0
- package/dist/components/slider/index.d.ts +61 -0
- package/dist/components/slider/index.js +219 -0
- package/dist/components/slider/index.js.map +1 -0
- package/dist/components/slider/style.js +6 -0
- package/dist/components/slider/style.js.map +1 -0
- package/dist/components/spinner/index.d.ts +32 -0
- package/dist/components/spinner/index.js +52 -0
- package/dist/components/spinner/index.js.map +1 -0
- package/dist/components/spinner/style.js +6 -0
- package/dist/components/spinner/style.js.map +1 -0
- package/dist/components/svg-draw-lines/index.d.ts +30 -9
- package/dist/components/svg-draw-lines/index.js +87 -62
- package/dist/components/svg-draw-lines/index.js.map +1 -1
- package/dist/components/svg-draw-lines/style.js +1 -1
- package/dist/components/svg-draw-lines/style.js.map +1 -1
- package/dist/components/switch/index.d.ts +37 -0
- package/dist/components/switch/index.js +117 -0
- package/dist/components/switch/index.js.map +1 -0
- package/dist/components/switch/style.js +6 -0
- package/dist/components/switch/style.js.map +1 -0
- package/dist/components/textarea/index.d.ts +65 -0
- package/dist/components/textarea/index.js +204 -0
- package/dist/components/textarea/index.js.map +1 -0
- package/dist/components/textarea/style.js +6 -0
- package/dist/components/textarea/style.js.map +1 -0
- package/dist/components/theme/index.d.ts +29 -0
- package/dist/components/theme/index.js +78 -0
- package/dist/components/theme/index.js.map +1 -0
- package/dist/components/theme/style.js +6 -0
- package/dist/components/theme/style.js.map +1 -0
- package/dist/components/toast/index.d.ts +3 -0
- package/dist/components/toast/index.js +3 -0
- package/dist/components/toast/manager.d.ts +15 -0
- package/dist/components/toast/manager.js +98 -0
- package/dist/components/toast/manager.js.map +1 -0
- package/dist/components/toast/style.js +6 -0
- package/dist/components/toast/style.js.map +1 -0
- package/dist/components/toast/toast.d.ts +42 -0
- package/dist/components/toast/toast.js +122 -0
- package/dist/components/toast/toast.js.map +1 -0
- package/dist/components/toast/types.d.ts +23 -0
- package/dist/components/tooltip/index.d.ts +59 -0
- package/dist/components/tooltip/index.js +190 -0
- package/dist/components/tooltip/index.js.map +1 -0
- package/dist/components/tooltip/style.js +6 -0
- package/dist/components/tooltip/style.js.map +1 -0
- package/dist/icons/generated/heroicons-check-16-solid.d.ts +6 -0
- package/dist/icons/generated/heroicons-check-16-solid.js +10 -0
- package/dist/icons/generated/heroicons-check-16-solid.js.map +1 -0
- package/dist/icons/generated/heroicons-x-mark-16-solid.d.ts +6 -0
- package/dist/icons/generated/heroicons-x-mark-16-solid.js +10 -0
- package/dist/icons/generated/heroicons-x-mark-16-solid.js.map +1 -0
- package/dist/icons/generated/jam-close-circle-f.d.ts +8 -0
- package/dist/icons/generated/jam-close-circle-f.js +12 -0
- package/dist/icons/generated/jam-close-circle-f.js.map +1 -0
- package/dist/icons/generated/jam-volume.d.ts +8 -0
- package/dist/icons/generated/jam-watch-f.d.ts +8 -0
- package/dist/icons/generated/lucide-arrow-down-to-line.d.ts +6 -0
- package/dist/icons/generated/lucide-arrow-down-to-line.js +10 -0
- package/dist/icons/generated/lucide-arrow-down-to-line.js.map +1 -0
- package/dist/icons/generated/lucide-arrow-up-to-line.d.ts +6 -0
- package/dist/icons/generated/lucide-arrow-up-to-line.js +10 -0
- package/dist/icons/generated/lucide-arrow-up-to-line.js.map +1 -0
- package/dist/icons/generated/lucide-bell.d.ts +6 -0
- package/dist/icons/generated/lucide-bell.js +10 -0
- package/dist/icons/generated/lucide-bell.js.map +1 -0
- package/dist/icons/generated/lucide-check.d.ts +6 -0
- package/dist/icons/generated/lucide-check.js +10 -0
- package/dist/icons/generated/lucide-check.js.map +1 -0
- package/dist/icons/generated/lucide-chevron-down.d.ts +6 -0
- package/dist/icons/generated/lucide-chevron-down.js +10 -0
- package/dist/icons/generated/lucide-chevron-down.js.map +1 -0
- package/dist/icons/generated/lucide-chevron-left.d.ts +6 -0
- package/dist/icons/generated/lucide-chevron-left.js +10 -0
- package/dist/icons/generated/lucide-chevron-left.js.map +1 -0
- package/dist/icons/generated/lucide-chevron-right.d.ts +6 -0
- package/dist/icons/generated/lucide-chevron-right.js +10 -0
- package/dist/icons/generated/lucide-chevron-right.js.map +1 -0
- package/dist/icons/generated/lucide-chevron-up.d.ts +6 -0
- package/dist/icons/generated/lucide-chevron-up.js +10 -0
- package/dist/icons/generated/lucide-chevron-up.js.map +1 -0
- package/dist/icons/generated/lucide-circle-alert.d.ts +6 -0
- package/dist/icons/generated/lucide-circle-alert.js +10 -0
- package/dist/icons/generated/lucide-circle-alert.js.map +1 -0
- package/dist/icons/generated/lucide-clipboard-paste.d.ts +6 -0
- package/dist/icons/generated/lucide-clipboard-paste.js +10 -0
- package/dist/icons/generated/lucide-clipboard-paste.js.map +1 -0
- package/dist/icons/generated/lucide-copy.d.ts +6 -0
- package/dist/icons/generated/lucide-copy.js +10 -0
- package/dist/icons/generated/lucide-copy.js.map +1 -0
- package/dist/icons/generated/lucide-download.d.ts +6 -0
- package/dist/icons/generated/lucide-download.js +10 -0
- package/dist/icons/generated/lucide-download.js.map +1 -0
- package/dist/icons/generated/lucide-file.d.ts +6 -0
- package/dist/icons/generated/lucide-file.js +10 -0
- package/dist/icons/generated/lucide-file.js.map +1 -0
- package/dist/icons/generated/lucide-folder.d.ts +6 -0
- package/dist/icons/generated/lucide-folder.js +10 -0
- package/dist/icons/generated/lucide-folder.js.map +1 -0
- package/dist/icons/generated/lucide-globe.d.ts +6 -0
- package/dist/icons/generated/lucide-globe.js +10 -0
- package/dist/icons/generated/lucide-globe.js.map +1 -0
- package/dist/icons/generated/lucide-heart.d.ts +6 -0
- package/dist/icons/generated/lucide-heart.js +10 -0
- package/dist/icons/generated/lucide-heart.js.map +1 -0
- package/dist/icons/generated/lucide-image.d.ts +6 -0
- package/dist/icons/generated/lucide-image.js +10 -0
- package/dist/icons/generated/lucide-image.js.map +1 -0
- package/dist/icons/generated/lucide-inbox.d.ts +6 -0
- package/dist/icons/generated/lucide-inbox.js +10 -0
- package/dist/icons/generated/lucide-inbox.js.map +1 -0
- package/dist/icons/generated/lucide-info.d.ts +6 -0
- package/dist/icons/generated/lucide-info.js +10 -0
- package/dist/icons/generated/lucide-info.js.map +1 -0
- package/dist/icons/generated/lucide-loader-circle.d.ts +6 -0
- package/dist/icons/generated/lucide-loader-circle.js +10 -0
- package/dist/icons/generated/lucide-loader-circle.js.map +1 -0
- package/dist/icons/generated/lucide-mail.d.ts +6 -0
- package/dist/icons/generated/lucide-mail.js +10 -0
- package/dist/icons/generated/lucide-mail.js.map +1 -0
- package/dist/icons/generated/lucide-minus.d.ts +6 -0
- package/dist/icons/generated/lucide-minus.js +10 -0
- package/dist/icons/generated/lucide-minus.js.map +1 -0
- package/dist/icons/generated/lucide-plus.d.ts +6 -0
- package/dist/icons/generated/lucide-plus.js +10 -0
- package/dist/icons/generated/lucide-plus.js.map +1 -0
- package/dist/icons/generated/lucide-printer.d.ts +6 -0
- package/dist/icons/generated/lucide-printer.js +10 -0
- package/dist/icons/generated/lucide-printer.js.map +1 -0
- package/dist/icons/generated/lucide-redo-2.d.ts +6 -0
- package/dist/icons/generated/lucide-redo-2.js +10 -0
- package/dist/icons/generated/lucide-redo-2.js.map +1 -0
- package/dist/icons/generated/lucide-scissors.d.ts +6 -0
- package/dist/icons/generated/lucide-scissors.js +10 -0
- package/dist/icons/generated/lucide-scissors.js.map +1 -0
- package/dist/icons/generated/lucide-search.d.ts +6 -0
- package/dist/icons/generated/lucide-search.js +10 -0
- package/dist/icons/generated/lucide-search.js.map +1 -0
- package/dist/icons/generated/lucide-settings.d.ts +6 -0
- package/dist/icons/generated/lucide-settings.js +10 -0
- package/dist/icons/generated/lucide-settings.js.map +1 -0
- package/dist/icons/generated/lucide-star.d.ts +6 -0
- package/dist/icons/generated/lucide-star.js +10 -0
- package/dist/icons/generated/lucide-star.js.map +1 -0
- package/dist/icons/generated/lucide-trash-2.d.ts +6 -0
- package/dist/icons/generated/lucide-trash-2.js +10 -0
- package/dist/icons/generated/lucide-trash-2.js.map +1 -0
- package/dist/icons/generated/lucide-triangle-alert.d.ts +6 -0
- package/dist/icons/generated/lucide-triangle-alert.js +10 -0
- package/dist/icons/generated/lucide-triangle-alert.js.map +1 -0
- package/dist/icons/generated/lucide-undo-2.d.ts +6 -0
- package/dist/icons/generated/lucide-undo-2.js +10 -0
- package/dist/icons/generated/lucide-undo-2.js.map +1 -0
- package/dist/icons/generated/lucide-upload.d.ts +6 -0
- package/dist/icons/generated/lucide-upload.js +10 -0
- package/dist/icons/generated/lucide-upload.js.map +1 -0
- package/dist/icons/generated/lucide-user.d.ts +6 -0
- package/dist/icons/generated/lucide-user.js +10 -0
- package/dist/icons/generated/lucide-user.js.map +1 -0
- package/dist/icons/generated/lucide-x.d.ts +6 -0
- package/dist/icons/generated/lucide-x.js +10 -0
- package/dist/icons/generated/lucide-x.js.map +1 -0
- package/dist/icons/generated/ooui-check.d.ts +6 -0
- package/dist/icons/generated/radix-icons-check.d.ts +6 -0
- package/dist/icons/generated/radix-icons-panel-left-minimized.d.ts +6 -0
- package/dist/icons/generated/radix-icons-panel-left-minimized.js +10 -0
- package/dist/icons/generated/radix-icons-panel-left-minimized.js.map +1 -0
- package/dist/icons/generated/si-check-alt-fill.d.ts +6 -0
- package/dist/icons/index.d.ts +39 -0
- package/dist/icons/index.js +40 -0
- package/dist/node_modules/.pnpm/@floating-ui_core@1.8.0/node_modules/@floating-ui/core/dist/floating-ui.core.js +248 -0
- package/dist/node_modules/.pnpm/@floating-ui_core@1.8.0/node_modules/@floating-ui/core/dist/floating-ui.core.js.map +1 -0
- package/dist/node_modules/.pnpm/@floating-ui_dom@1.8.0/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +324 -0
- package/dist/node_modules/.pnpm/@floating-ui_dom@1.8.0/node_modules/@floating-ui/dom/dist/floating-ui.dom.js.map +1 -0
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.12/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +99 -0
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.12/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js.map +1 -0
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.12/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +102 -0
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.12/node_modules/@floating-ui/utils/dist/floating-ui.utils.js.map +1 -0
- package/dist/shared/menu-portal/menu-portal.js +11 -0
- package/dist/shared/menu-portal/menu-portal.js.map +1 -0
- package/dist/shared/normalize/index.js +11 -0
- package/dist/shared/normalize/index.js.map +1 -0
- package/dist/shared/overlay/overlay.js +68 -0
- package/dist/shared/overlay/overlay.js.map +1 -0
- package/dist/shared/overlay/portal.js +29 -0
- package/dist/shared/overlay/portal.js.map +1 -0
- package/dist/shared/overlay/presence.js +34 -0
- package/dist/shared/overlay/presence.js.map +1 -0
- package/dist/shared/property-converters/boolean-with-false-string.js +9 -0
- package/dist/shared/property-converters/boolean-with-false-string.js.map +1 -0
- package/dist/shared/scroll-lock/scroll-lock.js +12 -0
- package/dist/shared/scroll-lock/scroll-lock.js.map +1 -0
- package/dist/shared/theme/overlay-root.js +28 -0
- package/dist/shared/theme/overlay-root.js.map +1 -0
- package/dist/shared/theme/theme-scope.js +27 -0
- package/dist/shared/theme/theme-scope.js.map +1 -0
- package/dist/types/iconify.d.ts +1 -0
- package/dist/types/react.d.ts +35 -9
- package/dist/types/utils.d.ts +14 -0
- package/dist/types/vue.d.ts +47 -7
- package/package.json +29 -13
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -5
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
export declare class WebUiButton extends LitElement {
|
|
3
|
-
static styles: import('lit').CSSResult;
|
|
3
|
+
static styles: import('lit').CSSResult[];
|
|
4
|
+
get variant(): 'primary' | 'secondary' | 'ghost' | 'danger' | 'glass';
|
|
5
|
+
set variant(v: string);
|
|
6
|
+
private _variant;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
loading: boolean;
|
|
4
9
|
full: boolean;
|
|
5
|
-
primary: boolean;
|
|
6
|
-
text: boolean;
|
|
7
10
|
icon: boolean;
|
|
11
|
+
size: string;
|
|
12
|
+
/** size="32" → 32x32,size="32x80" → 32x80 */
|
|
13
|
+
private get _sizeStyle();
|
|
14
|
+
private handleClick;
|
|
8
15
|
render(): import('lit').TemplateResult<1>;
|
|
16
|
+
readonly $events: Record<string, never>;
|
|
17
|
+
}
|
|
18
|
+
declare global {
|
|
19
|
+
interface HTMLElementTagNameMap {
|
|
20
|
+
'web-ui-button': WebUiButton;
|
|
21
|
+
}
|
|
9
22
|
}
|
|
@@ -1,41 +1,80 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import e from "../../_virtual/_@oxc-project_runtime@0.140.0/helpers/esm/decorate.js";
|
|
2
|
+
import "../icon/index.js";
|
|
3
|
+
import t from "../../assets/glass.js";
|
|
4
|
+
import n from "../../icons/generated/lucide-loader-circle.js";
|
|
5
|
+
import { normalizeLiteral as r } from "../../shared/normalize/index.js";
|
|
6
|
+
import i from "./style.js";
|
|
7
|
+
import { LitElement as a, html as o, nothing as s, unsafeCSS as c } from "lit";
|
|
8
|
+
import { customElement as l, property as u } from "lit/decorators.js";
|
|
9
|
+
import { classMap as d } from "lit/directives/class-map.js";
|
|
10
|
+
import { styleMap as f } from "lit/directives/style-map.js";
|
|
5
11
|
//#region src/components/button/index.ts
|
|
6
|
-
var
|
|
12
|
+
var p = [
|
|
13
|
+
"primary",
|
|
14
|
+
"secondary",
|
|
15
|
+
"ghost",
|
|
16
|
+
"danger",
|
|
17
|
+
"glass"
|
|
18
|
+
], m = class extends a {
|
|
7
19
|
constructor(...e) {
|
|
8
|
-
super(...e), this.
|
|
20
|
+
super(...e), this._variant = "glass", this.disabled = !1, this.loading = !1, this.full = !1, this.icon = !1, this.size = "";
|
|
9
21
|
}
|
|
10
22
|
static {
|
|
11
|
-
this.styles =
|
|
23
|
+
this.styles = [c(t), c(i)];
|
|
24
|
+
}
|
|
25
|
+
get variant() {
|
|
26
|
+
return this._variant;
|
|
27
|
+
}
|
|
28
|
+
set variant(e) {
|
|
29
|
+
let t = this._variant;
|
|
30
|
+
this._variant = r(e, p, "glass"), this.requestUpdate("variant", t);
|
|
31
|
+
}
|
|
32
|
+
get _sizeStyle() {
|
|
33
|
+
if (!this.size) return {};
|
|
34
|
+
let [e, t] = this.size.split("x"), n = { "--wui-button-size": `${e}px` };
|
|
35
|
+
return t && (n["--wui-button-width"] = `${t}px`), n;
|
|
36
|
+
}
|
|
37
|
+
handleClick(e) {
|
|
38
|
+
(this.disabled || this.loading) && (e.preventDefault(), e.stopPropagation());
|
|
12
39
|
}
|
|
13
40
|
render() {
|
|
14
|
-
return
|
|
15
|
-
<button
|
|
16
|
-
|
|
41
|
+
return o`
|
|
42
|
+
<button
|
|
43
|
+
class=${d({ "wui-glass": this.variant === "glass" && !this.hasAttribute("group") })}
|
|
44
|
+
style=${this.size ? f(this._sizeStyle) : s}
|
|
45
|
+
?disabled=${this.disabled || this.loading}
|
|
46
|
+
@click=${this.handleClick}
|
|
47
|
+
>
|
|
48
|
+
${this.loading ? o`<web-ui-icon .icon=${n} spin></web-ui-icon>` : ""}
|
|
49
|
+
${this.icon ? o`<slot></slot>` : o`
|
|
17
50
|
<slot name="prefix"></slot>
|
|
18
|
-
<slot></slot>
|
|
51
|
+
<span class="label"><slot></slot></span>
|
|
19
52
|
<slot name="suffix"></slot>
|
|
20
53
|
`}
|
|
21
54
|
</button>
|
|
22
55
|
`;
|
|
23
56
|
}
|
|
24
57
|
};
|
|
25
|
-
|
|
58
|
+
e([u({
|
|
59
|
+
type: String,
|
|
60
|
+
reflect: !0
|
|
61
|
+
})], m.prototype, "variant", null), e([u({
|
|
26
62
|
type: Boolean,
|
|
27
63
|
reflect: !0
|
|
28
|
-
})],
|
|
64
|
+
})], m.prototype, "disabled", void 0), e([u({
|
|
29
65
|
type: Boolean,
|
|
30
66
|
reflect: !0
|
|
31
|
-
})],
|
|
67
|
+
})], m.prototype, "loading", void 0), e([u({
|
|
32
68
|
type: Boolean,
|
|
33
69
|
reflect: !0
|
|
34
|
-
})],
|
|
70
|
+
})], m.prototype, "full", void 0), e([u({
|
|
35
71
|
type: Boolean,
|
|
36
72
|
reflect: !0
|
|
37
|
-
})],
|
|
73
|
+
})], m.prototype, "icon", void 0), e([u({
|
|
74
|
+
type: String,
|
|
75
|
+
reflect: !0
|
|
76
|
+
})], m.prototype, "size", void 0), m = e([l("web-ui-button")], m);
|
|
38
77
|
//#endregion
|
|
39
|
-
export {
|
|
78
|
+
export { m as WebUiButton };
|
|
40
79
|
|
|
41
80
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/button/index.ts"],"sourcesContent":["import { html, LitElement, unsafeCSS } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport style from './style.css?inline'\n\n@customElement('web-ui-button')\nexport class WebUiButton extends LitElement {\n static override styles = unsafeCSS(style)\n\n @property({ type: Boolean, reflect: true })
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/button/index.ts"],"sourcesContent":["import { html, LitElement, nothing, unsafeCSS } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { styleMap } from 'lit/directives/style-map.js'\n\n// web-ui-icon 必须注册(Rolldown tree-shake 副作用 import,引用类名阻止删除)\nimport '@/components/icon'\nimport glass from '@/assets/glass.css?inline'\nimport { lucideLoaderCircle } from '@/icons'\nimport { normalizeLiteral } from '@/shared/normalize'\n\nimport style from './style.css?inline'\n\nconst ALLOWED_VARIANTS = ['primary', 'secondary', 'ghost', 'danger', 'glass'] as const\n\n@customElement('web-ui-button')\nexport class WebUiButton extends LitElement {\n static override styles = [unsafeCSS(glass), unsafeCSS(style)]\n\n @property({ type: String, reflect: true })\n get variant(): 'primary' | 'secondary' | 'ghost' | 'danger' | 'glass' {\n return this._variant\n }\n set variant(v: string) {\n const old = this._variant\n this._variant = normalizeLiteral(v, ALLOWED_VARIANTS, 'glass')\n this.requestUpdate('variant', old)\n }\n private _variant: 'primary' | 'secondary' | 'ghost' | 'danger' | 'glass' = 'glass'\n\n @property({ type: Boolean, reflect: true }) disabled = false\n @property({ type: Boolean, reflect: true }) loading = false\n @property({ type: Boolean, reflect: true }) full = false\n @property({ type: Boolean, reflect: true }) icon = false\n @property({ type: String, reflect: true }) size = ''\n\n /** size=\"32\" → 32x32,size=\"32x80\" → 32x80 */\n private get _sizeStyle(): Record<string, string> {\n if (!this.size) return {}\n const [h, w] = this.size.split('x')\n const style: Record<string, string> = { '--wui-button-size': `${h}px` }\n if (w) style['--wui-button-width'] = `${w}px`\n return style\n }\n\n private handleClick(e: Event) {\n if (this.disabled || this.loading) {\n e.preventDefault()\n e.stopPropagation()\n }\n }\n\n override render() {\n const btnClass = { 'wui-glass': this.variant === 'glass' && !this.hasAttribute('group') }\n return html`\n <button\n class=${classMap(btnClass)}\n style=${this.size ? styleMap(this._sizeStyle) : nothing}\n ?disabled=${this.disabled || this.loading}\n @click=${this.handleClick}\n >\n ${this.loading ? html`<web-ui-icon .icon=${lucideLoaderCircle} spin></web-ui-icon>` : ''}\n ${this.icon\n ? html`<slot></slot>`\n : html`\n <slot name=\"prefix\"></slot>\n <span class=\"label\"><slot></slot></span>\n <slot name=\"suffix\"></slot>\n `}\n </button>\n `\n }\n\n declare readonly $events: Record<string, never>\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'web-ui-button': WebU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AWxC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,YAAA,KAAA,CAAA,GACzC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,WAAA,KAAA,CAAA,GACzC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,GACzC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,GACzC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,GAnB1C,IAAA,EAAA,CAAA,EAAc,eAAe,CAAA,GAAA,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/components/button/style.css?inline
|
|
2
|
-
var e = ":host
|
|
2
|
+
var e = "*,:before,:after{box-sizing:border-box}:host{display:inline-block}:host([full]){width:100%;display:block}:host([disabled]){cursor:not-allowed}button{cursor:pointer;-webkit-user-select:none;user-select:none;gap:var(--wui-button-gap,8px);box-sizing:border-box;width:var(--wui-button-width,max-content);min-width:var(--wui-button-size,auto);height:var(--wui-button-size,40px);padding:0 var(--wui-button-px,16px);font-size:var(--wui-font-size,14px);color:var(--wui-button-color);white-space:nowrap;background-color:var(--wui-button-bg);transition:transform var(--wui-duration-press,.12s) var(--wui-ease-out,cubic-bezier(.23, 1, .32, 1)), background-color var(--wui-duration-fast,.16s) ease;border:1px solid #0000;border-radius:2147483647px;justify-content:center;align-items:center;line-height:1;display:inline-flex;position:relative;overflow:clip}button:disabled{cursor:not-allowed;opacity:.4}button:focus-visible{outline:3px solid var(--wui-focus-ring,#08f6);outline-offset:2px}button:active:not(:disabled){transform:scale(var(--wui-scale-press,.97));background-color:var(--wui-button-bg-active)}@media (hover:hover) and (pointer:fine){button:hover:not(:disabled){background-color:var(--wui-button-bg-hover)}}@media (prefers-reduced-motion:reduce){button{transition:background-color var(--wui-duration-fast,.16s) ease}button:active:not(:disabled){transform:none}}:host([full]) button{width:100%;display:flex}:host([icon]) button{aspect-ratio:1;padding:0}:host([variant=primary]){--wui-button-color:var(--wui-color-on-accent,#fff);--wui-button-bg:var(--wui-color-accent,#08f);--wui-button-bg-hover:color-mix(in srgb, var(--wui-color-accent,#08f) 88%, var(--wui-color-text,#1b1b1b));--wui-button-bg-active:color-mix(in srgb, var(--wui-color-accent,#08f) 76%, var(--wui-color-text,#1b1b1b))}:host([variant=secondary]){--wui-button-color:var(--wui-color-text,#1b1b1b);--wui-button-bg:var(--wui-color-surface-raised-mid,#dfdfdf);--wui-button-bg-hover:color-mix(in srgb, var(--wui-color-surface-raised-mid,#dfdfdf) 90%, var(--wui-color-text,#1b1b1b));--wui-button-bg-active:color-mix(in srgb, var(--wui-color-surface-raised-mid,#dfdfdf) 80%, var(--wui-color-text,#1b1b1b))}:host([variant=ghost]){--wui-button-color:var(--wui-color-text,#1b1b1b);--wui-button-bg:transparent;--wui-button-bg-hover:color-mix(in srgb, var(--wui-color-text,#1b1b1b) 6%, transparent);--wui-button-bg-active:color-mix(in srgb, var(--wui-color-text,#1b1b1b) 10%, transparent)}:host([variant=danger]){--wui-button-color:var(--wui-color-danger,#dc2626);--wui-button-bg:color-mix(in srgb, var(--wui-color-danger,#dc2626) 18%, var(--wui-color-surface,#fff));--wui-button-bg-hover:color-mix(in srgb, var(--wui-color-danger,#dc2626) 26%, var(--wui-color-surface,#fff));--wui-button-bg-active:color-mix(in srgb, var(--wui-color-danger,#dc2626) 34%, var(--wui-color-surface,#fff))}:host([variant=glass]){--wui-button-color:var(--wui-color-text,#1b1b1b);--wui-button-bg:transparent;--wui-button-bg-hover:color-mix(in srgb, var(--wui-color-text,#1b1b1b) 6%, transparent);--wui-button-bg-active:color-mix(in srgb, var(--wui-color-text,#1b1b1b) 10%, transparent)}:host([group]){--wui-button-color:var(--wui-color-text,#1b1b1b);--wui-button-bg:transparent;--wui-button-bg-hover:color-mix(in srgb, var(--wui-color-text,#1b1b1b) 6%, transparent);--wui-button-bg-active:color-mix(in srgb, var(--wui-color-text,#1b1b1b) 10%, transparent);position:relative}:host([group]:not([last])):after{content:\"\";width:var(--wui-button-divider-width,0);background-color:var(--wui-color-border,#0000001a);height:24px;position:absolute;top:50%;right:-2px;transform:translateY(-50%)}:host([group][direction=vertical]:not([last])):after{width:24px;height:var(--wui-button-divider-width,0);inset:auto auto -2px 50%;transform:translate(-50%)}";
|
|
3
3
|
//#endregion
|
|
4
4
|
export { e as default };
|
|
5
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","names":[],"sources":["../../../src/components/button/style.css?inline"],"sourcesContent":[":host {\n
|
|
1
|
+
{"version":3,"file":"style.js","names":[],"sources":["../../../src/components/button/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n display: inline-block;\n}\n\n:host([full]) {\n display: block;\n width: 100%;\n}\n\n:host([disabled]) {\n cursor: not-allowed;\n}\n\nbutton {\n cursor: pointer;\n user-select: none;\n\n position: relative;\n\n overflow: clip;\n display: inline-flex;\n gap: var(--wui-button-gap, 8px);\n align-items: center;\n justify-content: center;\n\n box-sizing: border-box;\n width: var(--wui-button-width, max-content);\n min-width: var(--wui-button-size, auto);\n height: var(--wui-button-size, 40px);\n padding: 0 var(--wui-button-px, 16px);\n border: 1px solid transparent;\n border-radius: calc(infinity * 1px);\n\n font-size: var(--wui-font-size, 14px);\n line-height: 1;\n color: var(--wui-button-color);\n white-space: nowrap;\n\n background-color: var(--wui-button-bg);\n\n transition:\n transform var(--wui-duration-press, 120ms) var(--wui-ease-out, cubic-bezier(0.23, 1, 0.32, 1)),\n background-color var(--wui-duration-fast, 160ms) ease;\n\n &:disabled {\n cursor: not-allowed;\n opacity: 0.4;\n }\n\n &:focus-visible {\n outline: 3px solid var(--wui-focus-ring, rgb(0 136 255 / 0.4));\n outline-offset: 2px;\n }\n\n &:active:not(:disabled) {\n transform: scale(var(--wui-scale-press, 0.97));\n background-color: var(--wui-button-bg-active);\n }\n}\n\n@media (hover: hover) and (pointer: fine) {\n button:hover:not(:disabled) {\n background-color: var(--wui-button-bg-hover);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n button {\n transition: background-color var(--wui-duration-fast, 160ms) ease;\n }\n\n button:active:not(:disabled) {\n transform: none;\n }\n}\n\n/* ===== Full width ===== */\n\n:host([full]) button {\n display: flex;\n width: 100%;\n}\n\n/* ===== Icon mode ===== */\n\n:host([icon]) button {\n aspect-ratio: 1;\n padding: 0;\n}\n\n/* ===== Variant: primary (默认) ===== */\n\n:host([variant='primary']) {\n --wui-button-color: var(--wui-color-on-accent, #fff);\n --wui-button-bg: var(--wui-color-accent, #08f);\n --wui-button-bg-hover: color-mix(in srgb, var(--wui-color-accent, #08f) 88%, var(--wui-color-text, #1b1b1b));\n --wui-button-bg-active: color-mix(in srgb, var(--wui-color-accent, #08f) 76%, var(--wui-color-text, #1b1b1b));\n}\n\n/* ===== Variant: secondary ===== */\n\n:host([variant='secondary']) {\n --wui-button-color: var(--wui-color-text, #1b1b1b);\n --wui-button-bg: var(--wui-color-surface-raised-mid, #dfdfdf);\n --wui-button-bg-hover: color-mix(\n in srgb,\n var(--wui-color-surface-raised-mid, #dfdfdf) 90%,\n var(--wui-color-text, #1b1b1b)\n );\n --wui-button-bg-active: color-mix(\n in srgb,\n var(--wui-color-surface-raised-mid, #dfdfdf) 80%,\n var(--wui-color-text, #1b1b1b)\n );\n}\n\n/* ===== Variant: ghost ===== */\n\n:host([variant='ghost']) {\n --wui-button-color: var(--wui-color-text, #1b1b1b);\n --wui-button-bg: transparent;\n --wui-button-bg-hover: color-mix(in srgb, var(--wui-color-text, #1b1b1b) 6%, transparent);\n --wui-button-bg-active: color-mix(in srgb, var(--wui-color-text, #1b1b1b) 10%, transparent);\n}\n\n/* ===== Variant: danger ===== */\n\n:host([variant='danger']) {\n --wui-button-color: var(--wui-color-danger, #dc2626);\n --wui-button-bg: color-mix(in srgb, var(--wui-color-danger, #dc2626) 18%, var(--wui-color-surface, #fff));\n --wui-button-bg-hover: color-mix(in srgb, var(--wui-color-danger, #dc2626) 26%, var(--wui-color-surface, #fff));\n --wui-button-bg-active: color-mix(in srgb, var(--wui-color-danger, #dc2626) 34%, var(--wui-color-surface, #fff));\n}\n\n/* ===== Variant: glass (玻璃) ===== */\n\n/* .wui-glass 样式由 @/assets/glass.css 提供 */\n:host([variant='glass']) {\n --wui-button-color: var(--wui-color-text, #1b1b1b);\n --wui-button-bg: transparent;\n --wui-button-bg-hover: color-mix(in srgb, var(--wui-color-text, #1b1b1b) 6%, transparent);\n --wui-button-bg-active: color-mix(in srgb, var(--wui-color-text, #1b1b1b) 10%, transparent);\n}\n\n/* ===== Group context ===== */\n\n:host([group]) {\n --wui-button-color: var(--wui-color-text, #1b1b1b);\n --wui-button-bg: transparent;\n --wui-button-bg-hover: color-mix(in srgb, var(--wui-color-text, #1b1b1b) 6%, transparent);\n --wui-button-bg-active: color-mix(in srgb, var(--wui-color-text, #1b1b1b) 10%, transparent);\n position: relative;\n}\n\n:host([group]:not([last]))::after {\n content: '';\n\n position: absolute;\n top: 50%;\n right: -2px;\n transform: translateY(-50%);\n\n width: var(--wui-button-divider-width, 0);\n height: 24px;\n\n background-color: var(--wui-color-border, rgb(0 0 0 / 0.1));\n}\n\n:host([group][direction='vertical']:not([last]))::after {\n top: auto;\n right: auto;\n bottom: -2px;\n left: 50%;\n transform: translateX(-50%);\n\n width: 24px;\n height: var(--wui-button-divider-width, 0);\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class WebUiButtonGroup extends LitElement {
|
|
3
|
+
static styles: import('lit').CSSResult[];
|
|
4
|
+
get direction(): 'horizontal' | 'vertical';
|
|
5
|
+
set direction(v: string);
|
|
6
|
+
private _direction;
|
|
7
|
+
updated(): void;
|
|
8
|
+
private syncChildButtons;
|
|
9
|
+
render(): import('lit').TemplateResult<1>;
|
|
10
|
+
readonly $events: Record<string, never>;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
'web-ui-button-group': WebUiButtonGroup;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import e from "../../_virtual/_@oxc-project_runtime@0.140.0/helpers/esm/decorate.js";
|
|
2
|
+
import t from "../../assets/glass.js";
|
|
3
|
+
import { normalizeLiteral as n } from "../../shared/normalize/index.js";
|
|
4
|
+
import "../button/index.js";
|
|
5
|
+
import r from "./style.js";
|
|
6
|
+
import { LitElement as i, html as a, unsafeCSS as o } from "lit";
|
|
7
|
+
import { customElement as s, property as c } from "lit/decorators.js";
|
|
8
|
+
//#region src/components/button-group/index.ts
|
|
9
|
+
var l = ["horizontal", "vertical"], u = class extends i {
|
|
10
|
+
constructor(...e) {
|
|
11
|
+
super(...e), this._direction = "horizontal";
|
|
12
|
+
}
|
|
13
|
+
static {
|
|
14
|
+
this.styles = [o(t), o(r)];
|
|
15
|
+
}
|
|
16
|
+
get direction() {
|
|
17
|
+
return this._direction;
|
|
18
|
+
}
|
|
19
|
+
set direction(e) {
|
|
20
|
+
let t = this._direction;
|
|
21
|
+
this._direction = n(e, l, "horizontal"), this.requestUpdate("direction", t);
|
|
22
|
+
}
|
|
23
|
+
updated() {
|
|
24
|
+
this.syncChildButtons();
|
|
25
|
+
}
|
|
26
|
+
syncChildButtons() {
|
|
27
|
+
let e = this.querySelectorAll("web-ui-button"), t = this.direction === "vertical";
|
|
28
|
+
for (let [n, r] of [...e].entries()) {
|
|
29
|
+
r.hasAttribute("group") || r.setAttribute("group", ""), r.variant = "glass", r.style.setProperty("--wui-button-size", "32px"), r.setAttribute("direction", t ? "vertical" : "horizontal");
|
|
30
|
+
let i = n === e.length - 1;
|
|
31
|
+
r.toggleAttribute("last", i), r.style.setProperty("--wui-button-divider-width", i ? "0px" : "1px");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
return a`
|
|
36
|
+
<div class="wui-glass wui-button-group-inner">
|
|
37
|
+
<slot></slot>
|
|
38
|
+
</div>
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
e([c({
|
|
43
|
+
type: String,
|
|
44
|
+
reflect: !0
|
|
45
|
+
})], u.prototype, "direction", null), u = e([s("web-ui-button-group")], u);
|
|
46
|
+
//#endregion
|
|
47
|
+
export { u as WebUiButtonGroup };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/button-group/index.ts"],"sourcesContent":["import { html, LitElement, unsafeCSS } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\n// web-ui-button 必须注册(Rolldown tree-shake 副作用 import,引用类名阻止删除)\nimport '@/components/button'\nimport glass from '@/assets/glass.css?inline'\nimport { normalizeLiteral } from '@/shared/normalize'\n\nimport style from './style.css?inline'\n\nconst ALLOWED_DIRECTIONS = ['horizontal', 'vertical'] as const\n\n@customElement('web-ui-button-group')\nexport class WebUiButtonGroup extends LitElement {\n static override styles = [unsafeCSS(glass), unsafeCSS(style)]\n\n @property({ type: String, reflect: true })\n get direction(): 'horizontal' | 'vertical' {\n return this._direction\n }\n set direction(v: string) {\n const old = this._direction\n this._direction = normalizeLiteral(v, ALLOWED_DIRECTIONS, 'horizontal')\n this.requestUpdate('direction', old)\n }\n private _direction: 'horizontal' | 'vertical' = 'horizontal'\n\n override updated() {\n this.syncChildButtons()\n }\n\n private syncChildButtons() {\n const buttons = this.querySelectorAll<HTMLElement & { variant: string }>('web-ui-button')\n const isVertical = this.direction === 'vertical'\n for (const [i, btn] of [...buttons].entries()) {\n if (!btn.hasAttribute('group')) btn.setAttribute('group', '')\n btn.variant = 'glass'\n btn.style.setProperty('--wui-button-size', '32px')\n btn.setAttribute('direction', isVertical ? 'vertical' : 'horizontal')\n const isLast = i === buttons.length - 1\n btn.toggleAttribute('last', isLast)\n btn.style.setProperty('--wui-button-divider-width', isLast ? '0px' : '1px')\n }\n }\n\n override render() {\n return html`\n <div class=\"wui-glass wui-button-group-inner\">\n <slot></slot>\n </div>\n `\n }\n\n declare readonly $events: Record<string, never>\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'web-ui-button-group': WebUiButtonGroup\n }\n}\n"],"mappings":";;;;;;;;AAUA,IAAM,IAAqB,CAAC,cAAc,UAAU,GAGvC,IAAN,cAA+B,EAAW;;EAYC,aAAA,KAAA,aAAA;;;EAXvB,KAAA,SAAA,CAAC,EAAU,CAAK,GAAG,EAAU,CAAK,CAAC;;CAE5D,IACI,YAAuC;EACzC,OAAO,KAAK;CACd;CACA,IAAI,UAAU,GAAW;EACvB,IAAM,IAAM,KAAK;EAEjB,AADA,KAAK,aAAa,EAAiB,GAAG,GAAoB,YAAY,GACtE,KAAK,cAAc,aAAa,CAAG;CACrC;CAGA,UAAmB;EACjB,KAAK,iBAAiB;CACxB;CAEA,mBAA2B;EACzB,IAAM,IAAU,KAAK,iBAAoD,eAAe,GAClF,IAAa,KAAK,cAAc;EACtC,KAAK,IAAM,CAAC,GAAG,MAAQ,CAAC,GAAG,CAAO,CAAC,CAAC,QAAQ,GAAG;GAI7C,AAHK,EAAI,aAAa,OAAO,KAAG,EAAI,aAAa,SAAS,EAAE,GAC5D,EAAI,UAAU,SACd,EAAI,MAAM,YAAY,qBAAqB,MAAM,GACjD,EAAI,aAAa,aAAa,IAAa,aAAa,YAAY;GACpE,IAAM,IAAS,MAAM,EAAQ,SAAS;GAEtC,AADA,EAAI,gBAAgB,QAAQ,CAAM,GAClC,EAAI,MAAM,YAAY,8BAA8B,IAAS,QAAQ,KAAK;EAC5E;CACF;CAEA,SAAkB;EAChB,OAAO,CAAI;;;;;CAKb;AAGF;AAtCG,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,aAAA,IAAA,GAJ1C,IAAA,EAAA,CAAA,EAAc,qBAAqB,CAAA,GAAA,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/components/button-group/style.css?inline
|
|
2
|
+
var e = "*,:before,:after{box-sizing:border-box}:host{display:inline-block}.wui-button-group-inner{flex-direction:var(--wui-button-group-flex-direction,row);border-radius:2147483647px;align-items:center;gap:4px;width:max-content;height:40px;padding:0 4px;display:flex}:host([direction=vertical]){--wui-button-group-flex-direction:column}:host([direction=vertical]) .wui-button-group-inner{width:40px;height:auto;padding:4px 0}";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { e as default };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","names":[],"sources":["../../../src/components/button-group/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n display: inline-block;\n}\n\n.wui-button-group-inner {\n display: flex;\n flex-direction: var(--wui-button-group-flex-direction, row);\n gap: 4px;\n align-items: center;\n\n width: max-content;\n height: 40px;\n padding: 0 4px;\n border-radius: calc(infinity * 1px);\n}\n\n:host([direction='vertical']) {\n --wui-button-group-flex-direction: column;\n}\n\n:host([direction='vertical']) .wui-button-group-inner {\n width: 40px;\n height: auto;\n padding: 4px 0;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class WebUiCheckbox extends LitElement {
|
|
3
|
+
static styles: import('lit').CSSResult;
|
|
4
|
+
static formAssociated: boolean;
|
|
5
|
+
/** 内部表单关联实例(connectedCallback 中初始化) */
|
|
6
|
+
private _internals?;
|
|
7
|
+
private _formDisabled;
|
|
8
|
+
private _groupDisabled;
|
|
9
|
+
/** 内部 checked 状态,通过 getter/setter 暴露为公共 API */
|
|
10
|
+
private _checked;
|
|
11
|
+
get checked(): boolean;
|
|
12
|
+
set checked(v: boolean);
|
|
13
|
+
value: string;
|
|
14
|
+
name: string;
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
required: boolean;
|
|
17
|
+
private get _isDisabled();
|
|
18
|
+
private get _isManagedByGroup();
|
|
19
|
+
setGroupDisabled(disabled: boolean): void;
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
formResetCallback(): void;
|
|
22
|
+
formDisabledCallback(disabled: boolean): void;
|
|
23
|
+
updated(): void;
|
|
24
|
+
private _syncFormValue;
|
|
25
|
+
private _syncValidity;
|
|
26
|
+
/** 用户点击切换 */
|
|
27
|
+
private handleClick;
|
|
28
|
+
private handleKeyDown;
|
|
29
|
+
render(): import('lit').TemplateResult<1>;
|
|
30
|
+
readonly $events: {
|
|
31
|
+
input: Event;
|
|
32
|
+
change: Event;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
declare global {
|
|
36
|
+
interface HTMLElementTagNameMap {
|
|
37
|
+
'web-ui-checkbox': WebUiCheckbox;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import e from "../../_virtual/_@oxc-project_runtime@0.140.0/helpers/esm/decorate.js";
|
|
2
|
+
import "../icon/index.js";
|
|
3
|
+
import t from "../../icons/generated/heroicons-check-16-solid.js";
|
|
4
|
+
import n from "./style.js";
|
|
5
|
+
import { LitElement as r, html as i, unsafeCSS as a } from "lit";
|
|
6
|
+
import { customElement as o, property as s, state as c } from "lit/decorators.js";
|
|
7
|
+
import { classMap as l } from "lit/directives/class-map.js";
|
|
8
|
+
//#region src/components/checkbox/index.ts
|
|
9
|
+
var u = class extends r {
|
|
10
|
+
constructor(...e) {
|
|
11
|
+
super(...e), this._formDisabled = !1, this._groupDisabled = !1, this._checked = !1, this.value = "", this.name = "", this.disabled = !1, this.required = !1;
|
|
12
|
+
}
|
|
13
|
+
static {
|
|
14
|
+
this.styles = a(n);
|
|
15
|
+
}
|
|
16
|
+
static {
|
|
17
|
+
this.formAssociated = !0;
|
|
18
|
+
}
|
|
19
|
+
get checked() {
|
|
20
|
+
return this._checked;
|
|
21
|
+
}
|
|
22
|
+
set checked(e) {
|
|
23
|
+
let t = this._checked;
|
|
24
|
+
this._checked = e, this._syncFormValue(), this.requestUpdate("checked", t);
|
|
25
|
+
}
|
|
26
|
+
get _isDisabled() {
|
|
27
|
+
return this.disabled || this._formDisabled || this._groupDisabled;
|
|
28
|
+
}
|
|
29
|
+
get _isManagedByGroup() {
|
|
30
|
+
return this.closest("web-ui-checkbox-group") !== null;
|
|
31
|
+
}
|
|
32
|
+
setGroupDisabled(e) {
|
|
33
|
+
this._groupDisabled = e;
|
|
34
|
+
}
|
|
35
|
+
connectedCallback() {
|
|
36
|
+
super.connectedCallback(), !this._internals && (this._internals = this.attachInternals(), this.hasAttribute("checked") && (this._checked = !0), this._syncFormValue());
|
|
37
|
+
}
|
|
38
|
+
formResetCallback() {
|
|
39
|
+
this.checked = this.hasAttribute("checked");
|
|
40
|
+
}
|
|
41
|
+
formDisabledCallback(e) {
|
|
42
|
+
this._formDisabled = e;
|
|
43
|
+
}
|
|
44
|
+
updated() {
|
|
45
|
+
this._syncFormValue(), this._syncValidity();
|
|
46
|
+
}
|
|
47
|
+
_syncFormValue() {
|
|
48
|
+
this._internals?.setFormValue?.(!this._isManagedByGroup && this._checked ? this.value || "on" : null);
|
|
49
|
+
}
|
|
50
|
+
_syncValidity() {
|
|
51
|
+
if (!(!this._internals || typeof this._internals.setValidity != "function")) {
|
|
52
|
+
if (this._isDisabled || this._isManagedByGroup || !this.required || this._checked) {
|
|
53
|
+
this._internals.setValidity({});
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this._internals.setValidity({ valueMissing: !0 }, "请选择此项");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
handleClick() {
|
|
60
|
+
if (this._isDisabled) return;
|
|
61
|
+
let e = this._checked;
|
|
62
|
+
this._checked = !e, this._syncFormValue(), this.requestUpdate("checked", e), this.dispatchEvent(new Event("input", {
|
|
63
|
+
bubbles: !0,
|
|
64
|
+
composed: !0
|
|
65
|
+
})), this.dispatchEvent(new Event("change", {
|
|
66
|
+
bubbles: !0,
|
|
67
|
+
composed: !0
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
handleKeyDown(e) {
|
|
71
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.handleClick());
|
|
72
|
+
}
|
|
73
|
+
render() {
|
|
74
|
+
return i`
|
|
75
|
+
<label
|
|
76
|
+
class=${l({
|
|
77
|
+
"wui-checkbox": !0,
|
|
78
|
+
"is-checked": this._checked,
|
|
79
|
+
"is-disabled": this._isDisabled
|
|
80
|
+
})}
|
|
81
|
+
tabindex="0"
|
|
82
|
+
role="checkbox"
|
|
83
|
+
aria-checked=${String(this._checked)}
|
|
84
|
+
aria-disabled=${String(this._isDisabled)}
|
|
85
|
+
@click=${this.handleClick}
|
|
86
|
+
@keydown=${this.handleKeyDown}
|
|
87
|
+
>
|
|
88
|
+
<span class="wui-checkbox-box">
|
|
89
|
+
<span class="wui-checkbox-icon"
|
|
90
|
+
><web-ui-icon .icon=${t} size="18" color="#fff"></web-ui-icon
|
|
91
|
+
></span>
|
|
92
|
+
</span>
|
|
93
|
+
<span class="wui-checkbox-label"><slot></slot></span>
|
|
94
|
+
</label>
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
e([c()], u.prototype, "_formDisabled", void 0), e([c()], u.prototype, "_groupDisabled", void 0), e([c()], u.prototype, "_checked", void 0), e([s({ type: String })], u.prototype, "value", void 0), e([s({
|
|
99
|
+
type: String,
|
|
100
|
+
reflect: !0
|
|
101
|
+
})], u.prototype, "name", void 0), e([s({
|
|
102
|
+
type: Boolean,
|
|
103
|
+
reflect: !0
|
|
104
|
+
})], u.prototype, "disabled", void 0), e([s({
|
|
105
|
+
type: Boolean,
|
|
106
|
+
reflect: !0
|
|
107
|
+
})], u.prototype, "required", void 0), u = e([o("web-ui-checkbox")], u);
|
|
108
|
+
//#endregion
|
|
109
|
+
export { u as WebUiCheckbox };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/checkbox/index.ts"],"sourcesContent":["import { html, LitElement, unsafeCSS } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\n\nimport '@/components/icon'\nimport { heroiconsCheck16Solid } from '@/icons'\n\nimport style from './style.css?inline'\n\n@customElement('web-ui-checkbox')\nexport class WebUiCheckbox extends LitElement {\n static override styles = unsafeCSS(style)\n static formAssociated = true\n\n /** 内部表单关联实例(connectedCallback 中初始化) */\n private _internals?: ElementInternals\n @state() private _formDisabled = false\n @state() private _groupDisabled = false\n\n /** 内部 checked 状态,通过 getter/setter 暴露为公共 API */\n @state() private _checked = false\n\n get checked(): boolean {\n return this._checked\n }\n\n set checked(v: boolean) {\n const old = this._checked\n this._checked = v\n this._syncFormValue()\n this.requestUpdate('checked', old)\n }\n\n @property({ type: String }) value = ''\n @property({ type: String, reflect: true }) name = ''\n @property({ type: Boolean, reflect: true }) disabled = false\n @property({ type: Boolean, reflect: true }) required = false\n\n private get _isDisabled(): boolean {\n return this.disabled || this._formDisabled || this._groupDisabled\n }\n\n private get _isManagedByGroup(): boolean {\n return this.closest('web-ui-checkbox-group') !== null\n }\n\n setGroupDisabled(disabled: boolean) {\n this._groupDisabled = disabled\n }\n\n override connectedCallback() {\n super.connectedCallback()\n if (this._internals) return\n this._internals = this.attachInternals()\n if (this.hasAttribute('checked')) {\n this._checked = true\n }\n this._syncFormValue()\n }\n\n formResetCallback() {\n this.checked = this.hasAttribute('checked')\n }\n\n formDisabledCallback(disabled: boolean) {\n this._formDisabled = disabled\n }\n\n override updated() {\n this._syncFormValue()\n this._syncValidity()\n }\n\n private _syncFormValue() {\n this._internals?.setFormValue?.(!this._isManagedByGroup && this._checked ? this.value || 'on' : null)\n }\n\n private _syncValidity() {\n if (!this._internals || typeof this._internals.setValidity !== 'function') return\n if (this._isDisabled || this._isManagedByGroup || !this.required || this._checked) {\n this._internals.setValidity({})\n return\n }\n this._internals.setValidity({ valueMissing: true }, '请选择此项')\n }\n\n /** 用户点击切换 */\n private handleClick() {\n if (this._isDisabled) return\n const old = this._checked\n this._checked = !old\n this._syncFormValue()\n this.requestUpdate('checked', old)\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }))\n this.dispatchEvent(new Event('change', { bubbles: true, composed: true }))\n }\n\n private handleKeyDown(e: KeyboardEvent) {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n this.handleClick()\n }\n }\n\n override render() {\n const cls = {\n 'wui-checkbox': true,\n 'is-checked': this._checked,\n 'is-disabled': this._isDisabled\n }\n\n return html`\n <label\n class=${classMap(cls)}\n tabindex=\"0\"\n role=\"checkbox\"\n aria-checked=${String(this._checked)}\n aria-disabled=${String(this._isDisabled)}\n @click=${this.handleClick}\n @keydown=${this.handleKeyDown}\n >\n <span class=\"wui-checkbox-box\">\n <span class=\"wui-checkbox-icon\"\n ><web-ui-icon .icon=${heroiconsCheck16Solid} size=\"18\" color=\"#fff\"></web-ui-icon\n ></span>\n </span>\n <span class=\"wui-checkbox-label\"><slot></slot></span>\n </label>\n `\n }\n\n declare readonly $events: {\n input: Event\n change: Event\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'web-ui-checkbox': WebUiCheckbox\n }\n}\n"],"mappings":";;;;;;;;AAUO,IAAM,IAAN,cAA4B,EAAW;;EA0BW,aApBtB,KAAA,gBAAA,IACC,KAAA,iBAAA,IAGN,KAAA,WAAA,IAaQ,KAAA,QAAA,I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 -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/components/checkbox/style.css?inline
|
|
2
|
+
var e = "*,:before,:after{box-sizing:border-box}:host{cursor:pointer;display:inline-block}:host([disabled]){cursor:not-allowed;opacity:.4}.wui-checkbox{cursor:pointer;-webkit-user-select:none;user-select:none;font-size:var(--wui-font-size,14px);color:var(--wui-color-text,#1b1b1b);align-items:center;gap:10px;line-height:1;display:inline-flex}.wui-checkbox:focus-visible{outline:3px solid var(--wui-focus-ring,#08f6);outline-offset:2px;border-radius:2147483647px}:host([disabled]) .wui-checkbox{cursor:not-allowed;color:var(--wui-color-text-muted,#6a6a6a)}.wui-checkbox-box{background-color:var(--wui-color-surface-raised,#f2f2f7);border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;width:18px;height:18px;transition:background-color .2s,border-color .2s;display:flex}.is-checked .wui-checkbox-box{border-color:var(--wui-color-accent,#08f);background-color:var(--wui-color-accent,#08f)}.wui-checkbox-icon{opacity:0;transition:opacity var(--wui-duration-fast,.16s) ease, transform var(--wui-duration-fast,.16s) var(--wui-ease-out,cubic-bezier(.23, 1, .32, 1));font-size:0;line-height:0;display:block;overflow:hidden;transform:scale(.85)}.is-checked .wui-checkbox-icon{opacity:1;transform:scale(1)}.wui-checkbox-label{pointer-events:none}@media (prefers-reduced-motion:reduce){.wui-checkbox-icon,.is-checked .wui-checkbox-icon{transform:none}}";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { e as default };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","names":[],"sources":["../../../src/components/checkbox/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n cursor: pointer;\n display: inline-block;\n}\n\n:host([disabled]) {\n cursor: not-allowed;\n opacity: 0.4;\n}\n\n.wui-checkbox {\n cursor: pointer;\n user-select: none;\n\n display: inline-flex;\n gap: 10px;\n align-items: center;\n\n font-size: var(--wui-font-size, 14px);\n line-height: 1;\n color: var(--wui-color-text, #1b1b1b);\n\n &:focus-visible {\n border-radius: calc(infinity * 1px);\n outline: 3px solid var(--wui-focus-ring, rgb(0 136 255 / 0.4));\n outline-offset: 2px;\n }\n}\n\n:host([disabled]) .wui-checkbox {\n cursor: not-allowed;\n color: var(--wui-color-text-muted, #6a6a6a);\n}\n\n.wui-checkbox-box {\n display: flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n\n width: 18px;\n height: 18px;\n border-radius: 6px;\n\n background-color: var(--wui-color-surface-raised, #f2f2f7);\n\n transition:\n background-color 0.2s ease,\n border-color 0.2s ease;\n}\n\n.is-checked .wui-checkbox-box {\n border-color: var(--wui-color-accent, #08f);\n background-color: var(--wui-color-accent, #08f);\n}\n\n.wui-checkbox-icon {\n transform: scale(0.85);\n\n overflow: hidden;\n display: block;\n\n font-size: 0;\n line-height: 0;\n\n opacity: 0;\n\n transition:\n opacity var(--wui-duration-fast, 160ms) ease,\n transform var(--wui-duration-fast, 160ms) var(--wui-ease-out, cubic-bezier(0.23, 1, 0.32, 1));\n}\n\n.is-checked .wui-checkbox-icon {\n transform: scale(1);\n opacity: 1;\n}\n\n.wui-checkbox-label {\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .wui-checkbox-icon,\n .is-checked .wui-checkbox-icon {\n transform: none;\n }\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class WebUiCheckboxGroup extends LitElement {
|
|
3
|
+
static styles: import('lit').CSSResult;
|
|
4
|
+
static formAssociated: boolean;
|
|
5
|
+
name: string;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
required: boolean;
|
|
8
|
+
private _value;
|
|
9
|
+
private _formDisabled;
|
|
10
|
+
private _internals?;
|
|
11
|
+
private _initialValue;
|
|
12
|
+
get value(): string[];
|
|
13
|
+
set value(v: string[]);
|
|
14
|
+
private get _isDisabled();
|
|
15
|
+
connectedCallback(): void;
|
|
16
|
+
disconnectedCallback(): void;
|
|
17
|
+
updated(changed: Map<string, unknown>): void;
|
|
18
|
+
formResetCallback(): void;
|
|
19
|
+
formDisabledCallback(disabled: boolean): void;
|
|
20
|
+
private _syncFormValue;
|
|
21
|
+
private _syncValidity;
|
|
22
|
+
private _syncValueToChildren;
|
|
23
|
+
private _handleChildChange;
|
|
24
|
+
private _handleSlotChange;
|
|
25
|
+
render(): import('lit').TemplateResult<1>;
|
|
26
|
+
readonly $events: {
|
|
27
|
+
input: Event;
|
|
28
|
+
change: Event;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
declare global {
|
|
32
|
+
interface HTMLElementTagNameMap {
|
|
33
|
+
'web-ui-checkbox-group': WebUiCheckboxGroup;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import e from "../../_virtual/_@oxc-project_runtime@0.140.0/helpers/esm/decorate.js";
|
|
2
|
+
import t from "./style.js";
|
|
3
|
+
import { LitElement as n, html as r, unsafeCSS as i } from "lit";
|
|
4
|
+
import { customElement as a, property as o, state as s } from "lit/decorators.js";
|
|
5
|
+
//#region src/components/checkbox-group/index.ts
|
|
6
|
+
var c = class extends n {
|
|
7
|
+
constructor(...e) {
|
|
8
|
+
super(...e), this.name = "", this.disabled = !1, this.required = !1, this._value = [], this._formDisabled = !1, this._initialValue = [];
|
|
9
|
+
}
|
|
10
|
+
static {
|
|
11
|
+
this.styles = i(t);
|
|
12
|
+
}
|
|
13
|
+
static {
|
|
14
|
+
this.formAssociated = !0;
|
|
15
|
+
}
|
|
16
|
+
get value() {
|
|
17
|
+
return this._value;
|
|
18
|
+
}
|
|
19
|
+
set value(e) {
|
|
20
|
+
let t = this._value;
|
|
21
|
+
this._value = [...e], this._syncFormValue(), this.requestUpdate("value", t);
|
|
22
|
+
}
|
|
23
|
+
get _isDisabled() {
|
|
24
|
+
return this.disabled || this._formDisabled;
|
|
25
|
+
}
|
|
26
|
+
connectedCallback() {
|
|
27
|
+
super.connectedCallback(), this._internals ||= this.attachInternals();
|
|
28
|
+
let e = this.getAttribute("value");
|
|
29
|
+
e !== null && (this.value = e.split(",").filter(Boolean)), this._initialValue = [...this._value], this.addEventListener("change", this._handleChildChange);
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
super.disconnectedCallback(), this.removeEventListener("change", this._handleChildChange);
|
|
33
|
+
}
|
|
34
|
+
updated(e) {
|
|
35
|
+
(e.has("value") || e.has("disabled") || e.has("_formDisabled")) && this._syncValueToChildren(), this._syncFormValue(), this._syncValidity();
|
|
36
|
+
}
|
|
37
|
+
formResetCallback() {
|
|
38
|
+
this.value = [...this._initialValue];
|
|
39
|
+
}
|
|
40
|
+
formDisabledCallback(e) {
|
|
41
|
+
this._formDisabled = e;
|
|
42
|
+
}
|
|
43
|
+
_syncFormValue() {
|
|
44
|
+
if (!this._internals) return;
|
|
45
|
+
if (!this.name || this._value.length === 0) {
|
|
46
|
+
this._internals.setFormValue?.(null);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let e = new FormData();
|
|
50
|
+
this._value.forEach((t) => e.append(this.name, t)), this._internals.setFormValue?.(e);
|
|
51
|
+
}
|
|
52
|
+
_syncValidity() {
|
|
53
|
+
if (!(!this._internals || typeof this._internals.setValidity != "function")) {
|
|
54
|
+
if (this._isDisabled || !this.required || this._value.length > 0) {
|
|
55
|
+
this._internals.setValidity({});
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this._internals.setValidity({ valueMissing: !0 }, "请至少选择一项");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
_syncValueToChildren() {
|
|
62
|
+
this.querySelectorAll("web-ui-checkbox").forEach((e) => {
|
|
63
|
+
e.checked = this._value.includes(e.value), e.setGroupDisabled(this._isDisabled);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
_handleChildChange(e) {
|
|
67
|
+
if (this._isDisabled) return;
|
|
68
|
+
let t = e.target;
|
|
69
|
+
if (!t.matches?.("web-ui-checkbox")) return;
|
|
70
|
+
let n = t, r = n.checked ? [.../* @__PURE__ */ new Set([...this._value, n.value])] : this._value.filter((e) => e !== n.value);
|
|
71
|
+
this.value = r, this.dispatchEvent(new Event("input", {
|
|
72
|
+
bubbles: !0,
|
|
73
|
+
composed: !0
|
|
74
|
+
})), this.dispatchEvent(new Event("change", {
|
|
75
|
+
bubbles: !0,
|
|
76
|
+
composed: !0
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
_handleSlotChange() {
|
|
80
|
+
this._syncValueToChildren();
|
|
81
|
+
}
|
|
82
|
+
render() {
|
|
83
|
+
return r`<div class="wui-checkbox-group"><slot @slotchange=${this._handleSlotChange}></slot></div>`;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
e([o({
|
|
87
|
+
type: String,
|
|
88
|
+
reflect: !0
|
|
89
|
+
})], c.prototype, "name", void 0), e([o({
|
|
90
|
+
type: Boolean,
|
|
91
|
+
reflect: !0
|
|
92
|
+
})], c.prototype, "disabled", void 0), e([o({
|
|
93
|
+
type: Boolean,
|
|
94
|
+
reflect: !0
|
|
95
|
+
})], c.prototype, "required", void 0), e([s()], c.prototype, "_value", void 0), e([s()], c.prototype, "_formDisabled", void 0), c = e([a("web-ui-checkbox-group")], c);
|
|
96
|
+
//#endregion
|
|
97
|
+
export { c as WebUiCheckboxGroup };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/checkbox-group/index.ts"],"sourcesContent":["import { html, LitElement, unsafeCSS } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport type { WebUiCheckbox } from '../checkbox'\n\nimport style from './style.css?inline'\n\n@customElement('web-ui-checkbox-group')\nexport class WebUiCheckboxGroup extends LitElement {\n static override styles = unsafeCSS(style)\n static formAssociated = true\n\n @property({ type: String, reflect: true }) name = ''\n @property({ type: Boolean, reflect: true }) disabled = false\n @property({ type: Boolean, reflect: true }) required = false\n\n @state() private _value: string[] = []\n @state() private _formDisabled = false\n private _internals?: ElementInternals\n private _initialValue: string[] = []\n\n get value(): string[] {\n return this._value\n }\n\n set value(v: string[]) {\n const old = this._value\n this._value = [...v]\n this._syncFormValue()\n this.requestUpdate('value', old)\n }\n\n private get _isDisabled(): boolean {\n return this.disabled || this._formDisabled\n }\n\n override connectedCallback() {\n super.connectedCallback()\n if (!this._internals) this._internals = this.attachInternals()\n const attributeValue = this.getAttribute('value')\n if (attributeValue !== null) this.value = attributeValue.split(',').filter(Boolean)\n this._initialValue = [...this._value]\n this.addEventListener('change', this._handleChildChange)\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback()\n this.removeEventListener('change', this._handleChildChange)\n }\n\n override updated(changed: Map<string, unknown>) {\n if (changed.has('value') || changed.has('disabled') || changed.has('_formDisabled')) this._syncValueToChildren()\n this._syncFormValue()\n this._syncValidity()\n }\n\n formResetCallback() {\n this.value = [...this._initialValue]\n }\n\n formDisabledCallback(disabled: boolean) {\n this._formDisabled = disabled\n }\n\n private _syncFormValue() {\n if (!this._internals) return\n if (!this.name || this._value.length === 0) {\n this._internals.setFormValue?.(null)\n return\n }\n const formData = new FormData()\n this._value.forEach(value => formData.append(this.name, value))\n this._internals.setFormValue?.(formData)\n }\n\n private _syncValidity() {\n if (!this._internals || typeof this._internals.setValidity !== 'function') return\n if (this._isDisabled || !this.required || this._value.length > 0) {\n this._internals.setValidity({})\n return\n }\n this._internals.setValidity({ valueMissing: true }, '请至少选择一项')\n }\n\n private _syncValueToChildren() {\n this.querySelectorAll<WebUiCheckbox>('web-ui-checkbox').forEach(checkbox => {\n checkbox.checked = this._value.includes(checkbox.value)\n checkbox.setGroupDisabled(this._isDisabled)\n })\n }\n\n private _handleChildChange(e: Event) {\n if (this._isDisabled) return\n const target = e.target as HTMLElement\n if (!target.matches?.('web-ui-checkbox')) return\n\n const checkbox = target as WebUiCheckbox\n const next = checkbox.checked\n ? [...new Set([...this._value, checkbox.value])]\n : this._value.filter(v => v !== checkbox.value)\n\n this.value = next\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }))\n this.dispatchEvent(new Event('change', { bubbles: true, composed: true }))\n }\n\n private _handleSlotChange() {\n this._syncValueToChildren()\n }\n\n override render() {\n return html`<div class=\"wui-checkbox-group\"><slot @slotchange=${this._handleSlotChange}></slot></div>`\n }\n\n declare readonly $events: {\n input: Event\n change: Event\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'web-ui-checkbox-group': WebUiCheckboxGroup\n }\n}\n"],"mappings":";;;;;AAQO,IAAM,IAAN,cAAiC,EAAW;;EAWf,aAPgB,KAAA,OAAA,IACK,KAAA,WAAA,IACA,KAAA,WAAA,IAEnB,KAAA,SAAA,CAAC,GACJ,KAAA,gBAAA,IAEC,KAAA,gBAAA,CAAC;;;EAVV,KAAA,SAAA,EAAU,CAAK;;;EAChB,KAAA,iBAAA;;CAWxB,IAAI,QAAkB;EACpB,OAAO,KAAK;CACd;CAEA,IAAI,MAAM,GAAa;EACrB,IAAM,IAAM,KAAK;EAGjB,AAFA,KAAK,SAAS,CAAC,GAAG,CAAC,GACnB,KAAK,eAAe,GACpB,KAAK,cAAc,SAAS,CAAG;CACjC;CAEA,IAAY,cAAuB;EACjC,OAAO,KAAK,YAAY,KAAK;CAC/B;CAEA,oBAA6B;EAE3B,AADA,MAAM,kBAAkB,GACxB,AAAsB,KAAK,eAAa,KAAK,gBAAgB;EAC7D,IAAM,IAAiB,KAAK,aAAa,OAAO;EAGhD,AAFI,MAAmB,SAAM,KAAK,QAAQ,EAAe,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,IAClF,KAAK,gBAAgB,CAAC,GAAG,KAAK,MAAM,GACpC,KAAK,iBAAiB,UAAU,KAAK,kBAAkB;CACzD;CAEA,uBAAgC;EAE9B,AADA,MAA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G,KAAK,QAAQ,EAAS,KAAK,CAAC,CAAC,IAC7C,KAAK,OAAO,QAAO,MAAK,MAAM,EAAS,KAAK;EAIhD,AAFA,KAAK,QAAQ,GACb,KAAK,cAAc,IAAI,MAAM,SAAS;GAAE,SAAS;GAAM,UAAU;EAAK,CAAC,CAAC,GACxE,KAAK,cAAc,IAAI,MAAM,UAAU;GAAE,SAAS;GAAM,UAAU;EAAK,CAAC,CAAC;CAC3E;CAEA,oBAA4B;EAC1B,KAAK,qBAAqB;CAC5B;CAEA,SAAkB;EAChB,OAAO,CAAI,qDAAqD,KAAK,kBAAkB;CACzF;AAMF;AA1GG,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,GACxC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,YAAA,KAAA,CAAA,GACzC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,YAAA,KAAA,CAAA,GAEzC,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,UAAA,KAAA,CAAA,GACN,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,iBAAA,KAAA,CAAA,GAVR,IAAA,EAAA,CAAA,EAAc,uBAAuB,CAAA,GAAA,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/components/checkbox-group/style.css?inline
|
|
2
|
+
var e = "*,:before,:after{box-sizing:border-box}:host{-webkit-user-select:none;user-select:none;flex-direction:column;gap:8px;display:inline-flex}.wui-checkbox-group{gap:inherit;flex-direction:column;display:flex}";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { e as default };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","names":[],"sources":["../../../src/components/checkbox-group/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n user-select: none;\n display: inline-flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.wui-checkbox-group {\n display: flex;\n flex-direction: column;\n gap: inherit;\n}\n"],"mappings":""}
|