vira 0.5.1 → 0.6.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.
@@ -1 +1 @@
1
- export declare const allElementBookEntries: (import("element-book").BookPage<undefined, {}> | import("element-book").BookPage<import("element-book").BookPage<undefined, {}>, {}> | import("element-book").BookPage<import("element-book").BookPage<import("element-book").BookPage<undefined, {}>, {}>, {}>)[];
1
+ export declare const allElementBookEntries: (import("element-book").BookPage<undefined, {}> | import("element-book").BookPage<import("element-book").BookPage<undefined, {}>, {}>)[];
@@ -1,14 +1,16 @@
1
- import { elementsBookChapter } from '../elements/elements.book';
2
- import { viraButtonBookEntries } from '../elements/vira-button/vira-button.element.book';
3
- import { viraCollapsibleBookEntries } from '../elements/vira-collapsible/vira-collapsible-wrapper.element.book';
4
- import { viraIconBookEntries } from '../elements/vira-icon/vira-icon.element.book';
5
- import { viraInputBookEntries } from '../elements/vira-input/vira-input.element.book';
6
- import { iconBookEntries } from '../icons/icons.book';
1
+ import { elementsBookPage } from '../elements/elements.book';
2
+ import { viraButtonBookPage } from '../elements/vira-button/vira-button.element.book';
3
+ import { viraCollapsibleBookPage } from '../elements/vira-collapsible/vira-collapsible-wrapper.element.book';
4
+ import { viraIconBookPage } from '../elements/vira-icon/vira-icon.element.book';
5
+ import { viraInputBookPage } from '../elements/vira-input/vira-input.element.book';
6
+ import { viraLinkBookPage } from '../elements/vira-link/vira-link.element.book';
7
+ import { iconsBookPage } from '../icons/icons.book';
7
8
  export const allElementBookEntries = [
8
- elementsBookChapter,
9
- ...iconBookEntries,
10
- ...viraButtonBookEntries,
11
- ...viraCollapsibleBookEntries,
12
- ...viraIconBookEntries,
13
- ...viraInputBookEntries,
9
+ elementsBookPage,
10
+ iconsBookPage,
11
+ viraButtonBookPage,
12
+ viraCollapsibleBookPage,
13
+ viraIconBookPage,
14
+ viraInputBookPage,
15
+ viraLinkBookPage,
14
16
  ];
@@ -4,3 +4,4 @@ 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
6
  export * from './vira-input/vira-input.element';
7
+ export * from './vira-link/vira-link.element';
@@ -4,3 +4,4 @@ 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
6
  export * from './vira-input/vira-input.element';
7
+ export * from './vira-link/vira-link.element';
@@ -0,0 +1,15 @@
1
+ import { FullRoute, SpaRouter } from 'spa-router-vir';
2
+ import { RequireExactlyOne } from 'type-fest';
3
+ export declare const ViraLink: import("element-vir").DeclarativeElementDefinition<"vira-link", RequireExactlyOne<{
4
+ link: {
5
+ url: string;
6
+ newTab: boolean;
7
+ };
8
+ route: {
9
+ route: FullRoute;
10
+ router: Pick<SpaRouter, 'createRoutesUrl'>;
11
+ scrollToTop?: boolean;
12
+ };
13
+ }>, {}, {
14
+ routeChange: import("element-vir").DefinedTypedEventNameDefinition<FullRoute>;
15
+ }, `vira-link-${string}`, "vira-link-hover-color", import("lit-html").HTMLTemplateResult>;
@@ -0,0 +1,68 @@
1
+ import { css, defineElementEvent, html, listen } from 'element-vir';
2
+ import { shouldMouseEventTriggerRoutes } from 'spa-router-vir';
3
+ import { defineViraElement } from '../define-vira-element';
4
+ export const ViraLink = defineViraElement()({
5
+ tagName: 'vira-link',
6
+ cssVars: {
7
+ 'vira-link-hover-color': 'currentColor',
8
+ },
9
+ styles: ({ cssVars }) => css `
10
+ :host {
11
+ display: inline;
12
+ text-decoration: underline;
13
+ }
14
+
15
+ a,
16
+ a:visited,
17
+ a:active,
18
+ a:link,
19
+ a:hover {
20
+ color: inherit;
21
+ text-decoration: inherit;
22
+ white-space: inherit;
23
+ }
24
+
25
+ :host(:hover) a,
26
+ a:hover,
27
+ :host(:active) a,
28
+ a:active {
29
+ color: ${cssVars['vira-link-hover-color'].value};
30
+ }
31
+ `,
32
+ events: {
33
+ routeChange: defineElementEvent(),
34
+ },
35
+ renderCallback({ inputs, dispatch, events }) {
36
+ function clickCallback(clickEvent) {
37
+ if (!inputs.route) {
38
+ return;
39
+ }
40
+ if (shouldMouseEventTriggerRoutes(clickEvent)) {
41
+ clickEvent.preventDefault();
42
+ if (inputs.route.scrollToTop) {
43
+ window.scrollTo(0, 0);
44
+ }
45
+ dispatch(new events.routeChange(inputs.route.route));
46
+ }
47
+ }
48
+ if (inputs.link?.newTab) {
49
+ /** Noopener and noreferrer are needed for security reasons, do not remove! */
50
+ return html `
51
+ <a href=${inputs.link.url} target="_blank" rel="noopener noreferrer">
52
+ <slot></slot>
53
+ </a>
54
+ `;
55
+ }
56
+ else {
57
+ const linkUrl = inputs.link
58
+ ? inputs.link.url
59
+ : inputs.route?.router.createRoutesUrl(inputs.route.route);
60
+ /** Noopener and noreferrer are needed for security reasons, do not remove! */
61
+ return html `
62
+ <a href=${linkUrl} rel="noopener noreferrer" ${listen('click', clickCallback)}>
63
+ <slot></slot>
64
+ </a>
65
+ `;
66
+ }
67
+ },
68
+ });
@@ -1 +1,2 @@
1
+ export * from './native-styles';
1
2
  export * from './number';
@@ -1 +1,2 @@
1
+ export * from './native-styles';
1
2
  export * from './number';
@@ -0,0 +1,2 @@
1
+ export declare const noNativeSpacing: import("element-vir").CSSResult;
2
+ export declare const noNativeFormStyles: import("element-vir").CSSResult;
@@ -0,0 +1,16 @@
1
+ import { css } from 'element-vir';
2
+ export const noNativeSpacing = css `
3
+ padding: 0;
4
+ margin: 0;
5
+ `;
6
+ export const noNativeFormStyles = css `
7
+ ${noNativeSpacing}
8
+ background: none;
9
+ border: none;
10
+ font: inherit;
11
+ color: inherit;
12
+ cursor: pointer;
13
+ text-transform: inherit;
14
+ text-decoration: inherit;
15
+ -webkit-tap-highlight-color: transparent;
16
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "A simple and highly versatile design system using element-vir.",
5
5
  "keywords": [
6
6
  "design",
@@ -39,11 +39,13 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "element-vir": "^14.0.3",
42
- "lit-css-vars": "^2.0.3"
42
+ "lit-css-vars": "^2.0.3",
43
+ "spa-router-vir": "^2.1.1",
44
+ "type-fest": "^3.12.0"
43
45
  },
44
46
  "devDependencies": {
45
- "@augment-vir/browser-testing": "^15.2.1",
46
- "@augment-vir/node-js": "^15.2.1",
47
+ "@augment-vir/browser-testing": "^15.3.0",
48
+ "@augment-vir/node-js": "^15.3.0",
47
49
  "@open-wc/testing": "^3.2.0",
48
50
  "@types/chai": "^4.3.5",
49
51
  "@types/mocha": "^10.0.1",
@@ -52,10 +54,10 @@
52
54
  "@web/test-runner-commands": "^0.7.0",
53
55
  "@web/test-runner-playwright": "^0.10.1",
54
56
  "@web/test-runner-visual-regression": "^0.8.0",
55
- "esbuild": "^0.18.7",
57
+ "esbuild": "^0.18.11",
56
58
  "istanbul-smart-text-reporter": "^1.1.2",
57
59
  "npm-check-updates": "^16.10.13",
58
- "typescript": "^5.1.3",
60
+ "typescript": "^5.1.6",
59
61
  "vite": "^4.3.9",
60
62
  "vite-tsconfig-paths": "^4.2.0"
61
63
  }