@neovici/cosmoz-input 1.4.3 → 1.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.
Files changed (3) hide show
  1. package/cosmoz-input.js +7 -2
  2. package/package.json +12 -13
  3. package/styles.js +53 -17
package/cosmoz-input.js CHANGED
@@ -15,7 +15,9 @@ export const Input = host => {
15
15
  value,
16
16
  placeholder,
17
17
  readonly,
18
- disabled
18
+ disabled,
19
+ min,
20
+ max
19
21
  } = host,
20
22
  { onChange, onFocus, onInput } = useInput(host),
21
23
  onBeforeInput = useAllowedPattern(allowedPattern);
@@ -25,7 +27,8 @@ export const Input = host => {
25
27
  ?readonly=${ readonly } ?aria-disabled=${ disabled } ?disabled=${ disabled }
26
28
  .value=${ live(value ?? '') }
27
29
  @beforeinput=${ onBeforeInput } @input=${ onInput }
28
- @change=${ onChange } @focus=${ onFocus } @blur=${ onFocus }>`
30
+ @change=${ onChange } @focus=${ onFocus } @blur=${ onFocus }
31
+ min=${ ifDefined(min) } max=${ ifDefined(max) }>`
29
32
  , host);
30
33
  },
31
34
 
@@ -33,6 +36,8 @@ export const Input = host => {
33
36
  'type',
34
37
  'pattern',
35
38
  'allowed-pattern',
39
+ 'min',
40
+ 'max',
36
41
  ...attributes
37
42
  ];
38
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-input",
3
- "version": "1.4.3",
3
+ "version": "1.6.0",
4
4
  "description": "A input web component",
5
5
  "keywords": [
6
6
  "lit-html",
@@ -56,25 +56,24 @@
56
56
  ]
57
57
  },
58
58
  "dependencies": {
59
- "@neovici/cosmoz-utils": "^3.19.0",
59
+ "@neovici/cosmoz-utils": "^3.23.0",
60
60
  "haunted": "^4.8.0",
61
- "lit-html": "^1.4.1"
61
+ "lit-html": "^1.4.0"
62
62
  },
63
63
  "devDependencies": {
64
- "@commitlint/cli": "^13.0.0",
65
- "@commitlint/config-conventional": "^13.0.0",
66
- "@neovici/eslint-config": "^1.2.0",
64
+ "@commitlint/cli": "^15.0.0",
65
+ "@commitlint/config-conventional": "^15.0.0",
66
+ "@neovici/eslint-config": "^1.3.0",
67
67
  "@open-wc/demoing-storybook": "^2.1.0",
68
68
  "@open-wc/testing": "^2.5.0",
69
- "@semantic-release/changelog": "^5.0.1",
70
- "@semantic-release/git": "^9.0.0",
69
+ "@semantic-release/changelog": "^6.0.0",
70
+ "@semantic-release/git": "^10.0.0",
71
71
  "@storybook/storybook-deployer": "^2.8.5",
72
72
  "@web/test-runner": "^0.13.0",
73
73
  "@web/test-runner-selenium": "^0.5.0",
74
- "eslint": "^7.0.0",
75
- "husky": "^6.0.0",
76
- "semantic-release": "^17.4.0",
77
- "sinon": "^11.0.0",
78
- "typescript": "^4.3.0"
74
+ "husky": "^7.0.0",
75
+ "semantic-release": "^18.0.0",
76
+ "sinon": "^12.0.0",
77
+ "typescript": "^4.4.0"
79
78
  }
80
79
  }
package/styles.js CHANGED
@@ -1,22 +1,36 @@
1
1
  export const styles = `
2
2
  :host {
3
+ --font-family: var(--cosmoz-input-font-family, var(--paper-font-subhead_-_font-family, 'Roboto', 'Noto', sans-serif));
4
+ --font-size: var(--cosmoz-input-font-size, var(--paper-font-subhead_-_font-size, 16px));
5
+ --line-height: var(--cosmoz-input-line-height, var(--paper-font-subhead_-_line-height, 24px));
6
+ --label-scale: var(--cosmoz-input-label-scale, 0.75);
7
+ --disabled-opacity: var(--cosmoz-input-disabled-opacity, var(--paper-input-container-disabled_-_opacity, 0.33));
8
+ --disabled-line-opacity: var(--cosmoz-input-disabled-line-opacity, var(--paper-input-container-underline-disabled_-_opacity, 1));
9
+ --invalid-color: var(--cosmoz-input-invalid-color, var(--paper-input-container-invalid-color, var(--error-color, #fc5c5b)));
10
+ --bg: var(--cosmoz-input-background);
11
+ --focused-bg: var(--cosmoz-input-focused-background, var(--bg));
12
+ --color: var(--cosmoz-input-color, var(--secondary-text-color, #737373));
13
+ --focused-color: var(--cosmoz-input-focused-color, var(--primary-color, #3f51b5));
14
+
3
15
  display: block;
4
16
  padding: 8px 0;
5
17
  padding-top: var(--paper-input-container_-_padding-top, 8px);
6
- }
18
+ position: relative;
7
19
 
8
- :host, label, #input {
9
- font-family: var(--cosmoz-subhead-font-family, var(--paper-font-subhead_-_font-family, 'Roboto', 'Noto', sans-serif));
10
- font-size: var(--cosmoz-subhead-font-size, var(--paper-font-subhead_-_font-size, 16px));
11
- line-height: var(--cosmoz-subhead-line-height, var(--paper-font-subhead_-_line-height, 24px));
12
- display: block;
20
+ font-family: var(--font-family);
21
+ font-size: var(--font-size);
22
+ line-height: var(--line-height);
13
23
  }
14
24
 
15
25
  :host([disabled]) {
16
- opacity: var(--cosmoz-input-disabled-opacity, var(--paper-input-container-disabled_-_opacity, 0.33));
26
+ opacity: var(--disabled-opacity);
17
27
  pointer-events: none;
18
28
  }
19
29
 
30
+ .float {
31
+ line-height: calc(var(--line-height) * var(--label-scale));
32
+ }
33
+
20
34
  .wrap {
21
35
  display: flex;
22
36
  align-items: center;
@@ -35,11 +49,14 @@ export const styles = `
35
49
  border: none;
36
50
  width: 100%;
37
51
  max-width: 100%;
38
- background: var(--cosmoz-input-background, initial);
52
+ display: block;
53
+ background: var(--bg);
54
+ line-height: inherit;
55
+ font-size: inherit;
39
56
  }
40
57
 
41
58
  :host(:focus-within) #input {
42
- background: var(--cosmoz-input-focused-background, var(--cosmoz-input-background, initial));
59
+ background: var(--focused-bg);
43
60
  }
44
61
  label {
45
62
  position: absolute;
@@ -48,7 +65,7 @@ export const styles = `
48
65
  width: 100%;
49
66
  transition: transform 0.25s, width 0.25s;
50
67
  transform-origin: left top;
51
- color: var(--secondary-text-color, #737373);
68
+ color: var(--color);
52
69
  white-space: nowrap;
53
70
  overflow: hidden;
54
71
  text-overflow: ellipsis;
@@ -56,21 +73,40 @@ export const styles = `
56
73
 
57
74
  :host([always-float-label]) label,
58
75
  #input:not(:placeholder-shown) + label {
59
- transform: translateY(-75%) scale(0.75);
76
+ transform: translateY(calc(var(--label-scale) * -100%)) scale(var(--label-scale));
60
77
  }
61
78
  #input:not(:placeholder-shown):focus + label {
62
- color: var(--primary-color, #3f51b5);
79
+ color: var(--focused-color);
63
80
  }
64
81
 
65
82
  .line {
66
- border-bottom: 2px solid var(--secondary-text-color, #737373);
83
+ padding-top: 1px;
84
+ border-bottom: 1px solid var(--color);
85
+ position: relative;
86
+ }
87
+ .line::before {
88
+ content: '';
89
+ position: absolute;
90
+ display: block;
91
+ border-bottom: 2px solid transparent;
92
+ border-bottom-color: inherit;
93
+ left: 0;
94
+ right: 0;
95
+ top: 0;
96
+ transform: scale3d(0,1,1);
97
+ transform-origin: center center;
98
+ z-index: 1;
99
+ }
100
+ :host(:focus-within) .line::before {
101
+ transform: none;
102
+ transition: 0.25s transform ease;
67
103
  }
68
104
  :host(:focus-within) .line {
69
- border-bottom-color: var(--primary-color, #3f51b5);
105
+ border-bottom-color: var(--focused-color);
70
106
  }
71
107
  :host([disabled]) .line {
72
108
  border-bottom-style: dashed;
73
- opacity: var(--cosmoz-input-disabled-line-opacity, var(--paper-input-container-underline-disabled_-_opacity, 1));
109
+ opacity: var(--disabled-line-opacity);
74
110
  }
75
111
 
76
112
  :host([no-label-float]) .float,
@@ -87,10 +123,10 @@ export const styles = `
87
123
  max-width: 100%;
88
124
  }
89
125
  :host([invalid]) label, .error {
90
- color: var(--paper-input-container-invalid-color, var(--error-color, #fc5c5b));
126
+ color: var(--invalid-color);
91
127
  }
92
128
  :host([invalid]) .line {
93
- border-bottom-color: var(--paper-input-container-invalid-color, var(--error-color, #fc5c5b));
129
+ border-bottom-color: var(--invalid-color);
94
130
  }
95
131
 
96
132
  #input::-webkit-inner-spin-button {