vira 28.19.6 → 29.0.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/dist/elements/define-vira-element.d.ts +18 -0
- package/dist/elements/define-vira-element.js +19 -0
- package/dist/elements/form/vira-form-fields.d.ts +100 -0
- package/dist/elements/form/vira-form-fields.js +60 -0
- package/dist/elements/form/vira-form.element.d.ts +35 -0
- package/dist/elements/form/vira-form.element.js +151 -0
- package/dist/elements/index.js +25 -0
- package/dist/elements/pop-up/pop-up-helpers.d.ts +33 -0
- package/dist/elements/pop-up/pop-up-helpers.js +58 -0
- package/{src/elements/pop-up/pop-up-menu-item.ts → dist/elements/pop-up/pop-up-menu-item.d.ts} +3 -4
- package/dist/elements/pop-up/pop-up-menu-item.js +1 -0
- package/dist/elements/pop-up/vira-menu-item.element.d.ts +19 -0
- package/{src/elements/pop-up/vira-menu-item.element.ts → dist/elements/pop-up/vira-menu-item.element.js} +11 -28
- package/dist/elements/pop-up/vira-menu-trigger.element.d.ts +41 -0
- package/dist/elements/pop-up/vira-menu-trigger.element.js +121 -0
- package/dist/elements/pop-up/vira-menu.element.d.ts +38 -0
- package/{src/elements/pop-up/vira-menu.element.ts → dist/elements/pop-up/vira-menu.element.js} +49 -78
- package/dist/elements/pop-up/vira-pop-up-menu.element.d.ts +35 -0
- package/{src/elements/pop-up/vira-pop-up-menu.element.ts → dist/elements/pop-up/vira-pop-up-menu.element.js} +24 -37
- package/dist/elements/pop-up/vira-pop-up-trigger.element.d.ts +105 -0
- package/{src/elements/pop-up/vira-pop-up-trigger.element.ts → dist/elements/pop-up/vira-pop-up-trigger.element.js} +104 -199
- package/dist/elements/shared-text-input-logic.d.ts +63 -0
- package/dist/elements/shared-text-input-logic.js +101 -0
- package/dist/elements/vira-bold-text.element.d.ts +9 -0
- package/{src/elements/vira-bold-text.element.ts → dist/elements/vira-bold-text.element.js} +7 -8
- package/dist/elements/vira-button.element.d.ts +34 -0
- package/dist/elements/vira-button.element.js +176 -0
- package/dist/elements/vira-card.element.d.ts +18 -0
- package/dist/elements/vira-card.element.js +60 -0
- package/dist/elements/vira-checkbox.element.d.ts +38 -0
- package/{src/elements/vira-checkbox.element.ts → dist/elements/vira-checkbox.element.js} +70 -83
- package/dist/elements/vira-collapsible-wrapper.element.d.ts +14 -0
- package/{src/elements/vira-collapsible-wrapper.element.ts → dist/elements/vira-collapsible-wrapper.element.js} +16 -18
- package/dist/elements/vira-dropdown.element.d.ts +46 -0
- package/{src/elements/vira-dropdown.element.ts → dist/elements/vira-dropdown.element.js} +48 -95
- package/dist/elements/vira-error.element.d.ts +7 -0
- package/{src/elements/vira-error.element.ts → dist/elements/vira-error.element.js} +6 -7
- package/dist/elements/vira-icon.element.d.ts +13 -0
- package/{src/elements/vira-icon.element.ts → dist/elements/vira-icon.element.js} +6 -13
- package/dist/elements/vira-image.element.d.ts +45 -0
- package/{src/elements/vira-image.element.ts → dist/elements/vira-image.element.js} +43 -63
- package/dist/elements/vira-input.element.d.ts +62 -0
- package/{src/elements/vira-input.element.ts → dist/elements/vira-input.element.js} +93 -166
- package/dist/elements/vira-link.element.d.ts +73 -0
- package/{src/elements/vira-link.element.ts → dist/elements/vira-link.element.js} +17 -67
- package/dist/elements/vira-modal.element.d.ts +39 -0
- package/{src/elements/vira-modal.element.ts → dist/elements/vira-modal.element.js} +56 -97
- package/dist/elements/vira-overflow-switch.element.d.ts +21 -0
- package/dist/elements/vira-overflow-switch.element.js +110 -0
- package/dist/elements/vira-progress.element.d.ts +18 -0
- package/{src/elements/vira-progress.element.ts → dist/elements/vira-progress.element.js} +14 -30
- package/dist/elements/vira-select.element.d.ts +48 -0
- package/{src/elements/vira-select.element.ts → dist/elements/vira-select.element.js} +45 -99
- package/dist/icons/icon-color.test-helper.d.ts +6 -0
- package/dist/icons/icon-color.test-helper.js +9 -0
- package/dist/icons/icon-css-vars.d.ts +14 -0
- package/{src/icons/icon-css-vars.ts → dist/icons/icon-css-vars.js} +1 -2
- package/dist/icons/icon-svg.d.ts +27 -0
- package/dist/icons/icon-svg.js +48 -0
- package/dist/icons/icon-svgs/bell-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/bell-24.icon.ts → dist/icons/icon-svgs/bell-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/chat-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/chat-24.icon.ts → dist/icons/icon-svgs/chat-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/check-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/check-24.icon.ts → dist/icons/icon-svgs/check-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/chevron-down-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/chevron-down-24.icon.ts → dist/icons/icon-svgs/chevron-down-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/chevron-up-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/chevron-up-24.icon.ts → dist/icons/icon-svgs/chevron-up-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/close-x-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/close-x-24.icon.ts → dist/icons/icon-svgs/close-x-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/commit-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/commit-24.icon.ts → dist/icons/icon-svgs/commit-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/copy-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/copy-24.icon.ts → dist/icons/icon-svgs/copy-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/document-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/document-24.icon.ts → dist/icons/icon-svgs/document-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/document-search-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/document-search-24.icon.ts → dist/icons/icon-svgs/document-search-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/double-chevron-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/double-chevron-24.icon.ts → dist/icons/icon-svgs/double-chevron-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/element-16.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/element-16.icon.ts → dist/icons/icon-svgs/element-16.icon.js} +4 -5
- package/dist/icons/icon-svgs/element-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/element-24.icon.ts → dist/icons/icon-svgs/element-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/external-link-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/external-link-24.icon.ts → dist/icons/icon-svgs/external-link-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/eye-closed-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/eye-closed-24.icon.ts → dist/icons/icon-svgs/eye-closed-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/eye-open-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/eye-open-24.icon.ts → dist/icons/icon-svgs/eye-open-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/filter-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/filter-24.icon.ts → dist/icons/icon-svgs/filter-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/link-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/link-24.icon.ts → dist/icons/icon-svgs/link-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/loader-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/loader-24.icon.ts → dist/icons/icon-svgs/loader-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/loader-animated-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/loader-animated-24.icon.ts → dist/icons/icon-svgs/loader-animated-24.icon.js} +6 -8
- package/dist/icons/icon-svgs/lock-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/lock-24.icon.ts → dist/icons/icon-svgs/lock-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/options-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/options-24.icon.ts → dist/icons/icon-svgs/options-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/pencil-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/pencil-24.icon.ts → dist/icons/icon-svgs/pencil-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/shield-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/shield-24.icon.ts → dist/icons/icon-svgs/shield-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/sort-ascending-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/sort-ascending-24.icon.ts → dist/icons/icon-svgs/sort-ascending-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/sort-descending-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/sort-descending-24.icon.ts → dist/icons/icon-svgs/sort-descending-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-loud-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-loud-24.icon.ts → dist/icons/icon-svgs/speaker-loud-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-medium-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-medium-24.icon.ts → dist/icons/icon-svgs/speaker-medium-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-muted-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-muted-24.icon.ts → dist/icons/icon-svgs/speaker-muted-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-quiet-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-quiet-24.icon.ts → dist/icons/icon-svgs/speaker-quiet-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/star-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/star-24.icon.ts → dist/icons/icon-svgs/star-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-failure-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-failure-24.icon.ts → dist/icons/icon-svgs/status-failure-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-in-progress-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-in-progress-24.icon.ts → dist/icons/icon-svgs/status-in-progress-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-success-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-success-24.icon.ts → dist/icons/icon-svgs/status-success-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-unknown-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-unknown-24.icon.ts → dist/icons/icon-svgs/status-unknown-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-warning-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-warning-24.icon.ts → dist/icons/icon-svgs/status-warning-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/upload-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/upload-24.icon.ts → dist/icons/icon-svgs/upload-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/x-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/x-24.icon.ts → dist/icons/icon-svgs/x-24.icon.js} +4 -5
- package/dist/icons/index.d.ts +86 -0
- package/{src/icons/index.ts → dist/icons/index.js} +39 -43
- package/dist/index.js +4 -0
- package/dist/styles/disabled.d.ts +6 -0
- package/{src/styles/disabled.ts → dist/styles/disabled.js} +2 -3
- package/dist/styles/durations.d.ts +22 -0
- package/{src/styles/durations.ts → dist/styles/durations.js} +1 -2
- package/dist/styles/focus.d.ts +21 -0
- package/dist/styles/focus.js +41 -0
- package/dist/styles/font.d.ts +9 -0
- package/{src/styles/font.ts → dist/styles/font.js} +1 -2
- package/dist/styles/form-styles.d.ts +123 -0
- package/dist/styles/form-styles.js +126 -0
- package/{src/styles/index.ts → dist/styles/index.d.ts} +0 -2
- package/dist/styles/index.js +12 -0
- package/dist/styles/native-styles.d.ts +13 -0
- package/{src/styles/native-styles.ts → dist/styles/native-styles.js} +3 -6
- package/dist/styles/scrollbar.d.ts +6 -0
- package/{src/styles/scrollbar.ts → dist/styles/scrollbar.js} +3 -4
- package/dist/styles/shadows.d.ts +20 -0
- package/{src/styles/shadows.ts → dist/styles/shadows.js} +6 -8
- package/dist/styles/user-select.d.ts +6 -0
- package/{src/styles/user-select.ts → dist/styles/user-select.js} +2 -3
- package/dist/styles/vira-color-palette.d.ts +97 -0
- package/dist/styles/vira-color-palette.js +98 -0
- package/dist/styles/vira-color-theme.d.ts +1580 -0
- package/dist/styles/vira-color-theme.js +1516 -0
- package/dist/util/define-table.d.ts +110 -0
- package/dist/util/define-table.js +115 -0
- package/dist/util/dynamic-element.d.ts +63 -0
- package/dist/util/dynamic-element.js +61 -0
- package/dist/util/index.js +3 -0
- package/dist/util/pop-up-manager.d.ts +186 -0
- package/dist/util/pop-up-manager.js +214 -0
- package/package.json +6 -6
- package/src/elements/define-vira-element.ts +0 -29
- package/src/elements/form/vira-form-fields.ts +0 -140
- package/src/elements/form/vira-form.element.ts +0 -204
- package/src/elements/pop-up/pop-up-helpers.ts +0 -85
- package/src/elements/pop-up/vira-menu-trigger.element.ts +0 -158
- package/src/elements/shared-text-input-logic.ts +0 -173
- package/src/elements/vira-button.element.ts +0 -171
- package/src/elements/vira-card.element.ts +0 -54
- package/src/elements/vira-overflow-switch.element.ts +0 -137
- package/src/icons/icon-color.test-helper.ts +0 -9
- package/src/icons/icon-svg.ts +0 -71
- package/src/styles/border.ts +0 -11
- package/src/styles/focus.ts +0 -76
- package/src/styles/form-styles.ts +0 -26
- package/src/styles/vira-color-palette.ts +0 -106
- package/src/styles/vira-color-theme.ts +0 -1142
- package/src/util/define-table.ts +0 -279
- package/src/util/dynamic-element.ts +0 -129
- package/src/util/pop-up-manager.ts +0 -380
- /package/{src/elements/index.ts → dist/elements/index.d.ts} +0 -0
- /package/{src/index.ts → dist/index.d.ts} +0 -0
- /package/{src/util/index.ts → dist/util/index.d.ts} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type ViraIconSvg } from '../icons/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Button styles available for {@link ViraButton}.
|
|
5
|
+
*
|
|
6
|
+
* @category Button
|
|
7
|
+
*/
|
|
8
|
+
export declare enum ViraButtonStyle {
|
|
9
|
+
Default = "vira-button-default",
|
|
10
|
+
Outline = "vira-button-outline",
|
|
11
|
+
Danger = "vira-button-danger",
|
|
12
|
+
DangerOutline = "vira-button-danger-outline",
|
|
13
|
+
Ghost = "vira-button-ghost"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A custom button with default styling.
|
|
17
|
+
*
|
|
18
|
+
* @category Button
|
|
19
|
+
* @category Elements
|
|
20
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-button
|
|
21
|
+
*/
|
|
22
|
+
export declare const ViraButton: import("element-vir").DeclarativeElementDefinition<"vira-button", PartialWithUndefined<{
|
|
23
|
+
text: string;
|
|
24
|
+
icon: Pick<ViraIconSvg, "svgTemplate">;
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
buttonStyle: ViraButtonStyle;
|
|
27
|
+
/**
|
|
28
|
+
* When set to `true`, the given icon (if any) will take up its full dimensions, potentially
|
|
29
|
+
* increasing the button's size.
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
expandToFitIcon: boolean;
|
|
34
|
+
}>, {}, {}, "vira-button-outline-style" | "vira-button-danger-style" | "vira-button-ghost-style" | "vira-button-disabled" | "vira-button-expand-to-fit-icon" | "vira-button-icon-only" | "vira-button-default-style", "vira-button-padding" | "vira-button-internal-foreground-color" | "vira-button-internal-background-color", readonly [], readonly []>;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { css, html, nothing } from 'element-vir';
|
|
2
|
+
import { viraDisabledStyles } from '../styles/disabled.js';
|
|
3
|
+
import { viraAnimationDurations } from '../styles/durations.js';
|
|
4
|
+
import { createFocusStyles } from '../styles/focus.js';
|
|
5
|
+
import { viraFormCssVars } from '../styles/form-styles.js';
|
|
6
|
+
import { noUserSelect } from '../styles/index.js';
|
|
7
|
+
import { noNativeFormStyles } from '../styles/native-styles.js';
|
|
8
|
+
import { defineViraElement } from './define-vira-element.js';
|
|
9
|
+
import { ViraIcon } from './vira-icon.element.js';
|
|
10
|
+
/**
|
|
11
|
+
* Button styles available for {@link ViraButton}.
|
|
12
|
+
*
|
|
13
|
+
* @category Button
|
|
14
|
+
*/
|
|
15
|
+
export var ViraButtonStyle;
|
|
16
|
+
(function (ViraButtonStyle) {
|
|
17
|
+
ViraButtonStyle["Default"] = "vira-button-default";
|
|
18
|
+
ViraButtonStyle["Outline"] = "vira-button-outline";
|
|
19
|
+
ViraButtonStyle["Danger"] = "vira-button-danger";
|
|
20
|
+
ViraButtonStyle["DangerOutline"] = "vira-button-danger-outline";
|
|
21
|
+
ViraButtonStyle["Ghost"] = "vira-button-ghost";
|
|
22
|
+
})(ViraButtonStyle || (ViraButtonStyle = {}));
|
|
23
|
+
/**
|
|
24
|
+
* A custom button with default styling.
|
|
25
|
+
*
|
|
26
|
+
* @category Button
|
|
27
|
+
* @category Elements
|
|
28
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-button
|
|
29
|
+
*/
|
|
30
|
+
export const ViraButton = defineViraElement()({
|
|
31
|
+
tagName: 'vira-button',
|
|
32
|
+
hostClasses: {
|
|
33
|
+
'vira-button-outline-style': ({ inputs }) => inputs.buttonStyle === ViraButtonStyle.Outline ||
|
|
34
|
+
inputs.buttonStyle === ViraButtonStyle.DangerOutline,
|
|
35
|
+
'vira-button-danger-style': ({ inputs }) => inputs.buttonStyle === ViraButtonStyle.Danger ||
|
|
36
|
+
inputs.buttonStyle === ViraButtonStyle.DangerOutline,
|
|
37
|
+
'vira-button-ghost-style': ({ inputs }) => inputs.buttonStyle === ViraButtonStyle.Ghost,
|
|
38
|
+
'vira-button-disabled': ({ inputs }) => !!inputs.disabled,
|
|
39
|
+
'vira-button-expand-to-fit-icon': ({ inputs }) => !!inputs.expandToFitIcon,
|
|
40
|
+
'vira-button-icon-only': ({ inputs }) => !!inputs.icon && !inputs.text,
|
|
41
|
+
'vira-button-default-style': ({ inputs }) => !inputs.buttonStyle || inputs.buttonStyle === ViraButtonStyle.Default,
|
|
42
|
+
},
|
|
43
|
+
cssVars: {
|
|
44
|
+
'vira-button-padding': '5px 10px',
|
|
45
|
+
'vira-button-internal-foreground-color': 'transparent',
|
|
46
|
+
'vira-button-internal-background-color': 'transparent',
|
|
47
|
+
},
|
|
48
|
+
styles: ({ hostClasses, cssVars }) => css `
|
|
49
|
+
:host {
|
|
50
|
+
font-weight: bold;
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
position: relative;
|
|
53
|
+
vertical-align: middle;
|
|
54
|
+
align-items: center;
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
${noUserSelect};
|
|
57
|
+
${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-accent-primary-color'].value};
|
|
58
|
+
${cssVars['vira-button-internal-foreground-color'].name}: ${viraFormCssVars['vira-form-background-color'].value};
|
|
59
|
+
${viraFormCssVars['vira-form-focus-outline-color'].name}: ${viraFormCssVars['vira-form-accent-primary-hover-color'].value}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
${hostClasses['vira-button-disabled'].selector} {
|
|
63
|
+
${viraDisabledStyles};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:host(:hover) button,
|
|
67
|
+
button:hover {
|
|
68
|
+
${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-accent-primary-hover-color'].value};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host(:active) button,
|
|
72
|
+
button:active {
|
|
73
|
+
${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-accent-primary-active-color'].value};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
${hostClasses['vira-button-danger-style'].selector} {
|
|
77
|
+
& button {
|
|
78
|
+
${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-error-color'].value};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&:hover button,
|
|
82
|
+
& button:hover {
|
|
83
|
+
${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-error-hover-color'].value};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&:active button,
|
|
87
|
+
& button:active {
|
|
88
|
+
${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-error-active-color'].value};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
${hostClasses['vira-button-ghost-style'].selector} {
|
|
93
|
+
& button {
|
|
94
|
+
${cssVars['vira-button-internal-background-color'].name}: transparent;
|
|
95
|
+
${cssVars['vira-button-internal-foreground-color'].name}: currentColor;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&:hover button,
|
|
99
|
+
& button:hover {
|
|
100
|
+
${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-filled-background-color'].value};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&:active button,
|
|
104
|
+
& button:active {
|
|
105
|
+
${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-filled-active-background-color'].value};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
${hostClasses['vira-button-outline-style'].selector} button {
|
|
110
|
+
color: ${cssVars['vira-button-internal-background-color'].value};
|
|
111
|
+
background-color: ${cssVars['vira-button-internal-foreground-color'].value};
|
|
112
|
+
border-color: currentColor;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
button {
|
|
116
|
+
${noNativeFormStyles};
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
position: relative;
|
|
119
|
+
width: 100%;
|
|
120
|
+
height: 100%;
|
|
121
|
+
border: 2px solid transparent;
|
|
122
|
+
box-sizing: border-box;
|
|
123
|
+
display: inline-flex;
|
|
124
|
+
justify-content: center;
|
|
125
|
+
align-items: center;
|
|
126
|
+
border-radius: ${viraFormCssVars['vira-form-radius'].value};
|
|
127
|
+
background-color: ${cssVars['vira-button-internal-background-color'].value};
|
|
128
|
+
color: ${cssVars['vira-button-internal-foreground-color'].value};
|
|
129
|
+
padding: ${cssVars['vira-button-padding'].value};
|
|
130
|
+
transition:
|
|
131
|
+
color ${viraAnimationDurations['vira-interaction-animation-duration'].value},
|
|
132
|
+
background-color
|
|
133
|
+
${viraAnimationDurations['vira-interaction-animation-duration'].value},
|
|
134
|
+
border-color ${viraAnimationDurations['vira-interaction-animation-duration'].value};
|
|
135
|
+
|
|
136
|
+
${createFocusStyles({
|
|
137
|
+
elementBorderSize: 2,
|
|
138
|
+
})}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.empty-text {
|
|
142
|
+
width: 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
button ${ViraIcon} + .text-template {
|
|
146
|
+
margin-left: 8px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
:host(:not(.${hostClasses['vira-button-expand-to-fit-icon'].name})) {
|
|
150
|
+
& ${ViraIcon} {
|
|
151
|
+
height: 0;
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
`,
|
|
157
|
+
render: ({ inputs }) => {
|
|
158
|
+
const iconTemplate = inputs.icon
|
|
159
|
+
? html `
|
|
160
|
+
<${ViraIcon.assign({
|
|
161
|
+
icon: inputs.icon,
|
|
162
|
+
})}></${ViraIcon}>
|
|
163
|
+
`
|
|
164
|
+
: nothing;
|
|
165
|
+
const textTemplate = inputs.text
|
|
166
|
+
? html `
|
|
167
|
+
<span class="text-template">${inputs.text}</span>
|
|
168
|
+
`
|
|
169
|
+
: html `
|
|
170
|
+
<span class="empty-text"> </span>
|
|
171
|
+
`;
|
|
172
|
+
return html `
|
|
173
|
+
<button ?disabled=${inputs.disabled}>${iconTemplate} ${textTemplate}</button>
|
|
174
|
+
`;
|
|
175
|
+
},
|
|
176
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State options for {@link ViraCard}.
|
|
3
|
+
*
|
|
4
|
+
* @category Internal
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ViraCardState {
|
|
7
|
+
Error = "error",
|
|
8
|
+
Success = "success"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A simple wrapper "card" element that is just a `<slot>` with some styles.
|
|
12
|
+
*
|
|
13
|
+
* @category Elements
|
|
14
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-card
|
|
15
|
+
*/
|
|
16
|
+
export declare const ViraCard: import("element-vir").DeclarativeElementDefinition<"vira-card", {
|
|
17
|
+
cardState?: ViraCardState | undefined;
|
|
18
|
+
}, {}, {}, "vira-card-error" | "vira-card-success", "vira-card-border" | "vira-card-padding", readonly [], readonly []>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { css, html } from 'element-vir';
|
|
2
|
+
import { CssVarSyntaxName } from 'lit-css-vars';
|
|
3
|
+
import { viraFormCssVars } from '../styles/form-styles.js';
|
|
4
|
+
import { defineViraElement } from './define-vira-element.js';
|
|
5
|
+
/**
|
|
6
|
+
* State options for {@link ViraCard}.
|
|
7
|
+
*
|
|
8
|
+
* @category Internal
|
|
9
|
+
*/
|
|
10
|
+
export var ViraCardState;
|
|
11
|
+
(function (ViraCardState) {
|
|
12
|
+
ViraCardState["Error"] = "error";
|
|
13
|
+
ViraCardState["Success"] = "success";
|
|
14
|
+
})(ViraCardState || (ViraCardState = {}));
|
|
15
|
+
/**
|
|
16
|
+
* A simple wrapper "card" element that is just a `<slot>` with some styles.
|
|
17
|
+
*
|
|
18
|
+
* @category Elements
|
|
19
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-card
|
|
20
|
+
*/
|
|
21
|
+
export const ViraCard = defineViraElement()({
|
|
22
|
+
tagName: 'vira-card',
|
|
23
|
+
hostClasses: {
|
|
24
|
+
'vira-card-error': ({ inputs }) => inputs.cardState === ViraCardState.Error,
|
|
25
|
+
'vira-card-success': ({ inputs }) => inputs.cardState === ViraCardState.Success,
|
|
26
|
+
},
|
|
27
|
+
cssVars: {
|
|
28
|
+
'vira-card-border': {
|
|
29
|
+
default: css `1px solid ${viraFormCssVars['vira-form-border-color'].value}`,
|
|
30
|
+
initialValue: 'none',
|
|
31
|
+
},
|
|
32
|
+
'vira-card-padding': {
|
|
33
|
+
default: css `
|
|
34
|
+
${viraFormCssVars['vira-form-wrapper-radius'].value}
|
|
35
|
+
`,
|
|
36
|
+
initialValue: '16px',
|
|
37
|
+
syntax: CssVarSyntaxName.Length,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
styles: ({ hostClasses, cssVars }) => css `
|
|
41
|
+
:host {
|
|
42
|
+
display: block;
|
|
43
|
+
border: ${cssVars['vira-card-border'].value};
|
|
44
|
+
border-radius: ${viraFormCssVars['vira-form-wrapper-radius'].value};
|
|
45
|
+
padding: ${cssVars['vira-card-padding'].value};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
${hostClasses['vira-card-error'].selector} {
|
|
49
|
+
border-color: ${viraFormCssVars['vira-form-error-color'].value};
|
|
50
|
+
}
|
|
51
|
+
${hostClasses['vira-card-success'].selector} {
|
|
52
|
+
border-color: ${viraFormCssVars['vira-form-success-color'].value};
|
|
53
|
+
}
|
|
54
|
+
`,
|
|
55
|
+
render() {
|
|
56
|
+
return html `
|
|
57
|
+
<slot></slot>
|
|
58
|
+
`;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type AttributeValues, type CSSResult } from 'element-vir';
|
|
3
|
+
import { ViraIcon } from './vira-icon.element.js';
|
|
4
|
+
/**
|
|
5
|
+
* All inner elements supported by {@link ViraCheckbox}.
|
|
6
|
+
*
|
|
7
|
+
* @category Internals
|
|
8
|
+
*/
|
|
9
|
+
export type ViraCheckboxInnerElements = 'label' | 'custom-checkbox' | 'text' | typeof ViraIcon.tagName;
|
|
10
|
+
/**
|
|
11
|
+
* Inputs for {@link ViraCheckbox}.
|
|
12
|
+
*
|
|
13
|
+
* @category Internal
|
|
14
|
+
*/
|
|
15
|
+
export type ViraCheckboxInputs = {
|
|
16
|
+
value: boolean;
|
|
17
|
+
} & PartialWithUndefined<{
|
|
18
|
+
stylePassthrough: Partial<Record<ViraCheckboxInnerElements, CSSResult>>;
|
|
19
|
+
attributePassthrough: Partial<Record<ViraCheckboxInnerElements, AttributeValues>>;
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
label: string;
|
|
22
|
+
hasError: boolean;
|
|
23
|
+
horizontal: boolean;
|
|
24
|
+
/** The checkbox will be filled with a form selection color when it is checked. */
|
|
25
|
+
fillWhenChecked: boolean;
|
|
26
|
+
/** The checkbox will be filled with a form error color when it is unchecked. */
|
|
27
|
+
fillWhenUnchecked: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* A custom checkbox.
|
|
31
|
+
*
|
|
32
|
+
* @category Input
|
|
33
|
+
* @category Elements
|
|
34
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-checkbox
|
|
35
|
+
*/
|
|
36
|
+
export declare const ViraCheckbox: import("element-vir").DeclarativeElementDefinition<"vira-checkbox", Readonly<ViraCheckboxInputs>, {}, {
|
|
37
|
+
valueChange: import("element-vir").DefineEvent<boolean>;
|
|
38
|
+
}, "vira-checkbox-horizontal" | "vira-checkbox-filled-checked" | "vira-checkbox-filled-unchecked", "vira-checkbox-", readonly [], readonly []>;
|
|
@@ -1,52 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ifDefined,
|
|
9
|
-
listen,
|
|
10
|
-
listenToActivate,
|
|
11
|
-
nothing,
|
|
12
|
-
type AttributeValues,
|
|
13
|
-
type CSSResult,
|
|
14
|
-
} from 'element-vir';
|
|
15
|
-
import {Check24Icon, viraIconCssVars} from '../icons/index.js';
|
|
16
|
-
import {viraBorders} from '../styles/border.js';
|
|
17
|
-
import {viraDisabledStyles} from '../styles/disabled.js';
|
|
18
|
-
import {createFocusStyles} from '../styles/focus.js';
|
|
19
|
-
import {viraFormCssVars} from '../styles/form-styles.js';
|
|
20
|
-
import {defineViraElement} from './define-vira-element.js';
|
|
21
|
-
import {ViraIcon} from './vira-icon.element.js';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* All inner elements supported by {@link ViraCheckbox}.
|
|
25
|
-
*
|
|
26
|
-
* @category Internals
|
|
27
|
-
*/
|
|
28
|
-
export type ViraCheckboxInnerElements =
|
|
29
|
-
| 'label'
|
|
30
|
-
| 'custom-checkbox'
|
|
31
|
-
| 'text'
|
|
32
|
-
| typeof ViraIcon.tagName;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Inputs for {@link ViraCheckbox}.
|
|
36
|
-
*
|
|
37
|
-
* @category Internal
|
|
38
|
-
*/
|
|
39
|
-
export type ViraCheckboxInputs = PartialWithUndefined<{
|
|
40
|
-
stylePassthrough: Partial<Record<ViraCheckboxInnerElements, CSSResult>>;
|
|
41
|
-
attributePassthrough: Partial<Record<ViraCheckboxInnerElements, AttributeValues>>;
|
|
42
|
-
disabled: boolean;
|
|
43
|
-
label: string;
|
|
44
|
-
hasError: boolean;
|
|
45
|
-
horizontal: boolean;
|
|
46
|
-
}> & {
|
|
47
|
-
value: boolean;
|
|
48
|
-
};
|
|
49
|
-
|
|
1
|
+
import { attributes, classMap, css, defineElementEvent, html, ifDefined, listen, listenToActivate, nothing, } from 'element-vir';
|
|
2
|
+
import { Check24Icon, viraIconCssVars } from '../icons/index.js';
|
|
3
|
+
import { viraDisabledStyles } from '../styles/disabled.js';
|
|
4
|
+
import { createFocusStyles } from '../styles/focus.js';
|
|
5
|
+
import { viraFormCssVars } from '../styles/form-styles.js';
|
|
6
|
+
import { defineViraElement } from './define-vira-element.js';
|
|
7
|
+
import { ViraIcon } from './vira-icon.element.js';
|
|
50
8
|
/**
|
|
51
9
|
* A custom checkbox.
|
|
52
10
|
*
|
|
@@ -54,12 +12,14 @@ export type ViraCheckboxInputs = PartialWithUndefined<{
|
|
|
54
12
|
* @category Elements
|
|
55
13
|
* @see https://electrovir.github.io/vira/book/elements/vira-checkbox
|
|
56
14
|
*/
|
|
57
|
-
export const ViraCheckbox = defineViraElement
|
|
15
|
+
export const ViraCheckbox = defineViraElement()({
|
|
58
16
|
tagName: 'vira-checkbox',
|
|
59
17
|
hostClasses: {
|
|
60
|
-
'vira-checkbox-horizontal': ({inputs}) => !!inputs.horizontal,
|
|
18
|
+
'vira-checkbox-horizontal': ({ inputs }) => !!inputs.horizontal,
|
|
19
|
+
'vira-checkbox-filled-checked': ({ inputs }) => !!inputs.fillWhenChecked,
|
|
20
|
+
'vira-checkbox-filled-unchecked': ({ inputs }) => !!inputs.fillWhenUnchecked,
|
|
61
21
|
},
|
|
62
|
-
styles: ({hostClasses}) => css`
|
|
22
|
+
styles: ({ hostClasses }) => css `
|
|
63
23
|
:host {
|
|
64
24
|
display: inline-flex;
|
|
65
25
|
}
|
|
@@ -74,6 +34,43 @@ export const ViraCheckbox = defineViraElement<Readonly<ViraCheckboxInputs>>()({
|
|
|
74
34
|
width: 100%;
|
|
75
35
|
height: 100%;
|
|
76
36
|
box-sizing: border-box;
|
|
37
|
+
${viraIconCssVars['vira-icon-stroke-width'].name}: 3px;
|
|
38
|
+
opacity: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
${hostClasses['vira-checkbox-filled-checked'].selector} {
|
|
42
|
+
& .custom-checkbox.checked {
|
|
43
|
+
color: ${viraFormCssVars['vira-form-background-color'].value};
|
|
44
|
+
background-color: ${viraFormCssVars['vira-form-accent-primary-color'].value};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
label {
|
|
48
|
+
&:hover .custom-checkbox.checked {
|
|
49
|
+
background-color: ${viraFormCssVars['vira-form-accent-primary-hover-color']
|
|
50
|
+
.value};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&:active .custom-checkbox.checked {
|
|
54
|
+
background-color: ${viraFormCssVars['vira-form-accent-primary-active-color']
|
|
55
|
+
.value};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
${hostClasses['vira-checkbox-filled-unchecked'].selector} {
|
|
60
|
+
& .custom-checkbox:not(.checked) {
|
|
61
|
+
color: ${viraFormCssVars['vira-form-background-color'].value};
|
|
62
|
+
background-color: ${viraFormCssVars['vira-form-error-color'].value};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
label {
|
|
66
|
+
&:hover .custom-checkbox:not(.checked) {
|
|
67
|
+
background-color: ${viraFormCssVars['vira-form-error-hover-color'].value};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&:active .custom-checkbox:not(.checked) {
|
|
71
|
+
background-color: ${viraFormCssVars['vira-form-error-active-color'].value};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
label {
|
|
@@ -92,14 +89,11 @@ export const ViraCheckbox = defineViraElement<Readonly<ViraCheckboxInputs>>()({
|
|
|
92
89
|
}
|
|
93
90
|
|
|
94
91
|
&:hover .custom-checkbox {
|
|
95
|
-
background-color: ${viraFormCssVars['vira-form-selection-hover-
|
|
96
|
-
|
|
92
|
+
background-color: ${viraFormCssVars['vira-form-selection-hover-color'].value};
|
|
93
|
+
}
|
|
94
|
+
&:active .custom-checkbox {
|
|
95
|
+
background-color: ${viraFormCssVars['vira-form-selection-active-color'].value};
|
|
97
96
|
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
${ViraIcon} {
|
|
101
|
-
${viraIconCssVars['vira-icon-stroke-width'].name}: 2px;
|
|
102
|
-
opacity: 0;
|
|
103
97
|
}
|
|
104
98
|
|
|
105
99
|
/* The visible custom box */
|
|
@@ -107,12 +101,12 @@ export const ViraCheckbox = defineViraElement<Readonly<ViraCheckboxInputs>>()({
|
|
|
107
101
|
flex-shrink: 0;
|
|
108
102
|
border: 1px solid ${viraFormCssVars['vira-form-border-color'].value};
|
|
109
103
|
color: ${viraFormCssVars['vira-form-foreground-color'].value};
|
|
110
|
-
border-radius: ${
|
|
104
|
+
border-radius: ${viraFormCssVars['vira-form-radius'].value};
|
|
111
105
|
display: inline-block;
|
|
112
106
|
position: relative;
|
|
113
107
|
cursor: pointer;
|
|
114
108
|
|
|
115
|
-
${createFocusStyles({elementBorderSize: 1})}
|
|
109
|
+
${createFocusStyles({ elementBorderSize: 1 })}
|
|
116
110
|
|
|
117
111
|
&.checked {
|
|
118
112
|
& ${ViraIcon} {
|
|
@@ -121,12 +115,7 @@ export const ViraCheckbox = defineViraElement<Readonly<ViraCheckboxInputs>>()({
|
|
|
121
115
|
}
|
|
122
116
|
|
|
123
117
|
&.error {
|
|
124
|
-
border-color: ${viraFormCssVars['vira-form-error-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
&:active {
|
|
128
|
-
background-color: ${viraFormCssVars['vira-form-selection-active-background-color']
|
|
129
|
-
.value};
|
|
118
|
+
border-color: ${viraFormCssVars['vira-form-error-color'].value};
|
|
130
119
|
}
|
|
131
120
|
|
|
132
121
|
&.disabled {
|
|
@@ -141,17 +130,16 @@ export const ViraCheckbox = defineViraElement<Readonly<ViraCheckboxInputs>>()({
|
|
|
141
130
|
}
|
|
142
131
|
`,
|
|
143
132
|
events: {
|
|
144
|
-
valueChange: defineElementEvent
|
|
133
|
+
valueChange: defineElementEvent(),
|
|
145
134
|
},
|
|
146
|
-
render({inputs, dispatch, events}) {
|
|
147
|
-
function updateValue(
|
|
135
|
+
render({ inputs, dispatch, events }) {
|
|
136
|
+
function updateValue() {
|
|
148
137
|
if (!inputs.disabled) {
|
|
149
138
|
dispatch(new events.valueChange(!inputs.value));
|
|
150
139
|
}
|
|
151
140
|
}
|
|
152
|
-
|
|
153
141
|
const textLabel = inputs.label
|
|
154
|
-
? html`
|
|
142
|
+
? html `
|
|
155
143
|
<span
|
|
156
144
|
class="label-text"
|
|
157
145
|
${attributes(inputs.attributePassthrough?.['text'])}
|
|
@@ -161,12 +149,11 @@ export const ViraCheckbox = defineViraElement<Readonly<ViraCheckboxInputs>>()({
|
|
|
161
149
|
</span>
|
|
162
150
|
`
|
|
163
151
|
: nothing;
|
|
164
|
-
|
|
165
|
-
return html`
|
|
152
|
+
return html `
|
|
166
153
|
<label
|
|
167
154
|
class=${classMap({
|
|
168
|
-
|
|
169
|
-
|
|
155
|
+
disabled: !!inputs.disabled,
|
|
156
|
+
})}
|
|
170
157
|
${attributes(inputs.attributePassthrough?.label)}
|
|
171
158
|
style=${ifDefined(inputs.stylePassthrough?.label)}
|
|
172
159
|
${listen('mousedown', updateValue)}
|
|
@@ -174,10 +161,10 @@ export const ViraCheckbox = defineViraElement<Readonly<ViraCheckboxInputs>>()({
|
|
|
174
161
|
${textLabel}
|
|
175
162
|
<span
|
|
176
163
|
class="custom-checkbox ${classMap({
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
164
|
+
checked: inputs.value,
|
|
165
|
+
disabled: !!inputs.disabled,
|
|
166
|
+
error: !!inputs.hasError,
|
|
167
|
+
})}"
|
|
181
168
|
role="checkbox"
|
|
182
169
|
aria-label=${ifDefined(inputs.label || undefined)}
|
|
183
170
|
aria-checked=${inputs.value ? 'true' : 'false'}
|
|
@@ -188,9 +175,9 @@ export const ViraCheckbox = defineViraElement<Readonly<ViraCheckboxInputs>>()({
|
|
|
188
175
|
${listenToActivate(updateValue)}
|
|
189
176
|
>
|
|
190
177
|
<${ViraIcon.assign({
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
178
|
+
icon: Check24Icon,
|
|
179
|
+
fitContainer: true,
|
|
180
|
+
})}
|
|
194
181
|
${attributes(inputs.attributePassthrough?.[ViraIcon.tagName])}
|
|
195
182
|
style=${ifDefined(inputs.stylePassthrough?.[ViraIcon.tagName])}
|
|
196
183
|
></${ViraIcon}>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A wrapper element that can collapse and expand to fit its content dynamically and efficiently.
|
|
3
|
+
*
|
|
4
|
+
* @category Collapsible
|
|
5
|
+
* @category Elements
|
|
6
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-collapsible-wrapper
|
|
7
|
+
*/
|
|
8
|
+
export declare const ViraCollapsibleWrapper: import("element-vir").DeclarativeElementDefinition<"vira-collapsible-wrapper", {
|
|
9
|
+
expanded: boolean;
|
|
10
|
+
}, {
|
|
11
|
+
contentHeight: number;
|
|
12
|
+
}, {
|
|
13
|
+
expandChange: import("element-vir").DefineEvent<boolean>;
|
|
14
|
+
}, "vira-collapsible-wrapper-expanded", "vira-collapsible-wrapper-", readonly ["header"], readonly []>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {css, defineElementEvent, html, listen, onResize} from 'element-vir';
|
|
2
|
-
import {noNativeFormStyles, viraAnimationDurations} from '../styles/index.js';
|
|
3
|
-
import {defineViraElement} from './define-vira-element.js';
|
|
4
|
-
|
|
1
|
+
import { css, defineElementEvent, html, listen, onResize } from 'element-vir';
|
|
2
|
+
import { noNativeFormStyles, viraAnimationDurations } from '../styles/index.js';
|
|
3
|
+
import { defineViraElement } from './define-vira-element.js';
|
|
5
4
|
/**
|
|
6
5
|
* A wrapper element that can collapse and expand to fit its content dynamically and efficiently.
|
|
7
6
|
*
|
|
@@ -9,7 +8,7 @@ import {defineViraElement} from './define-vira-element.js';
|
|
|
9
8
|
* @category Elements
|
|
10
9
|
* @see https://electrovir.github.io/vira/book/elements/vira-collapsible-wrapper
|
|
11
10
|
*/
|
|
12
|
-
export const ViraCollapsibleWrapper = defineViraElement
|
|
11
|
+
export const ViraCollapsibleWrapper = defineViraElement()({
|
|
13
12
|
tagName: 'vira-collapsible-wrapper',
|
|
14
13
|
state() {
|
|
15
14
|
return {
|
|
@@ -17,10 +16,10 @@ export const ViraCollapsibleWrapper = defineViraElement<{expanded: boolean}>()({
|
|
|
17
16
|
};
|
|
18
17
|
},
|
|
19
18
|
hostClasses: {
|
|
20
|
-
'vira-collapsible-wrapper-expanded': ({inputs}) => inputs.expanded,
|
|
19
|
+
'vira-collapsible-wrapper-expanded': ({ inputs }) => inputs.expanded,
|
|
21
20
|
},
|
|
22
21
|
slotNames: ['header'],
|
|
23
|
-
styles: ({hostClasses}) => css`
|
|
22
|
+
styles: ({ hostClasses }) => css `
|
|
24
23
|
:host {
|
|
25
24
|
display: flex;
|
|
26
25
|
flex-direction: column;
|
|
@@ -47,32 +46,31 @@ export const ViraCollapsibleWrapper = defineViraElement<{expanded: boolean}>()({
|
|
|
47
46
|
}
|
|
48
47
|
`,
|
|
49
48
|
events: {
|
|
50
|
-
expandChange: defineElementEvent
|
|
49
|
+
expandChange: defineElementEvent(),
|
|
51
50
|
},
|
|
52
|
-
render({state, slotNames, updateState, dispatch, events, inputs}) {
|
|
51
|
+
render({ state, slotNames, updateState, dispatch, events, inputs }) {
|
|
53
52
|
const collapsingStyles = inputs.expanded
|
|
54
|
-
? css`
|
|
53
|
+
? css `
|
|
55
54
|
height: ${state.contentHeight}px;
|
|
56
55
|
`
|
|
57
|
-
: css`
|
|
56
|
+
: css `
|
|
58
57
|
height: 0;
|
|
59
58
|
`;
|
|
60
|
-
|
|
61
|
-
return html`
|
|
59
|
+
return html `
|
|
62
60
|
<button
|
|
63
61
|
class="header-wrapper"
|
|
64
62
|
${listen('click', () => {
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
dispatch(new events.expandChange(!inputs.expanded));
|
|
64
|
+
})}
|
|
67
65
|
>
|
|
68
66
|
<slot name=${slotNames.header}>Header</slot>
|
|
69
67
|
</button>
|
|
70
68
|
|
|
71
69
|
<div class="collapsing-element" style=${collapsingStyles} disabled="disabled">
|
|
72
70
|
<div
|
|
73
|
-
${onResize(({contentRect}) => {
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
${onResize(({ contentRect }) => {
|
|
72
|
+
updateState({ contentHeight: contentRect.height });
|
|
73
|
+
})}
|
|
76
74
|
class="content-wrapper"
|
|
77
75
|
>
|
|
78
76
|
<slot></slot>
|