vira 0.2.0 → 0.3.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.
Files changed (31) hide show
  1. package/dist/element-book/all-element-book-entries.js +13 -14
  2. package/dist/element-book/book-helpers/create-element-book-url.js +4 -8
  3. package/dist/element-book/vira-book-app.element.js +12 -15
  4. package/dist/elements/define-vira-element.js +6 -10
  5. package/dist/elements/index.d.ts +1 -0
  6. package/dist/elements/index.js +5 -20
  7. package/dist/elements/vira-button/vira-button.element.d.ts +2 -2
  8. package/dist/elements/vira-button/vira-button.element.js +32 -32
  9. package/dist/elements/vira-collapsible/vira-collapsible-wrapper.element.js +15 -18
  10. package/dist/elements/vira-icon/vira-icon.element.d.ts +1 -1
  11. package/dist/elements/vira-icon/vira-icon.element.js +8 -11
  12. package/dist/elements/vira-input/vira-input.element.d.ts +39 -0
  13. package/dist/elements/vira-input/vira-input.element.js +350 -0
  14. package/dist/icons/icon-color-css-vars.js +4 -7
  15. package/dist/icons/icon-svg.js +1 -5
  16. package/dist/icons/icon-svgs/element-16.icon.js +9 -10
  17. package/dist/icons/icon-svgs/element-24.icon.js +5 -10
  18. package/dist/icons/index.js +8 -25
  19. package/dist/index.js +4 -20
  20. package/dist/styles/disabled.js +2 -5
  21. package/dist/styles/durations.js +2 -5
  22. package/dist/styles/focus.d.ts +2 -0
  23. package/dist/styles/focus.js +13 -15
  24. package/dist/styles/index.js +5 -21
  25. package/dist/styles/native-styles.js +2 -6
  26. package/dist/styles/user-select.js +2 -5
  27. package/dist/styles/vira-css-vars.d.ts +3 -0
  28. package/dist/styles/vira-css-vars.js +4 -0
  29. package/dist/util/index.js +1 -17
  30. package/dist/util/number.js +2 -7
  31. package/package.json +10 -9
@@ -1,15 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.allElementBookEntries = void 0;
4
- const elements_book_1 = require("../elements/elements.book");
5
- const vira_button_element_book_1 = require("../elements/vira-button/vira-button.element.book");
6
- const vira_collapsible_wrapper_element_book_1 = require("../elements/vira-collapsible/vira-collapsible-wrapper.element.book");
7
- const vira_icon_element_book_1 = require("../elements/vira-icon/vira-icon.element.book");
8
- const icons_book_1 = require("../icons/icons.book");
9
- exports.allElementBookEntries = [
10
- elements_book_1.elementsBookChapter,
11
- ...icons_book_1.iconBookEntries,
12
- ...vira_button_element_book_1.viraButtonBookEntries,
13
- ...vira_collapsible_wrapper_element_book_1.viraCollapsibleBookEntries,
14
- ...vira_icon_element_book_1.viraIconBookEntries,
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';
7
+ export const allElementBookEntries = [
8
+ elementsBookChapter,
9
+ ...iconBookEntries,
10
+ ...viraButtonBookEntries,
11
+ ...viraCollapsibleBookEntries,
12
+ ...viraIconBookEntries,
13
+ ...viraInputBookEntries,
15
14
  ];
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createElementBookUrl = void 0;
4
- const common_1 = require("@augment-vir/common");
1
+ import { isTruthy, joinUrlParts } from '@augment-vir/common';
5
2
  const potentialBasePath = '/vira';
6
- function createElementBookUrl(...urlParts) {
3
+ export function createElementBookUrl(...urlParts) {
7
4
  const hasBasePath = globalThis.location.pathname.startsWith(potentialBasePath);
8
5
  const allParts = [
9
6
  hasBasePath ? potentialBasePath : '',
10
7
  ...urlParts,
11
- ].filter(common_1.isTruthy);
12
- return (0, common_1.joinUrlParts)(...allParts);
8
+ ].filter(isTruthy);
9
+ return joinUrlParts(...allParts);
13
10
  }
14
- exports.createElementBookUrl = createElementBookUrl;
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViraBookApp = void 0;
4
- const element_book_1 = require("element-book");
5
- const element_vir_1 = require("element-vir");
6
- const all_element_book_entries_1 = require("./all-element-book-entries");
7
- exports.ViraBookApp = (0, element_vir_1.defineElementNoInputs)({
1
+ import { ElementBookApp, ElementBookSlotName } from 'element-book';
2
+ import { assign, css, defineElementNoInputs, html } from 'element-vir';
3
+ import { allElementBookEntries } from './all-element-book-entries';
4
+ export const ViraBookApp = defineElementNoInputs({
8
5
  tagName: 'vira-book-app',
9
- styles: (0, element_vir_1.css) `
6
+ styles: css `
10
7
  :host {
11
8
  display: block;
12
9
  height: 100%;
13
10
  width: 100%;
14
11
  }
15
12
 
16
- ${element_book_1.ElementBookApp} {
13
+ ${ElementBookApp} {
17
14
  height: 100%;
18
15
  width: 100%;
19
16
  }
@@ -26,19 +23,19 @@ exports.ViraBookApp = (0, element_vir_1.defineElementNoInputs)({
26
23
  }
27
24
  `,
28
25
  renderCallback() {
29
- return (0, element_vir_1.html) `
30
- <${element_book_1.ElementBookApp}
31
- ${(0, element_vir_1.assign)(element_book_1.ElementBookApp, {
26
+ return html `
27
+ <${ElementBookApp}
28
+ ${assign(ElementBookApp, {
32
29
  internalRouterConfig: {
33
30
  basePath: 'vira',
34
31
  useInternalRouter: true,
35
32
  },
36
- entries: all_element_book_entries_1.allElementBookEntries,
33
+ entries: allElementBookEntries,
37
34
  themeColor: '#33ccff',
38
35
  })}
39
36
  >
40
- <h1 slot=${element_book_1.ElementBookSlotName.NavHeader}>Vira</h1>
41
- </${element_book_1.ElementBookApp}>
37
+ <h1 slot=${ElementBookSlotName.NavHeader}>Vira</h1>
38
+ </${ElementBookApp}>
42
39
  `;
43
40
  },
44
41
  });
@@ -1,13 +1,9 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.defineViraElementNoInputs = exports.defineViraElement = exports.ViraTagNamePrefix = void 0;
5
- const element_vir_1 = require("element-vir");
6
- exports.ViraTagNamePrefix = `vira-`;
7
- _a = (0, element_vir_1.wrapDefineElement)({
1
+ import { wrapDefineElement } from 'element-vir';
2
+ export const ViraTagNamePrefix = `vira-`;
3
+ export const { defineElement: defineViraElement, defineElementNoInputs: defineViraElementNoInputs } = wrapDefineElement({
8
4
  assertInputs: (inputs) => {
9
- if (!inputs.tagName.startsWith(exports.ViraTagNamePrefix)) {
10
- throw new Error(`Tag name should start with '${exports.ViraTagNamePrefix}' but got '${inputs.tagName}'`);
5
+ if (!inputs.tagName.startsWith(ViraTagNamePrefix)) {
6
+ throw new Error(`Tag name should start with '${ViraTagNamePrefix}' but got '${inputs.tagName}'`);
11
7
  }
12
8
  },
13
- }), exports.defineViraElement = _a.defineElement, exports.defineViraElementNoInputs = _a.defineElementNoInputs;
9
+ });
@@ -3,3 +3,4 @@ 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-input/vira-input.element';
@@ -1,21 +1,6 @@
1
- "use strict";
2
1
  /** This file is automatically updated by update-element-exports.ts */
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- __exportStar(require("./define-vira-element"), exports);
19
- __exportStar(require("./vira-button/vira-button.element"), exports);
20
- __exportStar(require("./vira-collapsible/vira-collapsible-wrapper.element"), exports);
21
- __exportStar(require("./vira-icon/vira-icon.element"), exports);
2
+ export * from './define-vira-element';
3
+ export * from './vira-button/vira-button.element';
4
+ export * from './vira-collapsible/vira-collapsible-wrapper.element';
5
+ export * from './vira-icon/vira-icon.element';
6
+ export * from './vira-input/vira-input.element';
@@ -5,7 +5,7 @@ export declare enum ViraButtonStyleEnum {
5
5
  }
6
6
  export declare const ViraButton: import("element-vir").DeclarativeElementDefinition<"vira-button", {
7
7
  text?: string;
8
- icon?: undefined | ViraIconSvg;
8
+ icon?: undefined | Pick<ViraIconSvg, 'svgTemplate'>;
9
9
  disabled?: boolean | undefined;
10
10
  buttonStyle?: ViraButtonStyleEnum | undefined;
11
- }, {}, {}, "vira-button-outline-style" | "vira-button-disabled", "vira-button-primary-color" | "vira-button-primary-hover-color" | "vira-button-primary-active-color" | "vira-button-secondary-color" | "vira-button-internal-foreground-color" | "vira-button-internal-background-color", import("lit-html").HTMLTemplateResult>;
11
+ }, {}, {}, "vira-button-outline-style" | "vira-button-disabled", "vira-button-primary-color" | "vira-button-primary-hover-color" | "vira-button-primary-active-color" | "vira-button-secondary-color" | "vira-button-internal-foreground-color" | "vira-button-internal-background-color" | "vira-button-padding", import("lit-html").HTMLTemplateResult>;
@@ -1,20 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViraButton = exports.ViraButtonStyleEnum = void 0;
4
- const element_vir_1 = require("element-vir");
5
- const styles_1 = require("../../styles");
6
- const disabled_1 = require("../../styles/disabled");
7
- const durations_1 = require("../../styles/durations");
8
- const focus_1 = require("../../styles/focus");
9
- const native_styles_1 = require("../../styles/native-styles");
10
- const define_vira_element_1 = require("../define-vira-element");
11
- const vira_icon_element_1 = require("../vira-icon/vira-icon.element");
12
- var ViraButtonStyleEnum;
1
+ import { assign, css, html } from 'element-vir';
2
+ import { noUserSelect } from '../../styles';
3
+ import { viraDisabledStyles } from '../../styles/disabled';
4
+ import { viraAnimationDurations } from '../../styles/durations';
5
+ import { createFocusStyles, viraFocusCssVars } from '../../styles/focus';
6
+ import { removeNativeFormStyles } from '../../styles/native-styles';
7
+ import { viraCssVars } from '../../styles/vira-css-vars';
8
+ import { defineViraElement } from '../define-vira-element';
9
+ import { ViraIcon } from '../vira-icon/vira-icon.element';
10
+ export var ViraButtonStyleEnum;
13
11
  (function (ViraButtonStyleEnum) {
14
12
  ViraButtonStyleEnum["Default"] = "vira-button-default";
15
13
  ViraButtonStyleEnum["Outline"] = "vira-button-outline";
16
- })(ViraButtonStyleEnum = exports.ViraButtonStyleEnum || (exports.ViraButtonStyleEnum = {}));
17
- exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
14
+ })(ViraButtonStyleEnum || (ViraButtonStyleEnum = {}));
15
+ export const ViraButton = defineViraElement()({
18
16
  tagName: 'vira-button',
19
17
  hostClasses: {
20
18
  'vira-button-outline-style': ({ inputs }) => inputs.buttonStyle === ViraButtonStyleEnum.Outline,
@@ -29,8 +27,9 @@ exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
29
27
  'vira-button-secondary-color': 'white',
30
28
  'vira-button-internal-foreground-color': '',
31
29
  'vira-button-internal-background-color': '',
30
+ 'vira-button-padding': '5px 10px',
32
31
  },
33
- styles: ({ hostClasses, cssVars }) => (0, element_vir_1.css) `
32
+ styles: ({ hostClasses, cssVars }) => css `
34
33
  :host {
35
34
  font-weight: bold;
36
35
  display: inline-flex;
@@ -38,10 +37,10 @@ exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
38
37
  vertical-align: middle;
39
38
  align-items: center;
40
39
  box-sizing: border-box;
41
- ${styles_1.noUserSelect};
40
+ ${noUserSelect};
42
41
  ${cssVars['vira-button-internal-background-color'].name}: ${cssVars['vira-button-primary-color'].value};
43
42
  ${cssVars['vira-button-internal-foreground-color'].name}: ${cssVars['vira-button-secondary-color'].value};
44
- ${focus_1.viraFocusCssVars['vira-focus-outline-color'].name}: ${cssVars['vira-button-primary-hover-color'].value}
43
+ ${viraFocusCssVars['vira-focus-outline-color'].name}: ${cssVars['vira-button-primary-hover-color'].value}
45
44
  }
46
45
 
47
46
  :host(:hover) button,
@@ -55,7 +54,7 @@ exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
55
54
  }
56
55
 
57
56
  ${hostClasses['vira-button-disabled'].selector} {
58
- ${disabled_1.viraDisabledStyles};
57
+ ${viraDisabledStyles};
59
58
  }
60
59
 
61
60
  ${hostClasses['vira-button-outline-style'].selector} button {
@@ -65,7 +64,8 @@ exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
65
64
  }
66
65
 
67
66
  button {
68
- ${native_styles_1.removeNativeFormStyles};
67
+ cursor: pointer;
68
+ ${removeNativeFormStyles};
69
69
  position: relative;
70
70
  width: 100%;
71
71
  height: 100%;
@@ -75,41 +75,41 @@ exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
75
75
  display: inline-flex;
76
76
  justify-content: center;
77
77
  align-items: center;
78
- border-radius: 8px;
78
+ border-radius: ${viraCssVars['vira-form-input-border-radius'].value};
79
79
  background-color: ${cssVars['vira-button-internal-background-color'].value};
80
80
  color: ${cssVars['vira-button-internal-foreground-color'].value};
81
- padding: 5px 10px;
82
- transition: color ${durations_1.viraAnimationDurations['vira-interaction-animation-duration'].value},
81
+ padding: ${cssVars['vira-button-padding'].value};
82
+ transition: color ${viraAnimationDurations['vira-interaction-animation-duration'].value},
83
83
  background-color
84
- ${durations_1.viraAnimationDurations['vira-interaction-animation-duration'].value},
85
- border-color ${durations_1.viraAnimationDurations['vira-interaction-animation-duration'].value};
84
+ ${viraAnimationDurations['vira-interaction-animation-duration'].value},
85
+ border-color ${viraAnimationDurations['vira-interaction-animation-duration'].value};
86
86
  }
87
87
 
88
- ${(0, focus_1.createFocusStyles)({
88
+ ${createFocusStyles({
89
89
  mainSelector: 'button:focus:focus-visible:not(:active):not([disabled])',
90
90
  elementBorderSize: 2,
91
91
  })}
92
92
 
93
- button ${vira_icon_element_1.ViraIcon} + .text-template {
93
+ button ${ViraIcon} + .text-template {
94
94
  margin-left: 8px;
95
95
  }
96
96
  `,
97
97
  renderCallback: ({ inputs }) => {
98
98
  const iconTemplate = inputs.icon
99
- ? (0, element_vir_1.html) `
100
- <${vira_icon_element_1.ViraIcon}
101
- ${(0, element_vir_1.assign)(vira_icon_element_1.ViraIcon, {
99
+ ? html `
100
+ <${ViraIcon}
101
+ ${assign(ViraIcon, {
102
102
  icon: inputs.icon,
103
103
  })}
104
- ></${vira_icon_element_1.ViraIcon}>
104
+ ></${ViraIcon}>
105
105
  `
106
106
  : '';
107
107
  const textTemplate = inputs.text
108
- ? (0, element_vir_1.html) `
108
+ ? html `
109
109
  <span class="text-template">${inputs.text}</span>
110
110
  `
111
111
  : '';
112
- return (0, element_vir_1.html) `
112
+ return html `
113
113
  <button ?disabled=${inputs.disabled}>${iconTemplate} ${textTemplate}</button>
114
114
  `;
115
115
  },
@@ -1,27 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViraCollapsibleWrapper = exports.ViraCollapsibleSlotNameEnum = void 0;
4
- const element_vir_1 = require("element-vir");
5
- const styles_1 = require("../../styles");
6
- const define_vira_element_1 = require("../define-vira-element");
7
- var ViraCollapsibleSlotNameEnum;
1
+ import { css, defineElementEvent, html, listen, onResize } from 'element-vir';
2
+ import { removeNativeFormStyles, viraAnimationDurations } from '../../styles';
3
+ import { defineViraElement } from '../define-vira-element';
4
+ export var ViraCollapsibleSlotNameEnum;
8
5
  (function (ViraCollapsibleSlotNameEnum) {
9
6
  ViraCollapsibleSlotNameEnum["Header"] = "header";
10
- })(ViraCollapsibleSlotNameEnum = exports.ViraCollapsibleSlotNameEnum || (exports.ViraCollapsibleSlotNameEnum = {}));
11
- exports.ViraCollapsibleWrapper = (0, define_vira_element_1.defineViraElement)()({
7
+ })(ViraCollapsibleSlotNameEnum || (ViraCollapsibleSlotNameEnum = {}));
8
+ export const ViraCollapsibleWrapper = defineViraElement()({
12
9
  tagName: 'vira-collapsible-wrapper',
13
10
  hostClasses: {
14
11
  'vira-collapsible-wrapper-expanded': ({ inputs }) => inputs.expanded,
15
12
  },
16
- styles: ({ hostClasses }) => (0, element_vir_1.css) `
13
+ styles: ({ hostClasses }) => css `
17
14
  :host {
18
15
  display: flex;
19
16
  flex-direction: column;
20
17
  }
21
18
 
22
19
  .header-wrapper {
20
+ ${removeNativeFormStyles};
23
21
  cursor: pointer;
24
- ${styles_1.removeNativeFormStyles};
25
22
  }
26
23
 
27
24
  .content-wrapper,
@@ -32,7 +29,7 @@ exports.ViraCollapsibleWrapper = (0, define_vira_element_1.defineViraElement)()(
32
29
  }
33
30
 
34
31
  .collapsing-element {
35
- transition: height ${styles_1.viraAnimationDurations['vira-pretty-animation-duration'].value};
32
+ transition: height ${viraAnimationDurations['vira-pretty-animation-duration'].value};
36
33
  overflow: hidden;
37
34
  }
38
35
  ${hostClasses['vira-collapsible-wrapper-expanded'].name} .collapsing-element {
@@ -40,23 +37,23 @@ exports.ViraCollapsibleWrapper = (0, define_vira_element_1.defineViraElement)()(
40
37
  }
41
38
  `,
42
39
  events: {
43
- expandChange: (0, element_vir_1.defineElementEvent)(),
40
+ expandChange: defineElementEvent(),
44
41
  },
45
42
  stateInitStatic: {
46
43
  contentHeight: 0,
47
44
  },
48
45
  renderCallback({ state, updateState, dispatch, events, inputs }) {
49
46
  const collapsingStyles = inputs.expanded
50
- ? (0, element_vir_1.css) `
47
+ ? css `
51
48
  height: ${state.contentHeight}px;
52
49
  `
53
- : (0, element_vir_1.css) `
50
+ : css `
54
51
  height: 0;
55
52
  `;
56
- return (0, element_vir_1.html) `
53
+ return html `
57
54
  <button
58
55
  class="header-wrapper"
59
- ${(0, element_vir_1.listen)('click', () => {
56
+ ${listen('click', () => {
60
57
  dispatch(new events.expandChange(!inputs.expanded));
61
58
  })}
62
59
  >
@@ -64,7 +61,7 @@ exports.ViraCollapsibleWrapper = (0, define_vira_element_1.defineViraElement)()(
64
61
  </button>
65
62
  <div class="collapsing-element" style=${collapsingStyles} disabled="disabled">
66
63
  <div
67
- ${(0, element_vir_1.onResize)(({ contentRect }) => {
64
+ ${onResize(({ contentRect }) => {
68
65
  updateState({ contentHeight: contentRect.height });
69
66
  })}
70
67
  class="content-wrapper"
@@ -1,6 +1,6 @@
1
1
  import { ViraIconSvg } from '../../icons/icon-svg';
2
2
  export declare const ViraIcon: import("element-vir").DeclarativeElementDefinition<"vira-icon", {
3
- icon: ViraIconSvg | undefined;
3
+ icon: Pick<ViraIconSvg, 'svgTemplate'> | undefined;
4
4
  /** Ignores the given icon's embedded size and causes the <svg> element to fill its parent. */
5
5
  fitContainer?: boolean | undefined;
6
6
  }, {}, {}, "vira-icon-fit-container", `vira-icon-${string}`, import("lit-html").TemplateResult | "">;
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViraIcon = void 0;
4
- const element_vir_1 = require("element-vir");
5
- const icon_color_css_vars_1 = require("../../icons/icon-color-css-vars");
6
- const define_vira_element_1 = require("../define-vira-element");
7
- exports.ViraIcon = (0, define_vira_element_1.defineViraElement)()({
1
+ import { css } from 'element-vir';
2
+ import { viraIconColorCssVars } from '../../icons/icon-color-css-vars';
3
+ import { defineViraElement } from '../define-vira-element';
4
+ export const ViraIcon = defineViraElement()({
8
5
  tagName: 'vira-icon',
9
6
  hostClasses: {
10
7
  /** Ignores the given icon's embedded size and causes the <svg> element to fill its parent. */
11
8
  'vira-icon-fit-container': ({ inputs }) => !!inputs.fitContainer,
12
9
  },
13
- styles: ({ hostClasses }) => (0, element_vir_1.css) `
10
+ styles: ({ hostClasses }) => css `
14
11
  :host {
15
12
  display: inline-block;
16
- color: ${icon_color_css_vars_1.viraIconColorCssVars['vira-icon-color'].value};
17
- fill: ${icon_color_css_vars_1.viraIconColorCssVars['vira-icon-fill-color'].value};
18
- stroke: ${icon_color_css_vars_1.viraIconColorCssVars['vira-icon-stroke-color'].value};
13
+ color: ${viraIconColorCssVars['vira-icon-color'].value};
14
+ fill: ${viraIconColorCssVars['vira-icon-fill-color'].value};
15
+ stroke: ${viraIconColorCssVars['vira-icon-stroke-color'].value};
19
16
  }
20
17
 
21
18
  svg {
@@ -0,0 +1,39 @@
1
+ import { ViraIconSvg } from '../../icons';
2
+ export declare const ViraInput: import("element-vir").DeclarativeElementDefinition<"vira-input", {
3
+ icon?: undefined | Pick<ViraIconSvg, 'svgTemplate'>;
4
+ value: string;
5
+ /** Shown when no other text is present. Input restrictions do not apply to this property. */
6
+ placeholder?: string;
7
+ /** Set to true to trigger disabled styles and to block all user input. */
8
+ disabled?: boolean;
9
+ /**
10
+ * Only letters in the given string or matches to the given RegExp will be allowed.
11
+ * blockedInputs takes precedence over this input.
12
+ *
13
+ * For example: if allowedInputs is set to "abcd" and blockedInputs is set to "d", only "a",
14
+ * "b", or "c" letters will be allowed.
15
+ */
16
+ allowedInputs?: string | RegExp;
17
+ /** Any letters in the given string or matches to the given RegExp will be blocked. */
18
+ blockedInputs?: string | RegExp;
19
+ /** Disable all browser helps like spellchecking, autocomplete, etc. */
20
+ disableBrowserHelps?: boolean;
21
+ /** A suffix that, if provided, is shown following the user input field. */
22
+ suffix?: string;
23
+ /** Set this to true to make the whole element size to only fit the input text. */
24
+ fitText?: boolean;
25
+ }, {
26
+ forcedInputWidth: number;
27
+ }, {
28
+ /**
29
+ * Fires whenever a user input created a new value. Does not fire if all input letters are
30
+ * filtered out due to input restrictions.
31
+ */
32
+ valueChange: import("element-vir").DefinedTypedEventNameDefinition<string>;
33
+ /**
34
+ * Fires when inputs are blocked. Useful for showing warnings or error messages to inform
35
+ * the user why their input did not propagate if it was blocked. This does not fire for text
36
+ * that was blocked out of programmatic "value" property assignments.
37
+ */
38
+ inputBlocked: import("element-vir").DefinedTypedEventNameDefinition<string>;
39
+ }, "vira-input-disabled" | "vira-input-has-value" | "vira-input-fit-text", "vira-input-placeholder-color" | "vira-input-text-color" | "vira-input-border-color" | "vira-input-focus-border-color" | "vira-input-text-selection-color" | "vira-input-padding-horizontal" | "vira-input-padding-vertical", import("lit-html").HTMLTemplateResult>;
@@ -0,0 +1,350 @@
1
+ import { assign, classMap, css, defineElementEvent, html, listen, onResize, renderIf, } from 'element-vir';
2
+ import { noUserSelect, viraAnimationDurations, viraDisabledStyles } from '../../styles';
3
+ import { createFocusStyles, viraFocusCssVars } from '../../styles/focus';
4
+ import { removeNativeFormStyles } from '../../styles/native-styles';
5
+ import { viraCssVars } from '../../styles/vira-css-vars';
6
+ import { defineViraElement } from '../define-vira-element';
7
+ import { ViraIcon } from '../vira-icon/vira-icon.element';
8
+ function doesMatch({ input, matcher }) {
9
+ if (!input || !matcher) {
10
+ return true;
11
+ }
12
+ if (input.length > 1) {
13
+ return !!input.split('').every((singleInput) => doesMatch({ input: singleInput, matcher }));
14
+ }
15
+ if (matcher instanceof RegExp) {
16
+ return !!input.match(matcher);
17
+ }
18
+ else {
19
+ return matcher.includes(input);
20
+ }
21
+ }
22
+ function isAllowed({ value, allowed, blocked }) {
23
+ const isAllowedCharacter = allowed
24
+ ? doesMatch({
25
+ input: value,
26
+ matcher: allowed,
27
+ })
28
+ : true;
29
+ const isBlockedCharacter = blocked
30
+ ? doesMatch({
31
+ input: value,
32
+ matcher: blocked,
33
+ })
34
+ : false;
35
+ return isAllowedCharacter && !isBlockedCharacter;
36
+ }
37
+ function filterToAllowedCharactersOnly(inputs) {
38
+ if (!inputs.value) {
39
+ return { filtered: inputs.value, blocked: '' };
40
+ }
41
+ const { filtered, blocked } = inputs.value.split('').reduce((accum, letter) => {
42
+ const allowed = isAllowed({ ...inputs, value: letter });
43
+ if (allowed) {
44
+ accum.filtered.push(letter);
45
+ }
46
+ else {
47
+ accum.blocked.push(letter);
48
+ }
49
+ return accum;
50
+ }, {
51
+ filtered: [],
52
+ blocked: [],
53
+ });
54
+ return {
55
+ filtered: filtered.join(''),
56
+ blocked: blocked.join(''),
57
+ };
58
+ }
59
+ export const ViraInput = defineViraElement()({
60
+ tagName: 'vira-input',
61
+ hostClasses: {
62
+ 'vira-input-disabled': ({ inputs }) => !!inputs.disabled,
63
+ 'vira-input-has-value': ({ inputs }) => !!inputs.value,
64
+ 'vira-input-fit-text': ({ inputs }) => !!inputs.fitText,
65
+ },
66
+ cssVars: {
67
+ 'vira-input-placeholder-color': '#ccc',
68
+ 'vira-input-text-color': 'black',
69
+ 'vira-input-border-color': '#ccc',
70
+ 'vira-input-focus-border-color': '#59B1FF',
71
+ 'vira-input-text-selection-color': '#CFE9FF',
72
+ 'vira-input-padding-horizontal': '10px',
73
+ 'vira-input-padding-vertical': '6px',
74
+ },
75
+ events: {
76
+ /**
77
+ * Fires whenever a user input created a new value. Does not fire if all input letters are
78
+ * filtered out due to input restrictions.
79
+ */
80
+ valueChange: defineElementEvent(),
81
+ /**
82
+ * Fires when inputs are blocked. Useful for showing warnings or error messages to inform
83
+ * the user why their input did not propagate if it was blocked. This does not fire for text
84
+ * that was blocked out of programmatic "value" property assignments.
85
+ */
86
+ inputBlocked: defineElementEvent(),
87
+ },
88
+ styles: ({ hostClasses, cssVars }) => {
89
+ return css `
90
+ :host {
91
+ position: relative;
92
+ display: inline-flex;
93
+ width: 224px;
94
+ box-sizing: border-box;
95
+ ${viraFocusCssVars['vira-focus-outline-color'].name}: ${cssVars['vira-input-focus-border-color'].value};
96
+ color: ${cssVars['vira-input-text-color'].value};
97
+ }
98
+
99
+ ${hostClasses['vira-input-disabled'].selector} {
100
+ ${viraDisabledStyles};
101
+ }
102
+
103
+ ${hostClasses['vira-input-fit-text'].selector} {
104
+ width: unset;
105
+ }
106
+ ${hostClasses['vira-input-fit-text'].selector} input {
107
+ flex-grow: 0;
108
+ }
109
+ ${hostClasses['vira-input-fit-text'].selector} input.has-value {
110
+ /*
111
+ Account for weird Safari <input> behavior with text alignment and size. so we
112
+ don't lose a pixel on the left side.
113
+ Only apply this when <input> has a value, otherwise externally-set width and a
114
+ placeholder input will cause the text selector bar to initially be in the center
115
+ of the element.
116
+ */
117
+ text-align: center;
118
+ }
119
+ ${hostClasses['vira-input-fit-text'].selector} .size-span {
120
+ ${removeNativeFormStyles};
121
+ font-family: inherit;
122
+ display: inline-block;
123
+ font-size: inherit;
124
+ line-height: inherit;
125
+ box-sizing: border-box;
126
+ position: absolute;
127
+ opacity: 0;
128
+ visibility: hidden;
129
+ pointer-events: none;
130
+ z-index: -1;
131
+ width: min-content;
132
+ ${noUserSelect};
133
+ vertical-align: middle;
134
+ max-height: 100%;
135
+ }
136
+
137
+ pre {
138
+ ${removeNativeFormStyles};
139
+ font: inherit;
140
+ /*
141
+ Leave at least a few pixels for the cursor bar when there is no text at all.
142
+ This also accounts for a weird Safari <input> behavior where the text moves
143
+ around if it's not given a tiny bit of padding.
144
+ */
145
+ padding-left: 2px;
146
+ display: block;
147
+ }
148
+
149
+ .border-style {
150
+ position: absolute;
151
+ top: 0;
152
+ left: 0;
153
+ width: 100%;
154
+ height: 100%;
155
+ border-radius: ${viraCssVars['vira-form-input-border-radius'].value};
156
+ z-index: 0;
157
+ pointer-events: none;
158
+ }
159
+
160
+ .label-border {
161
+ top: -1px;
162
+ left: -1px;
163
+ border: 1px solid ${cssVars['vira-input-border-color'].value};
164
+ transition: border
165
+ ${viraAnimationDurations['vira-interaction-animation-duration'].value};
166
+ }
167
+
168
+ label {
169
+ ${removeNativeFormStyles};
170
+ max-width: 100%;
171
+ flex-grow: 1;
172
+ cursor: pointer;
173
+ display: inline-flex;
174
+ box-sizing: border-box;
175
+ align-items: center;
176
+ position: relative;
177
+ padding: 0 ${cssVars['vira-input-padding-horizontal'].value};
178
+ border-radius: ${viraCssVars['vira-form-input-border-radius'].value};
179
+ background-color: transparent;
180
+ /*
181
+ Border colors are actually applied via the .label-border class. However, we must
182
+ apply a border here still so that it takes up space.
183
+ */
184
+ border: 1px solid transparent;
185
+ gap: 4px;
186
+ }
187
+
188
+ ${createFocusStyles({
189
+ mainSelector: 'input:focus:focus-visible:not(:active):not([disabled]) ~ .focus-border',
190
+ elementBorderSize: 0,
191
+ })}
192
+
193
+ ${ViraIcon} {
194
+ margin-right: calc(${cssVars['vira-input-padding-horizontal'].value} - 4px);
195
+ }
196
+
197
+ input {
198
+ ${removeNativeFormStyles};
199
+ cursor: text;
200
+ margin: ${cssVars['vira-input-padding-vertical'].value} 0;
201
+ flex-grow: 1;
202
+ max-width: 100%;
203
+ /* fix input element not shrinking by default */
204
+ width: 0;
205
+ text-overflow: ellipsis;
206
+ box-sizing: border-box;
207
+ overflow: hidden;
208
+ }
209
+
210
+ ::selection {
211
+ background: ${cssVars['vira-input-text-selection-color']
212
+ .value}; /* WebKit/Blink Browsers */
213
+ }
214
+ ::-moz-selection {
215
+ background: ${cssVars['vira-input-text-selection-color']
216
+ .value}; /* Gecko Browsers */
217
+ }
218
+
219
+ input:placeholder-shown {
220
+ text-overflow: ellipsis;
221
+ overflow: hidden;
222
+ }
223
+
224
+ input:focus {
225
+ outline: none;
226
+ }
227
+
228
+ input::placeholder {
229
+ color: ${cssVars['vira-input-placeholder-color'].value};
230
+ }
231
+
232
+ .suffix {
233
+ font-weight: bold;
234
+ }
235
+ `;
236
+ },
237
+ stateInitStatic: {
238
+ forcedInputWidth: 0,
239
+ },
240
+ renderCallback: ({ inputs, dispatch, state, updateState, events }) => {
241
+ const { filtered: filteredValue } = filterToAllowedCharactersOnly({
242
+ value: inputs.value ?? '',
243
+ allowed: inputs.allowedInputs,
244
+ blocked: inputs.blockedInputs,
245
+ });
246
+ const iconTemplate = inputs.icon
247
+ ? html `
248
+ <${ViraIcon} ${assign(ViraIcon, { icon: inputs.icon })}></${ViraIcon}>
249
+ `
250
+ : '';
251
+ const forcedInputWidthStyles = inputs.fitText
252
+ ? css `
253
+ width: ${state.forcedInputWidth}px;
254
+ `
255
+ : '';
256
+ return html `
257
+ <label>
258
+ ${iconTemplate}
259
+ ${renderIf(!!inputs.fitText, html `
260
+ <span
261
+ class="size-span"
262
+ ${onResize(({ contentRect }) => {
263
+ updateState({ forcedInputWidth: contentRect.width });
264
+ })}
265
+ >
266
+ <pre>${filteredValue || inputs.placeholder || ''}</pre>
267
+ </span>
268
+ `)}
269
+ <input
270
+ class=${classMap({
271
+ 'have-value': !!filteredValue,
272
+ })}
273
+ style=${forcedInputWidthStyles}
274
+ autocomplete=${inputs.disableBrowserHelps ? 'off' : ''}
275
+ autocorrect=${inputs.disableBrowserHelps ? 'off' : ''}
276
+ autocapitalize=${inputs.disableBrowserHelps ? 'off' : ''}
277
+ spellcheck=${inputs.disableBrowserHelps ? 'false' : ''}
278
+ ?disabled=${inputs.disabled}
279
+ .value=${filteredValue}
280
+ ${listen('input', (event) => {
281
+ /**
282
+ * When attached to an input element (like here) this event type should
283
+ * always be InputEvent.
284
+ */
285
+ if (!(event instanceof InputEvent)) {
286
+ throw new Error(`Input event type mismatch: "${event.constructor.name}"`);
287
+ }
288
+ const inputElement = event.target;
289
+ if (!(inputElement instanceof HTMLInputElement)) {
290
+ throw new Error(`Failed to find input element target from input event.`);
291
+ }
292
+ /**
293
+ * This is usually a single character, but can be a bunch of characters in
294
+ * some circumstances. For example, when a bunch of characters are pasted,
295
+ * this will be the entire pasted contents.
296
+ */
297
+ const changedText = event.data;
298
+ const beforeChangeText = filteredValue;
299
+ // this will be overwritten below if blocked characters are encountered
300
+ let finalText = inputElement.value ?? '';
301
+ /**
302
+ * When changedText is falsy, that means an operation other than inserting
303
+ * characters happened. Such as: deleting, cutting the text, etc.
304
+ */
305
+ if (changedText) {
306
+ if (changedText.length === 1) {
307
+ if (!isAllowed({
308
+ value: changedText,
309
+ allowed: inputs.allowedInputs,
310
+ blocked: inputs.blockedInputs,
311
+ })) {
312
+ // prevent the change from happening
313
+ finalText = beforeChangeText;
314
+ dispatch(new events.inputBlocked(changedText));
315
+ }
316
+ }
317
+ // filters out blocked pasted letters
318
+ else {
319
+ const { filtered, blocked } = filterToAllowedCharactersOnly({
320
+ value: changedText,
321
+ allowed: inputs.allowedInputs,
322
+ blocked: inputs.blockedInputs,
323
+ });
324
+ finalText = filtered;
325
+ dispatch(new events.inputBlocked(blocked));
326
+ }
327
+ }
328
+ if (inputElement.value !== finalText) {
329
+ // this prevents blocked inputs by simply overwriting them
330
+ inputElement.value = finalText;
331
+ }
332
+ if (beforeChangeText !== finalText) {
333
+ dispatch(new events.valueChange(finalText));
334
+ }
335
+ })}
336
+ placeholder=${inputs.placeholder}
337
+ />
338
+ ${renderIf(!!inputs.suffix, html `
339
+ <div class="suffix">${inputs.suffix}</div>
340
+ `)}
341
+ <!--
342
+ These separate style elements are necessary so that we can select them as
343
+ siblings of the focused <input> element.
344
+ -->
345
+ <div class="border-style focus-border"></div>
346
+ <div class="border-style label-border"></div>
347
+ </label>
348
+ `;
349
+ },
350
+ });
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.viraIconColorCssVars = void 0;
4
- const lit_css_vars_1 = require("lit-css-vars");
5
- const genericIconColorCssVar = (0, lit_css_vars_1.defineCssVars)({
1
+ import { defineCssVars } from 'lit-css-vars';
2
+ const genericIconColorCssVar = defineCssVars({
6
3
  /**
7
4
  * Specifies the icon color as a whole. This will color both the icon stroke and icon fill
8
5
  * colors unless those respective CSS vars are specifically overridden. This CSS var value
@@ -11,10 +8,10 @@ const genericIconColorCssVar = (0, lit_css_vars_1.defineCssVars)({
11
8
  */
12
9
  'vira-icon-color': 'currentColor',
13
10
  });
14
- const specificIconCssVars = (0, lit_css_vars_1.defineCssVars)({
11
+ const specificIconCssVars = defineCssVars({
15
12
  /** To be used for coloring an icon's stroke. */
16
13
  'vira-icon-stroke-color': genericIconColorCssVar['vira-icon-color'].value,
17
14
  /** To be used for coloring an icon's fill. */
18
15
  'vira-icon-fill-color': genericIconColorCssVar['vira-icon-color'].value,
19
16
  });
20
- exports.viraIconColorCssVars = { ...genericIconColorCssVar, ...specificIconCssVars };
17
+ export const viraIconColorCssVars = { ...genericIconColorCssVar, ...specificIconCssVars };
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineIcon = void 0;
4
- function defineIcon({ name, svgTemplate, }) {
1
+ export function defineIcon({ name, svgTemplate, }) {
5
2
  const iconSvg = {
6
3
  name,
7
4
  svgTemplate,
8
5
  };
9
6
  return iconSvg;
10
7
  }
11
- exports.defineIcon = defineIcon;
@@ -1,21 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Element16Icon = void 0;
4
- const element_vir_1 = require("element-vir");
5
- const icon_svg_1 = require("../icon-svg");
6
- exports.Element16Icon = (0, icon_svg_1.defineIcon)({
1
+ import { html } from 'element-vir';
2
+ import { defineIcon } from '../icon-svg';
3
+ export const Element16Icon = defineIcon({
7
4
  name: 'Element16Icon',
8
- svgTemplate: (0, element_vir_1.html) `
5
+ svgTemplate: html `
9
6
  <svg
10
7
  xmlns="http://www.w3.org/2000/svg"
11
- xml:space="preserve"
12
8
  fill="none"
13
9
  width="16"
14
10
  height="16"
15
11
  viewBox="0 0 16 16"
16
- stroke-width="1px"
17
12
  >
18
- <path d="M4 5 1 8l3 3m8-6 3 3-3 3m-5 0 2-6" />
13
+ <path
14
+ stroke-width="1"
15
+ vector-effect="non-scaling-stroke"
16
+ d="M4 5 1 8l3 3m8-6 3 3-3 3m-5 0 2-6"
17
+ />
19
18
  </svg>
20
19
  `,
21
20
  });
@@ -1,21 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Element24Icon = void 0;
4
- const element_vir_1 = require("element-vir");
5
- const icon_svg_1 = require("../icon-svg");
6
- exports.Element24Icon = (0, icon_svg_1.defineIcon)({
1
+ import { html } from 'element-vir';
2
+ import { defineIcon } from '../icon-svg';
3
+ export const Element24Icon = defineIcon({
7
4
  name: 'Element24Icon',
8
- svgTemplate: (0, element_vir_1.html) `
5
+ svgTemplate: html `
9
6
  <svg
10
7
  xmlns="http://www.w3.org/2000/svg"
11
- xml:space="preserve"
12
8
  viewBox="0 0 24 24"
13
9
  fill="none"
14
10
  width="24"
15
11
  height="24"
16
- stroke-width="1px"
17
12
  >
18
- <path d="m7 7-5 5 5 5M17 7l5 5-5 5m-6 0 2-10" />
13
+ <path stroke-width="1px" d="m7 7-5 5 5 5M17 7l5 5-5 5m-6 0 2-10" />
19
14
  </svg>
20
15
  `,
21
16
  });
@@ -1,27 +1,10 @@
1
- "use strict";
2
1
  /** This file is automatically updated by update-icon-exports.ts */
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.allIconsByName = void 0;
19
- const element_16_icon_1 = require("./icon-svgs/element-16.icon");
20
- const element_24_icon_1 = require("./icon-svgs/element-24.icon");
21
- __exportStar(require("./icon-svg"), exports);
22
- __exportStar(require("./icon-svgs/element-16.icon"), exports);
23
- __exportStar(require("./icon-svgs/element-24.icon"), exports);
24
- exports.allIconsByName = {
25
- Element16Icon: element_16_icon_1.Element16Icon,
26
- Element24Icon: element_24_icon_1.Element24Icon,
2
+ import { Element16Icon } from './icon-svgs/element-16.icon';
3
+ import { Element24Icon } from './icon-svgs/element-24.icon';
4
+ export * from './icon-svg';
5
+ export * from './icon-svgs/element-16.icon';
6
+ export * from './icon-svgs/element-24.icon';
7
+ export const allIconsByName = {
8
+ Element16Icon,
9
+ Element24Icon,
27
10
  };
package/dist/index.js CHANGED
@@ -1,20 +1,4 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./elements"), exports);
18
- __exportStar(require("./icons"), exports);
19
- __exportStar(require("./styles"), exports);
20
- __exportStar(require("./util"), exports);
1
+ export * from './elements';
2
+ export * from './icons';
3
+ export * from './styles';
4
+ export * from './util';
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.viraDisabledStyles = void 0;
4
- const element_vir_1 = require("element-vir");
5
- exports.viraDisabledStyles = (0, element_vir_1.css) `
1
+ import { css } from 'element-vir';
2
+ export const viraDisabledStyles = css `
6
3
  pointer-events: none;
7
4
  opacity: 0.3;
8
5
  `;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.viraAnimationDurations = void 0;
4
- const lit_css_vars_1 = require("lit-css-vars");
5
- exports.viraAnimationDurations = (0, lit_css_vars_1.defineCssVars)({
1
+ import { defineCssVars } from 'lit-css-vars';
2
+ export const viraAnimationDurations = defineCssVars({
6
3
  /** A longer duration to emphasize the animation. */
7
4
  'vira-pretty-animation-duration': '300ms',
8
5
  /**
@@ -1,5 +1,6 @@
1
1
  export declare const viraFocusCssVars: import("lit-css-vars").CssVarDefinitions<{
2
2
  'vira-focus-outline-color': string;
3
+ 'vira-focus-outline-border-radius': import("element-vir").CSSResult;
3
4
  }>;
4
5
  /**
5
6
  * Create styles that look like an outline for the given selector.
@@ -17,4 +18,5 @@ export declare function createFocusStyles({ mainSelector, elementBorderSize, out
17
18
  elementBorderSize: number;
18
19
  outlineGap?: number;
19
20
  outlineWidth?: number;
21
+ borderRadius?: number;
20
22
  }): import("element-vir").CSSResult;
@@ -1,12 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createFocusStyles = exports.viraFocusCssVars = void 0;
4
- const element_vir_1 = require("element-vir");
5
- const lit_1 = require("lit");
6
- const lit_css_vars_1 = require("lit-css-vars");
7
- const number_1 = require("../util/number");
8
- exports.viraFocusCssVars = (0, lit_css_vars_1.defineCssVars)({
1
+ import { css } from 'element-vir';
2
+ import { unsafeCSS } from 'lit';
3
+ import { defineCssVars } from 'lit-css-vars';
4
+ import { toPixel } from '../util/number';
5
+ import { viraCssVars } from './vira-css-vars';
6
+ export const viraFocusCssVars = defineCssVars({
9
7
  'vira-focus-outline-color': 'blue',
8
+ 'vira-focus-outline-border-radius': css `calc(${viraCssVars['vira-form-input-border-radius'].value} + 4px)`,
10
9
  });
11
10
  /**
12
11
  * Create styles that look like an outline for the given selector.
@@ -14,10 +13,10 @@ exports.viraFocusCssVars = (0, lit_css_vars_1.defineCssVars)({
14
13
  * It is recommended to use the pseudo selectors ":focus:focus-visible:not(:active)" to preventing
15
14
  * clicking from creating focus styles in Chrome.
16
15
  */
17
- function createFocusStyles({ mainSelector, elementBorderSize, outlineGap = 2, outlineWidth = 3, }) {
18
- const outlineSpacing = (0, lit_1.unsafeCSS)((0, number_1.toPixel)(outlineWidth + outlineGap + elementBorderSize));
19
- return (0, element_vir_1.css) `
20
- ${(0, lit_1.unsafeCSS)(mainSelector)}::after {
16
+ export function createFocusStyles({ mainSelector, elementBorderSize, outlineGap = 2, outlineWidth = 3, }) {
17
+ const outlineSpacing = unsafeCSS(toPixel(outlineWidth + outlineGap + elementBorderSize));
18
+ return css `
19
+ ${unsafeCSS(mainSelector)}::after {
21
20
  content: '';
22
21
  top: calc(${outlineSpacing} * -1);
23
22
  left: calc(${outlineSpacing} * -1);
@@ -26,10 +25,9 @@ function createFocusStyles({ mainSelector, elementBorderSize, outlineGap = 2, ou
26
25
  height: calc(100% + calc(${outlineSpacing} * 2));
27
26
  box-sizing: border-box;
28
27
  pointer-events: none;
29
- border: ${outlineWidth}px solid ${exports.viraFocusCssVars['vira-focus-outline-color'].value};
30
- border-radius: 12px;
28
+ border: ${outlineWidth}px solid ${viraFocusCssVars['vira-focus-outline-color'].value};
29
+ border-radius: ${viraFocusCssVars['vira-focus-outline-border-radius'].value};
31
30
  z-index: 100;
32
31
  }
33
32
  `;
34
33
  }
35
- exports.createFocusStyles = createFocusStyles;
@@ -1,21 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./disabled"), exports);
18
- __exportStar(require("./durations"), exports);
19
- __exportStar(require("./focus"), exports);
20
- __exportStar(require("./native-styles"), exports);
21
- __exportStar(require("./user-select"), exports);
1
+ export * from './disabled';
2
+ export * from './durations';
3
+ export * from './focus';
4
+ export * from './native-styles';
5
+ export * from './user-select';
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeNativeFormStyles = void 0;
4
- const element_vir_1 = require("element-vir");
5
- exports.removeNativeFormStyles = (0, element_vir_1.css) `
1
+ import { css } from 'element-vir';
2
+ export const removeNativeFormStyles = css `
6
3
  background: none;
7
4
  padding: 0;
8
5
  margin: 0;
9
6
  border: none;
10
7
  font: inherit;
11
8
  color: inherit;
12
- cursor: pointer;
13
9
  text-transform: inherit;
14
10
  text-decoration: inherit;
15
11
  -webkit-tap-highlight-color: transparent;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noUserSelect = void 0;
4
- const element_vir_1 = require("element-vir");
5
- exports.noUserSelect = (0, element_vir_1.css) `
1
+ import { css } from 'element-vir';
2
+ export const noUserSelect = css `
6
3
  -webkit-touch-callout: none; /* iOS Safari */
7
4
  -webkit-user-select: none; /* Safari */
8
5
  user-select: none; /* Non-prefixed version, currently supported by Chrome, Edge, Opera and Firefox */
@@ -0,0 +1,3 @@
1
+ export declare const viraCssVars: import("lit-css-vars").CssVarDefinitions<{
2
+ 'vira-form-input-border-radius': string;
3
+ }>;
@@ -0,0 +1,4 @@
1
+ import { defineCssVars } from 'lit-css-vars';
2
+ export const viraCssVars = defineCssVars({
3
+ 'vira-form-input-border-radius': '8px',
4
+ });
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./number"), exports);
1
+ export * from './number';
@@ -1,11 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toPercent = exports.toPixel = void 0;
4
- function toPixel(value) {
1
+ export function toPixel(value) {
5
2
  return `${value}px`;
6
3
  }
7
- exports.toPixel = toPixel;
8
- function toPercent(value) {
4
+ export function toPercent(value) {
9
5
  return `${value}%`;
10
6
  }
11
- exports.toPercent = toPercent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/electrovir/vira",
@@ -29,21 +29,22 @@
29
29
  "test:docs": "virmator code-in-markdown check"
30
30
  },
31
31
  "dependencies": {
32
- "element-vir": "^13.0.0",
33
- "lit-css-vars": "^2.0.2"
32
+ "element-vir": "^13.0.4",
33
+ "lit-css-vars": "^2.0.3"
34
34
  },
35
35
  "devDependencies": {
36
- "@augment-vir/browser-testing": "^14.2.0",
37
- "@augment-vir/node-js": "^14.2.0",
38
- "@open-wc/testing": "^3.1.8",
36
+ "@augment-vir/browser-testing": "^14.3.0",
37
+ "@augment-vir/node-js": "^14.3.0",
38
+ "@open-wc/testing": "^3.2.0",
39
+ "@types/chai": "^4.3.5",
39
40
  "@types/mocha": "^10.0.1",
40
41
  "@web/dev-server-esbuild": "^0.4.1",
41
42
  "@web/test-runner": "^0.16.1",
42
43
  "@web/test-runner-commands": "^0.7.0",
43
- "@web/test-runner-playwright": "^0.10.0",
44
+ "@web/test-runner-playwright": "^0.10.1",
44
45
  "@web/test-runner-visual-regression": "^0.8.0",
45
- "istanbul-smart-text-reporter": "^1.1.1",
46
- "typescript": "^5.0.4",
46
+ "istanbul-smart-text-reporter": "^1.1.2",
47
+ "typescript": "^5.1.3",
47
48
  "vite": "^4.3.9",
48
49
  "vite-tsconfig-paths": "^4.2.0"
49
50
  }