vira 2.3.1 → 2.4.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/element-book/all-element-book-entries.js +2 -0
- package/dist/elements/common/shared-text-input-logic.d.ts +1 -2
- package/dist/elements/index.d.ts +1 -0
- package/dist/elements/index.js +1 -0
- package/dist/elements/vira-button/vira-button.element.js +2 -1
- package/dist/elements/vira-image/vira-image.element.d.ts +42 -0
- package/dist/elements/vira-image/vira-image.element.js +133 -0
- package/dist/elements/vira-input/vira-input.element.d.ts +1 -0
- package/dist/elements/vira-input/vira-input.element.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/styles/focus.js +1 -2
- package/dist/util/dimensions.d.ts +4 -0
- package/dist/util/dimensions.js +1 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.js +1 -0
- package/package.json +28 -21
|
@@ -2,6 +2,7 @@ import { elementsBookPage } from '../elements/elements.book';
|
|
|
2
2
|
import { viraButtonBookPage } from '../elements/vira-button/vira-button.element.book';
|
|
3
3
|
import { viraCollapsibleBookPage } from '../elements/vira-collapsible/vira-collapsible-wrapper.element.book';
|
|
4
4
|
import { viraIconBookPage } from '../elements/vira-icon/vira-icon.element.book';
|
|
5
|
+
import { viraImageBookPage } from '../elements/vira-image/vira-image.element.book';
|
|
5
6
|
import { viraInputBookPage } from '../elements/vira-input/vira-input.element.book';
|
|
6
7
|
import { viraLinkBookPage } from '../elements/vira-link/vira-link.element.book';
|
|
7
8
|
import { iconsBookPage } from '../icons/icons.book';
|
|
@@ -11,6 +12,7 @@ export const allElementBookEntries = [
|
|
|
11
12
|
viraButtonBookPage,
|
|
12
13
|
viraCollapsibleBookPage,
|
|
13
14
|
viraIconBookPage,
|
|
15
|
+
viraImageBookPage,
|
|
14
16
|
viraInputBookPage,
|
|
15
17
|
viraLinkBookPage,
|
|
16
18
|
];
|
|
@@ -19,7 +19,7 @@ export type SharedTextInputElementInputs = {
|
|
|
19
19
|
/** Set this to true to make the whole element size to only fit the input text. */
|
|
20
20
|
fitText?: boolean;
|
|
21
21
|
};
|
|
22
|
-
type IsAllowedInputs = {
|
|
22
|
+
export type IsAllowedInputs = {
|
|
23
23
|
value: string;
|
|
24
24
|
allowed: string | RegExp | undefined;
|
|
25
25
|
blocked: string | RegExp | undefined;
|
|
@@ -35,4 +35,3 @@ export declare function textInputListener({ inputs, filteredValue, event, inputB
|
|
|
35
35
|
inputBlockedCallback: (blockedInput: string) => void;
|
|
36
36
|
newValueCallback: (newValue: string) => void;
|
|
37
37
|
}): void;
|
|
38
|
-
export {};
|
package/dist/elements/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export * from './define-vira-element';
|
|
|
3
3
|
export * from './vira-button/vira-button.element';
|
|
4
4
|
export * from './vira-collapsible/vira-collapsible-wrapper.element';
|
|
5
5
|
export * from './vira-icon/vira-icon.element';
|
|
6
|
+
export * from './vira-image/vira-image.element';
|
|
6
7
|
export * from './vira-input/vira-input.element';
|
|
7
8
|
export * from './vira-link/vira-link.element';
|
package/dist/elements/index.js
CHANGED
|
@@ -3,5 +3,6 @@ export * from './define-vira-element';
|
|
|
3
3
|
export * from './vira-button/vira-button.element';
|
|
4
4
|
export * from './vira-collapsible/vira-collapsible-wrapper.element';
|
|
5
5
|
export * from './vira-icon/vira-icon.element';
|
|
6
|
+
export * from './vira-image/vira-image.element';
|
|
6
7
|
export * from './vira-input/vira-input.element';
|
|
7
8
|
export * from './vira-link/vira-link.element';
|
|
@@ -79,7 +79,8 @@ export const ViraButton = defineViraElement()({
|
|
|
79
79
|
background-color: ${cssVars['vira-button-internal-background-color'].value};
|
|
80
80
|
color: ${cssVars['vira-button-internal-foreground-color'].value};
|
|
81
81
|
padding: ${cssVars['vira-button-padding'].value};
|
|
82
|
-
transition:
|
|
82
|
+
transition:
|
|
83
|
+
color ${viraAnimationDurations['vira-interaction-animation-duration'].value},
|
|
83
84
|
background-color
|
|
84
85
|
${viraAnimationDurations['vira-interaction-animation-duration'].value},
|
|
85
86
|
border-color ${viraAnimationDurations['vira-interaction-animation-duration'].value};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Duration, DurationUnit } from 'date-vir';
|
|
2
|
+
import { Dimensions } from '../../util/dimensions';
|
|
3
|
+
export declare enum ViraImageSlotNameEnum {
|
|
4
|
+
Loading = "loading",
|
|
5
|
+
Error = "error"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* An `<img>` element wrapper that handles size constraints and includes slots for loading and error
|
|
9
|
+
* indicators.
|
|
10
|
+
*
|
|
11
|
+
* Use CSS properties to constrain the image. In particular, set `min-height` and `min-width` on
|
|
12
|
+
* this to control the size of the loader and error slots.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ViraImage: import("element-vir").DeclarativeElementDefinition<"vira-image", {
|
|
15
|
+
/** The URL of the image to load. This is passed directly to the `<img>` element. */
|
|
16
|
+
imageUrl: string;
|
|
17
|
+
/**
|
|
18
|
+
* The dimension which should dominantly constrain the image size. Whichever dimension this is
|
|
19
|
+
* set to is the dimension that the image will grow to match. This is only relevant if you apply
|
|
20
|
+
* size constraints on ViraImage via CSS in its parent.
|
|
21
|
+
*
|
|
22
|
+
* @default 'width'
|
|
23
|
+
*/
|
|
24
|
+
dominantDimension?: keyof Dimensions | undefined;
|
|
25
|
+
/** For debugging only: artificially set a delay for the image loading so you can see the loader. */
|
|
26
|
+
_debugLoadDelay?: Duration<DurationUnit.Milliseconds> | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
/**
|
|
29
|
+
* To avoid race conditions between `<img>` element events and potential input changing,
|
|
30
|
+
* save the loaded state of an URL's image by the image's URL.
|
|
31
|
+
*/
|
|
32
|
+
loadedUrls: Readonly<{
|
|
33
|
+
[url: string]: true;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* To avoid race conditions between `<img>` element events and potential input changing,
|
|
37
|
+
* save the errored state of an URL's image by the image's URL.
|
|
38
|
+
*/
|
|
39
|
+
erroredUrls: Readonly<{
|
|
40
|
+
[url: string]: true;
|
|
41
|
+
}>;
|
|
42
|
+
}, {}, "vira-image-height-constrained", `vira-image-${string}`, import("lit-html").HTMLTemplateResult>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { wait } from '@augment-vir/common';
|
|
2
|
+
import { classMap, css, html, listen, renderIf } from 'element-vir';
|
|
3
|
+
import { LoaderAnimated24Icon, StatusFailure24Icon } from '../../icons';
|
|
4
|
+
import { defineViraElement } from '../define-vira-element';
|
|
5
|
+
import { ViraIcon } from '../vira-icon/vira-icon.element';
|
|
6
|
+
export var ViraImageSlotNameEnum;
|
|
7
|
+
(function (ViraImageSlotNameEnum) {
|
|
8
|
+
ViraImageSlotNameEnum["Loading"] = "loading";
|
|
9
|
+
ViraImageSlotNameEnum["Error"] = "error";
|
|
10
|
+
})(ViraImageSlotNameEnum || (ViraImageSlotNameEnum = {}));
|
|
11
|
+
/**
|
|
12
|
+
* An `<img>` element wrapper that handles size constraints and includes slots for loading and error
|
|
13
|
+
* indicators.
|
|
14
|
+
*
|
|
15
|
+
* Use CSS properties to constrain the image. In particular, set `min-height` and `min-width` on
|
|
16
|
+
* this to control the size of the loader and error slots.
|
|
17
|
+
*/
|
|
18
|
+
export const ViraImage = defineViraElement()({
|
|
19
|
+
tagName: 'vira-image',
|
|
20
|
+
hostClasses: {
|
|
21
|
+
'vira-image-height-constrained': ({ inputs }) => inputs.dominantDimension === 'height',
|
|
22
|
+
},
|
|
23
|
+
styles: ({ hostClasses }) => css `
|
|
24
|
+
:host {
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
position: relative;
|
|
30
|
+
border-radius: inherit;
|
|
31
|
+
min-height: 100px;
|
|
32
|
+
min-width: 100px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
img {
|
|
36
|
+
width: 100%;
|
|
37
|
+
height: auto;
|
|
38
|
+
flex-shrink: 0;
|
|
39
|
+
}
|
|
40
|
+
${hostClasses['vira-image-height-constrained'].selector} {
|
|
41
|
+
flex-direction: row;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
${hostClasses['vira-image-height-constrained'].selector} img {
|
|
45
|
+
width: auto;
|
|
46
|
+
height: 100%;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.status-wrapper {
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
border-radius: inherit;
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 100%;
|
|
54
|
+
position: absolute;
|
|
55
|
+
top: 0;
|
|
56
|
+
left: 0;
|
|
57
|
+
display: flex;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
align-items: center;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.error {
|
|
63
|
+
color: red;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.hidden {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
`,
|
|
70
|
+
stateInitStatic: {
|
|
71
|
+
/**
|
|
72
|
+
* To avoid race conditions between `<img>` element events and potential input changing,
|
|
73
|
+
* save the loaded state of an URL's image by the image's URL.
|
|
74
|
+
*/
|
|
75
|
+
loadedUrls: {},
|
|
76
|
+
/**
|
|
77
|
+
* To avoid race conditions between `<img>` element events and potential input changing,
|
|
78
|
+
* save the errored state of an URL's image by the image's URL.
|
|
79
|
+
*/
|
|
80
|
+
erroredUrls: {},
|
|
81
|
+
},
|
|
82
|
+
renderCallback({ inputs, state, updateState }) {
|
|
83
|
+
/**
|
|
84
|
+
* Saved off for use in the image listeners. This is used to eliminate race conditions
|
|
85
|
+
* between image events and the input URL changing.
|
|
86
|
+
*/
|
|
87
|
+
const imageUrl = inputs.imageUrl;
|
|
88
|
+
const statusTemplate = state.erroredUrls[imageUrl]
|
|
89
|
+
? html `
|
|
90
|
+
<slot class="status-wrapper" name=${ViraImageSlotNameEnum.Error}>
|
|
91
|
+
<${ViraIcon.assign({ icon: StatusFailure24Icon })} class="error"></${ViraIcon}>
|
|
92
|
+
</slot>
|
|
93
|
+
`
|
|
94
|
+
: !state.loadedUrls[imageUrl]
|
|
95
|
+
? html `
|
|
96
|
+
<slot class="status-wrapper" name=${ViraImageSlotNameEnum.Loading}>
|
|
97
|
+
<${ViraIcon.assign({ icon: LoaderAnimated24Icon })}></${ViraIcon}>
|
|
98
|
+
</slot>
|
|
99
|
+
`
|
|
100
|
+
: undefined;
|
|
101
|
+
return html `
|
|
102
|
+
${renderIf(!!statusTemplate, statusTemplate)}
|
|
103
|
+
<img
|
|
104
|
+
class=${classMap({
|
|
105
|
+
hidden: !!statusTemplate,
|
|
106
|
+
})}
|
|
107
|
+
${listen('load', async () => {
|
|
108
|
+
if (inputs._debugLoadDelay) {
|
|
109
|
+
await wait(inputs._debugLoadDelay.milliseconds);
|
|
110
|
+
}
|
|
111
|
+
updateState({
|
|
112
|
+
loadedUrls: {
|
|
113
|
+
...state.loadedUrls,
|
|
114
|
+
[imageUrl]: true,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
})}
|
|
118
|
+
${listen('error', async () => {
|
|
119
|
+
if (inputs._debugLoadDelay) {
|
|
120
|
+
await wait(inputs._debugLoadDelay.milliseconds);
|
|
121
|
+
}
|
|
122
|
+
updateState({
|
|
123
|
+
erroredUrls: {
|
|
124
|
+
...state.erroredUrls,
|
|
125
|
+
[imageUrl]: true,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
})}
|
|
129
|
+
src=${imageUrl}
|
|
130
|
+
/>
|
|
131
|
+
`;
|
|
132
|
+
},
|
|
133
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ViraIconSvg } from '../../icons';
|
|
2
2
|
import { SharedTextInputElementInputs } from '../common/shared-text-input-logic';
|
|
3
|
+
export * from '../common/shared-text-input-logic';
|
|
3
4
|
export declare const ViraInput: import("element-vir").DeclarativeElementDefinition<"vira-input", {
|
|
4
5
|
icon?: undefined | Pick<ViraIconSvg, 'svgTemplate'>;
|
|
5
6
|
/** A suffix that, if provided, is shown following the user input field. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css, defineElementEvent, html, listen, onResize, renderIf } from 'element-vir';
|
|
1
|
+
import { css, defineElementEvent, html, listen, onResize, renderIf, } from 'element-vir';
|
|
2
2
|
import { CloseX24Icon } from '../../icons/icon-svgs/close-x-24.icon';
|
|
3
3
|
import { noUserSelect, viraAnimationDurations, viraDisabledStyles } from '../../styles';
|
|
4
4
|
import { createFocusStyles, viraFocusCssVars } from '../../styles/focus';
|
|
@@ -7,6 +7,7 @@ import { viraCssVars } from '../../styles/vira-css-vars';
|
|
|
7
7
|
import { filterTextInputValue, textInputListener, } from '../common/shared-text-input-logic';
|
|
8
8
|
import { defineViraElement } from '../define-vira-element';
|
|
9
9
|
import { ViraIcon } from '../vira-icon/vira-icon.element';
|
|
10
|
+
export * from '../common/shared-text-input-logic';
|
|
10
11
|
export const ViraInput = defineViraElement()({
|
|
11
12
|
tagName: 'vira-input',
|
|
12
13
|
hostClasses: {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/styles/focus.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { addPx } from '@augment-vir/common';
|
|
2
|
-
import { css } from 'element-vir';
|
|
3
|
-
import { unsafeCSS } from 'lit';
|
|
2
|
+
import { css, unsafeCSS } from 'element-vir';
|
|
4
3
|
import { defineCssVars } from 'lit-css-vars';
|
|
5
4
|
import { viraCssVars } from './vira-css-vars';
|
|
6
5
|
export const viraFocusCssVars = defineCssVars({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dimensions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dimensions';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vira",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "A simple and highly versatile design system using element-vir.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design",
|
|
@@ -31,38 +31,45 @@
|
|
|
31
31
|
"build": "npm run compile && virmator frontend build",
|
|
32
32
|
"compile": "virmator compile && rm -rf ../../node_modules/element-book/node_modules/vira",
|
|
33
33
|
"prepublishOnly": "cd ../scripts && npm run publish:pre",
|
|
34
|
-
"preview": "npm run compile && virmator frontend preview --outDir ./book
|
|
34
|
+
"preview": "npm run compile && virmator frontend preview --outDir ./dist-book",
|
|
35
35
|
"postpublish": "cd ../scripts && npm run publish:post",
|
|
36
36
|
"start": "npm run compile && virmator frontend",
|
|
37
37
|
"test": "virmator test-web",
|
|
38
|
-
"test:all": "npm test",
|
|
38
|
+
"test:all": "concurrently --colors --kill-others-on-fail -c auto --names tests,docs \"npm run test\" \"npm run test:docs\"",
|
|
39
39
|
"test:coverage": "npm run test",
|
|
40
|
-
"test:docs": "virmator
|
|
40
|
+
"test:docs": "virmator docs check"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@augment-vir/
|
|
43
|
+
"@augment-vir/browser": "^21.5.1",
|
|
44
|
+
"@augment-vir/common": "^21.5.1",
|
|
44
45
|
"colorjs.io": "^0.4.5",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
46
|
+
"date-vir": "^3.0.0",
|
|
47
|
+
"element-vir": "^16.5.2",
|
|
48
|
+
"lit-css-vars": "^3.0.2",
|
|
47
49
|
"spa-router-vir": "^3.0.2",
|
|
48
|
-
"type-fest": "^4.
|
|
50
|
+
"type-fest": "^4.6.0"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
|
-
"@augment-vir/browser-testing": "^
|
|
52
|
-
"@augment-vir/node-js": "^
|
|
53
|
-
"@open-wc/testing": "^
|
|
54
|
-
"@types/chai": "^4.3.
|
|
55
|
-
"@types/mocha": "^10.0.
|
|
56
|
-
"@web/dev-server-esbuild": "^0.
|
|
57
|
-
"@web/test-runner": "^0.
|
|
58
|
-
"@web/test-runner-commands": "^0.
|
|
59
|
-
"@web/test-runner-playwright": "^0.
|
|
60
|
-
"@web/test-runner-visual-regression": "^0.
|
|
61
|
-
"
|
|
53
|
+
"@augment-vir/browser-testing": "^21.5.1",
|
|
54
|
+
"@augment-vir/node-js": "^21.5.1",
|
|
55
|
+
"@open-wc/testing": "^4.0.0",
|
|
56
|
+
"@types/chai": "^4.3.9",
|
|
57
|
+
"@types/mocha": "^10.0.4",
|
|
58
|
+
"@web/dev-server-esbuild": "^1.0.0",
|
|
59
|
+
"@web/test-runner": "^0.18.0",
|
|
60
|
+
"@web/test-runner-commands": "^0.9.0",
|
|
61
|
+
"@web/test-runner-playwright": "^0.11.0",
|
|
62
|
+
"@web/test-runner-visual-regression": "^0.9.0",
|
|
63
|
+
"dependency-cruiser": "^15.2.0",
|
|
64
|
+
"element-book": "^10.1.5",
|
|
65
|
+
"esbuild": "^0.19.5",
|
|
62
66
|
"istanbul-smart-text-reporter": "^1.1.2",
|
|
63
|
-
"
|
|
67
|
+
"markdown-code-example-inserter": "^0.3.2",
|
|
68
|
+
"npm-check-updates": "~16.12.3",
|
|
69
|
+
"run-time-assertions": "^0.1.3",
|
|
70
|
+
"typedoc": "^0.25.3",
|
|
64
71
|
"typescript": "^5.2.2",
|
|
65
|
-
"vite": "^4.
|
|
72
|
+
"vite": "^4.5.0",
|
|
66
73
|
"vite-tsconfig-paths": "^4.2.1"
|
|
67
74
|
}
|
|
68
75
|
}
|