vira 0.3.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.
@@ -1,17 +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 vira_input_element_book_1 = require("../elements/vira-input/vira-input.element.book");
9
- const icons_book_1 = require("../icons/icons.book");
10
- exports.allElementBookEntries = [
11
- elements_book_1.elementsBookChapter,
12
- ...icons_book_1.iconBookEntries,
13
- ...vira_button_element_book_1.viraButtonBookEntries,
14
- ...vira_collapsible_wrapper_element_book_1.viraCollapsibleBookEntries,
15
- ...vira_icon_element_book_1.viraIconBookEntries,
16
- ...vira_input_element_book_1.viraInputBookEntries,
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,
17
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
+ });
@@ -1,22 +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);
22
- __exportStar(require("./vira-input/vira-input.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';
@@ -1,21 +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 vira_css_vars_1 = require("../../styles/vira-css-vars");
11
- const define_vira_element_1 = require("../define-vira-element");
12
- const vira_icon_element_1 = require("../vira-icon/vira-icon.element");
13
- 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;
14
11
  (function (ViraButtonStyleEnum) {
15
12
  ViraButtonStyleEnum["Default"] = "vira-button-default";
16
13
  ViraButtonStyleEnum["Outline"] = "vira-button-outline";
17
- })(ViraButtonStyleEnum = exports.ViraButtonStyleEnum || (exports.ViraButtonStyleEnum = {}));
18
- exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
14
+ })(ViraButtonStyleEnum || (ViraButtonStyleEnum = {}));
15
+ export const ViraButton = defineViraElement()({
19
16
  tagName: 'vira-button',
20
17
  hostClasses: {
21
18
  'vira-button-outline-style': ({ inputs }) => inputs.buttonStyle === ViraButtonStyleEnum.Outline,
@@ -32,7 +29,7 @@ exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
32
29
  'vira-button-internal-background-color': '',
33
30
  'vira-button-padding': '5px 10px',
34
31
  },
35
- styles: ({ hostClasses, cssVars }) => (0, element_vir_1.css) `
32
+ styles: ({ hostClasses, cssVars }) => css `
36
33
  :host {
37
34
  font-weight: bold;
38
35
  display: inline-flex;
@@ -40,10 +37,10 @@ exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
40
37
  vertical-align: middle;
41
38
  align-items: center;
42
39
  box-sizing: border-box;
43
- ${styles_1.noUserSelect};
40
+ ${noUserSelect};
44
41
  ${cssVars['vira-button-internal-background-color'].name}: ${cssVars['vira-button-primary-color'].value};
45
42
  ${cssVars['vira-button-internal-foreground-color'].name}: ${cssVars['vira-button-secondary-color'].value};
46
- ${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}
47
44
  }
48
45
 
49
46
  :host(:hover) button,
@@ -57,7 +54,7 @@ exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
57
54
  }
58
55
 
59
56
  ${hostClasses['vira-button-disabled'].selector} {
60
- ${disabled_1.viraDisabledStyles};
57
+ ${viraDisabledStyles};
61
58
  }
62
59
 
63
60
  ${hostClasses['vira-button-outline-style'].selector} button {
@@ -68,7 +65,7 @@ exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
68
65
 
69
66
  button {
70
67
  cursor: pointer;
71
- ${native_styles_1.removeNativeFormStyles};
68
+ ${removeNativeFormStyles};
72
69
  position: relative;
73
70
  width: 100%;
74
71
  height: 100%;
@@ -78,41 +75,41 @@ exports.ViraButton = (0, define_vira_element_1.defineViraElement)()({
78
75
  display: inline-flex;
79
76
  justify-content: center;
80
77
  align-items: center;
81
- border-radius: ${vira_css_vars_1.viraCssVars['vira-form-input-border-radius'].value};
78
+ border-radius: ${viraCssVars['vira-form-input-border-radius'].value};
82
79
  background-color: ${cssVars['vira-button-internal-background-color'].value};
83
80
  color: ${cssVars['vira-button-internal-foreground-color'].value};
84
81
  padding: ${cssVars['vira-button-padding'].value};
85
- transition: color ${durations_1.viraAnimationDurations['vira-interaction-animation-duration'].value},
82
+ transition: color ${viraAnimationDurations['vira-interaction-animation-duration'].value},
86
83
  background-color
87
- ${durations_1.viraAnimationDurations['vira-interaction-animation-duration'].value},
88
- 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};
89
86
  }
90
87
 
91
- ${(0, focus_1.createFocusStyles)({
88
+ ${createFocusStyles({
92
89
  mainSelector: 'button:focus:focus-visible:not(:active):not([disabled])',
93
90
  elementBorderSize: 2,
94
91
  })}
95
92
 
96
- button ${vira_icon_element_1.ViraIcon} + .text-template {
93
+ button ${ViraIcon} + .text-template {
97
94
  margin-left: 8px;
98
95
  }
99
96
  `,
100
97
  renderCallback: ({ inputs }) => {
101
98
  const iconTemplate = inputs.icon
102
- ? (0, element_vir_1.html) `
103
- <${vira_icon_element_1.ViraIcon}
104
- ${(0, element_vir_1.assign)(vira_icon_element_1.ViraIcon, {
99
+ ? html `
100
+ <${ViraIcon}
101
+ ${assign(ViraIcon, {
105
102
  icon: inputs.icon,
106
103
  })}
107
- ></${vira_icon_element_1.ViraIcon}>
104
+ ></${ViraIcon}>
108
105
  `
109
106
  : '';
110
107
  const textTemplate = inputs.text
111
- ? (0, element_vir_1.html) `
108
+ ? html `
112
109
  <span class="text-template">${inputs.text}</span>
113
110
  `
114
111
  : '';
115
- return (0, element_vir_1.html) `
112
+ return html `
116
113
  <button ?disabled=${inputs.disabled}>${iconTemplate} ${textTemplate}</button>
117
114
  `;
118
115
  },
@@ -1,26 +1,23 @@
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 {
23
- ${styles_1.removeNativeFormStyles};
20
+ ${removeNativeFormStyles};
24
21
  cursor: pointer;
25
22
  }
26
23
 
@@ -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,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 {
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViraInput = void 0;
4
- const element_vir_1 = require("element-vir");
5
- const styles_1 = require("../../styles");
6
- const focus_1 = require("../../styles/focus");
7
- const native_styles_1 = require("../../styles/native-styles");
8
- const vira_css_vars_1 = require("../../styles/vira-css-vars");
9
- const define_vira_element_1 = require("../define-vira-element");
10
- const vira_icon_element_1 = require("../vira-icon/vira-icon.element");
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';
11
8
  function doesMatch({ input, matcher }) {
12
9
  if (!input || !matcher) {
13
10
  return true;
@@ -59,7 +56,7 @@ function filterToAllowedCharactersOnly(inputs) {
59
56
  blocked: blocked.join(''),
60
57
  };
61
58
  }
62
- exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
59
+ export const ViraInput = defineViraElement()({
63
60
  tagName: 'vira-input',
64
61
  hostClasses: {
65
62
  'vira-input-disabled': ({ inputs }) => !!inputs.disabled,
@@ -80,27 +77,27 @@ exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
80
77
  * Fires whenever a user input created a new value. Does not fire if all input letters are
81
78
  * filtered out due to input restrictions.
82
79
  */
83
- valueChange: (0, element_vir_1.defineElementEvent)(),
80
+ valueChange: defineElementEvent(),
84
81
  /**
85
82
  * Fires when inputs are blocked. Useful for showing warnings or error messages to inform
86
83
  * the user why their input did not propagate if it was blocked. This does not fire for text
87
84
  * that was blocked out of programmatic "value" property assignments.
88
85
  */
89
- inputBlocked: (0, element_vir_1.defineElementEvent)(),
86
+ inputBlocked: defineElementEvent(),
90
87
  },
91
88
  styles: ({ hostClasses, cssVars }) => {
92
- return (0, element_vir_1.css) `
89
+ return css `
93
90
  :host {
94
91
  position: relative;
95
92
  display: inline-flex;
96
93
  width: 224px;
97
94
  box-sizing: border-box;
98
- ${focus_1.viraFocusCssVars['vira-focus-outline-color'].name}: ${cssVars['vira-input-focus-border-color'].value};
95
+ ${viraFocusCssVars['vira-focus-outline-color'].name}: ${cssVars['vira-input-focus-border-color'].value};
99
96
  color: ${cssVars['vira-input-text-color'].value};
100
97
  }
101
98
 
102
99
  ${hostClasses['vira-input-disabled'].selector} {
103
- ${styles_1.viraDisabledStyles};
100
+ ${viraDisabledStyles};
104
101
  }
105
102
 
106
103
  ${hostClasses['vira-input-fit-text'].selector} {
@@ -120,7 +117,7 @@ exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
120
117
  text-align: center;
121
118
  }
122
119
  ${hostClasses['vira-input-fit-text'].selector} .size-span {
123
- ${native_styles_1.removeNativeFormStyles};
120
+ ${removeNativeFormStyles};
124
121
  font-family: inherit;
125
122
  display: inline-block;
126
123
  font-size: inherit;
@@ -132,13 +129,13 @@ exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
132
129
  pointer-events: none;
133
130
  z-index: -1;
134
131
  width: min-content;
135
- ${styles_1.noUserSelect};
132
+ ${noUserSelect};
136
133
  vertical-align: middle;
137
134
  max-height: 100%;
138
135
  }
139
136
 
140
137
  pre {
141
- ${native_styles_1.removeNativeFormStyles};
138
+ ${removeNativeFormStyles};
142
139
  font: inherit;
143
140
  /*
144
141
  Leave at least a few pixels for the cursor bar when there is no text at all.
@@ -155,7 +152,7 @@ exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
155
152
  left: 0;
156
153
  width: 100%;
157
154
  height: 100%;
158
- border-radius: ${vira_css_vars_1.viraCssVars['vira-form-input-border-radius'].value};
155
+ border-radius: ${viraCssVars['vira-form-input-border-radius'].value};
159
156
  z-index: 0;
160
157
  pointer-events: none;
161
158
  }
@@ -165,11 +162,11 @@ exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
165
162
  left: -1px;
166
163
  border: 1px solid ${cssVars['vira-input-border-color'].value};
167
164
  transition: border
168
- ${styles_1.viraAnimationDurations['vira-interaction-animation-duration'].value};
165
+ ${viraAnimationDurations['vira-interaction-animation-duration'].value};
169
166
  }
170
167
 
171
168
  label {
172
- ${native_styles_1.removeNativeFormStyles};
169
+ ${removeNativeFormStyles};
173
170
  max-width: 100%;
174
171
  flex-grow: 1;
175
172
  cursor: pointer;
@@ -178,7 +175,7 @@ exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
178
175
  align-items: center;
179
176
  position: relative;
180
177
  padding: 0 ${cssVars['vira-input-padding-horizontal'].value};
181
- border-radius: ${vira_css_vars_1.viraCssVars['vira-form-input-border-radius'].value};
178
+ border-radius: ${viraCssVars['vira-form-input-border-radius'].value};
182
179
  background-color: transparent;
183
180
  /*
184
181
  Border colors are actually applied via the .label-border class. However, we must
@@ -188,17 +185,17 @@ exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
188
185
  gap: 4px;
189
186
  }
190
187
 
191
- ${(0, focus_1.createFocusStyles)({
188
+ ${createFocusStyles({
192
189
  mainSelector: 'input:focus:focus-visible:not(:active):not([disabled]) ~ .focus-border',
193
190
  elementBorderSize: 0,
194
191
  })}
195
192
 
196
- ${vira_icon_element_1.ViraIcon} {
193
+ ${ViraIcon} {
197
194
  margin-right: calc(${cssVars['vira-input-padding-horizontal'].value} - 4px);
198
195
  }
199
196
 
200
197
  input {
201
- ${native_styles_1.removeNativeFormStyles};
198
+ ${removeNativeFormStyles};
202
199
  cursor: text;
203
200
  margin: ${cssVars['vira-input-padding-vertical'].value} 0;
204
201
  flex-grow: 1;
@@ -247,22 +244,22 @@ exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
247
244
  blocked: inputs.blockedInputs,
248
245
  });
249
246
  const iconTemplate = inputs.icon
250
- ? (0, element_vir_1.html) `
251
- <${vira_icon_element_1.ViraIcon} ${(0, element_vir_1.assign)(vira_icon_element_1.ViraIcon, { icon: inputs.icon })}></${vira_icon_element_1.ViraIcon}>
247
+ ? html `
248
+ <${ViraIcon} ${assign(ViraIcon, { icon: inputs.icon })}></${ViraIcon}>
252
249
  `
253
250
  : '';
254
251
  const forcedInputWidthStyles = inputs.fitText
255
- ? (0, element_vir_1.css) `
252
+ ? css `
256
253
  width: ${state.forcedInputWidth}px;
257
254
  `
258
255
  : '';
259
- return (0, element_vir_1.html) `
256
+ return html `
260
257
  <label>
261
258
  ${iconTemplate}
262
- ${(0, element_vir_1.renderIf)(!!inputs.fitText, (0, element_vir_1.html) `
259
+ ${renderIf(!!inputs.fitText, html `
263
260
  <span
264
261
  class="size-span"
265
- ${(0, element_vir_1.onResize)(({ contentRect }) => {
262
+ ${onResize(({ contentRect }) => {
266
263
  updateState({ forcedInputWidth: contentRect.width });
267
264
  })}
268
265
  >
@@ -270,7 +267,7 @@ exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
270
267
  </span>
271
268
  `)}
272
269
  <input
273
- class=${(0, element_vir_1.classMap)({
270
+ class=${classMap({
274
271
  'have-value': !!filteredValue,
275
272
  })}
276
273
  style=${forcedInputWidthStyles}
@@ -280,7 +277,7 @@ exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
280
277
  spellcheck=${inputs.disableBrowserHelps ? 'false' : ''}
281
278
  ?disabled=${inputs.disabled}
282
279
  .value=${filteredValue}
283
- ${(0, element_vir_1.listen)('input', (event) => {
280
+ ${listen('input', (event) => {
284
281
  /**
285
282
  * When attached to an input element (like here) this event type should
286
283
  * always be InputEvent.
@@ -338,7 +335,7 @@ exports.ViraInput = (0, define_vira_element_1.defineViraElement)()({
338
335
  })}
339
336
  placeholder=${inputs.placeholder}
340
337
  />
341
- ${(0, element_vir_1.renderIf)(!!inputs.suffix, (0, element_vir_1.html) `
338
+ ${renderIf(!!inputs.suffix, html `
342
339
  <div class="suffix">${inputs.suffix}</div>
343
340
  `)}
344
341
  <!--
@@ -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,11 +1,8 @@
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
8
  fill="none"
@@ -1,11 +1,8 @@
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
8
  viewBox="0 0 24 24"
@@ -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,14 +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
- const vira_css_vars_1 = require("./vira-css-vars");
9
- 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({
10
7
  'vira-focus-outline-color': 'blue',
11
- 'vira-focus-outline-border-radius': (0, element_vir_1.css) `calc(${vira_css_vars_1.viraCssVars['vira-form-input-border-radius'].value} + 4px)`,
8
+ 'vira-focus-outline-border-radius': css `calc(${viraCssVars['vira-form-input-border-radius'].value} + 4px)`,
12
9
  });
13
10
  /**
14
11
  * Create styles that look like an outline for the given selector.
@@ -16,10 +13,10 @@ exports.viraFocusCssVars = (0, lit_css_vars_1.defineCssVars)({
16
13
  * It is recommended to use the pseudo selectors ":focus:focus-visible:not(:active)" to preventing
17
14
  * clicking from creating focus styles in Chrome.
18
15
  */
19
- function createFocusStyles({ mainSelector, elementBorderSize, outlineGap = 2, outlineWidth = 3, }) {
20
- const outlineSpacing = (0, lit_1.unsafeCSS)((0, number_1.toPixel)(outlineWidth + outlineGap + elementBorderSize));
21
- return (0, element_vir_1.css) `
22
- ${(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 {
23
20
  content: '';
24
21
  top: calc(${outlineSpacing} * -1);
25
22
  left: calc(${outlineSpacing} * -1);
@@ -28,10 +25,9 @@ function createFocusStyles({ mainSelector, elementBorderSize, outlineGap = 2, ou
28
25
  height: calc(100% + calc(${outlineSpacing} * 2));
29
26
  box-sizing: border-box;
30
27
  pointer-events: none;
31
- border: ${outlineWidth}px solid ${exports.viraFocusCssVars['vira-focus-outline-color'].value};
32
- border-radius: ${exports.viraFocusCssVars['vira-focus-outline-border-radius'].value};
28
+ border: ${outlineWidth}px solid ${viraFocusCssVars['vira-focus-outline-color'].value};
29
+ border-radius: ${viraFocusCssVars['vira-focus-outline-border-radius'].value};
33
30
  z-index: 100;
34
31
  }
35
32
  `;
36
33
  }
37
- 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,8 +1,5 @@
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;
@@ -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 */
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.viraCssVars = void 0;
4
- const lit_css_vars_1 = require("lit-css-vars");
5
- exports.viraCssVars = (0, lit_css_vars_1.defineCssVars)({
1
+ import { defineCssVars } from 'lit-css-vars';
2
+ export const viraCssVars = defineCssVars({
6
3
  'vira-form-input-border-radius': '8px',
7
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.3.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
  }