@awes-io/ui 2.34.0 → 2.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,57 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.36.0](https://github.com/awes-io/client/compare/@awes-io/ui@2.35.0...@awes-io/ui@2.36.0) (2021-12-10)
7
+
8
+
9
+ ### Features
10
+
11
+ * logo switching added ([e5e7328](https://github.com/awes-io/client/commit/e5e732812e9acb5c3a6c810d9a7346affa422988))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.35.0](https://github.com/awes-io/client/compare/@awes-io/ui@2.34.2...@awes-io/ui@2.35.0) (2021-12-04)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * default date format ([3435466](https://github.com/awes-io/client/commit/3435466e8ff789d64682ba99e5125eaa5dabf723))
23
+
24
+
25
+ ### Features
26
+
27
+ * **aw-birthday-picker:** leap year support ([43805c3](https://github.com/awes-io/client/commit/43805c3cecacec61340f512fe8e9dfcfae4ba1fb))
28
+ * **aw-date:** editable format validation added ([307ec9e](https://github.com/awes-io/client/commit/307ec9e662f32839178cab4d3c14e506b2abbc97))
29
+ * **aw-date:** editable input ([f6f7237](https://github.com/awes-io/client/commit/f6f723755f3cc9ca1c09d33860ea38c403c023ff))
30
+
31
+
32
+
33
+
34
+
35
+ ## [2.34.2](https://github.com/awes-io/client/compare/@awes-io/ui@2.34.1...@awes-io/ui@2.34.2) (2021-11-26)
36
+
37
+
38
+ ### Bug Fixes
39
+
40
+ * **aw-tel:** type button added to dropdown button ([c1369cd](https://github.com/awes-io/client/commit/c1369cd16efb9b569f5a41a94da2eee746a8e40d))
41
+
42
+
43
+
44
+
45
+
46
+ ## [2.34.1](https://github.com/awes-io/client/compare/@awes-io/ui@2.34.0...@awes-io/ui@2.34.1) (2021-11-25)
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * **aw-tel:** check if given value is string before parsing ([4161fb6](https://github.com/awes-io/client/commit/4161fb67b57ccea772a390769dab200baee15a44))
52
+
53
+
54
+
55
+
56
+
6
57
  # [2.34.0](https://github.com/awes-io/client/compare/@awes-io/ui@2.33.0...@awes-io/ui@2.34.0) (2021-11-25)
7
58
 
8
59
 
@@ -755,6 +755,9 @@ export default {
755
755
  },
756
756
 
757
757
  _selectIndex(index) {
758
+ const _option = this.optionsList.find((opt) => opt.index === index)
759
+ if (_option && _option.disabled) return
760
+
758
761
  if (this.multiple) {
759
762
  const selected = this.selectedIndexes
760
763
 
@@ -38,7 +38,10 @@
38
38
  :name="_inputKeys.year"
39
39
  :label="$t('AwBirthdayPicker.year')"
40
40
  :clearable="!showYear"
41
+ :option-disabled="isOptionDisabled"
41
42
  class="w-full"
43
+ track-by="year"
44
+ option-label="year"
42
45
  @input="checkMaxDay"
43
46
  @clear="clearYear"
44
47
  />
@@ -128,15 +131,9 @@ export default {
128
131
  },
129
132
 
130
133
  daysList() {
131
- const date = this.dayjs()
132
-
133
- if (this.year) {
134
- date.year(this.year)
135
- }
134
+ const date = this.dayjs().year(this.year || 2000)
136
135
 
137
- const maxDays = this.dayjs()
138
- .month(this.month || 0)
139
- .daysInMonth()
136
+ const maxDays = date.month(this.month || 0).daysInMonth()
140
137
 
141
138
  const arr = [...Array(maxDays + 1).keys()]
142
139
  arr.shift()
@@ -145,7 +142,12 @@ export default {
145
142
 
146
143
  yearsList() {
147
144
  const current = this.dayjs().year()
148
- return [...Array(101).keys()].map((el) => current - el)
145
+ return [...Array(101).keys()].map((el) => ({
146
+ year: current - el,
147
+ isLeapYear: this.dayjs()
148
+ .year(current - el)
149
+ .isLeapYear()
150
+ }))
149
151
  }
150
152
  },
151
153
 
@@ -171,25 +173,10 @@ export default {
171
173
  this.emit()
172
174
  },
173
175
 
174
- // parseString(str) {
175
- // if (!str) return
176
-
177
- // const d = this.toDayjs(str)
178
- // this.day = d.date()
179
- // this.month = d.month()
180
-
181
- // const y = d.year()
182
- // const yString = this.getYearString(str)
183
-
184
- // if (yString.includes(y)) {
185
- // this.year = y
186
- // this.isYearHidden = false
187
- // }
188
- // },
189
-
190
176
  emit() {
191
177
  if (!isNil(this.month) && this.day) {
192
178
  let d = this.dayjs()
179
+ .year(this.year || 2000)
193
180
  .month(this.month)
194
181
  .date(this.day)
195
182
  let formatVal = this.shortParseFormat || 'MM-DD'
@@ -210,6 +197,14 @@ export default {
210
197
  this.isYearHidden = true
211
198
  this.year = null
212
199
  this.emit()
200
+ },
201
+
202
+ isOptionDisabled(option) {
203
+ if (this.month === 1 && this.day === 29) {
204
+ return !option.isLeapYear
205
+ }
206
+
207
+ return false
213
208
  }
214
209
  }
215
210
  }
@@ -5,9 +5,11 @@
5
5
  :value="inputValue"
6
6
  :prefix="prefix"
7
7
  :postfix="postfix"
8
- readonly
8
+ :pattern="_editable ? mask : null"
9
+ :readonly="!_editable"
9
10
  @focus="isOpened = true"
10
11
  @click.stop="isOpened = true"
12
+ @input="onInput"
11
13
  >
12
14
  <template #icon>
13
15
  <AwButton
@@ -107,7 +109,12 @@ export default {
107
109
  /**
108
110
  * Show clear button if value exists
109
111
  */
110
- clearable: Boolean
112
+ clearable: Boolean,
113
+
114
+ /**
115
+ * If false input is readonly
116
+ */
117
+ editable: Boolean
111
118
  },
112
119
 
113
120
  data() {
@@ -118,6 +125,12 @@ export default {
118
125
  },
119
126
 
120
127
  computed: {
128
+ _editable() {
129
+ return (
130
+ this.editable && !this.range && /^[DMY\W]+$/.test(this.format)
131
+ )
132
+ },
133
+
121
134
  inputValue() {
122
135
  const result = []
123
136
 
@@ -170,6 +183,10 @@ export default {
170
183
  }
171
184
 
172
185
  return views
186
+ },
187
+
188
+ mask() {
189
+ return this.format.replace(/[DMY]/g, '#')
173
190
  }
174
191
  },
175
192
 
@@ -224,6 +241,16 @@ export default {
224
241
  'resize',
225
242
  this._checkMaxViewsOnResize
226
243
  )
244
+ },
245
+
246
+ onInput(val) {
247
+ if (val.length === this.format.length) {
248
+ const d = this.$dayjs(val, this.format)
249
+ if (d.isValid()) {
250
+ this.viewDate = d
251
+ this.$emit('input', this._getNonRangeValue(d))
252
+ }
253
+ }
227
254
  }
228
255
  }
229
256
  }
@@ -256,7 +256,7 @@ export default {
256
256
 
257
257
  onFileLoaded($event) {
258
258
  this.openCropModal($event.target.files[0])
259
-
259
+ $event.target.value = '' // reset to allow upload same file
260
260
  this.$refs.dropdown && this.$refs.dropdown.close()
261
261
  },
262
262
 
@@ -27,6 +27,7 @@
27
27
  </template>
28
28
  <template #prefix>
29
29
  <button
30
+ type="button"
30
31
  class="aw-tel__country-toggler focus-outline"
31
32
  @click="_openCountriesDropdown"
32
33
  >
@@ -278,7 +279,8 @@ export default {
278
279
  this.showCountries = false
279
280
  },
280
281
 
281
- _parsePhoneNumber(number, country) {
282
+ _parsePhoneNumber(value, country) {
283
+ const number = typeof value === 'string' ? value : ''
282
284
  const phoneNumber = parsePhoneNumberFromString(number, country)
283
285
 
284
286
  if (phoneNumber) {
@@ -27,23 +27,14 @@
27
27
  </template>
28
28
 
29
29
  <script>
30
+ import { mapGetters } from 'vuex'
30
31
  import { pathOr } from 'rambdax'
31
32
 
32
33
  export default {
33
34
  name: 'AwLayoutCenter',
34
35
 
35
36
  computed: {
36
- isDark() {
37
- return this.$store.getters['awesIo/isDarkTheme']
38
- },
39
-
40
- logo() {
41
- return pathOr(
42
- null,
43
- ['$awes', '_config', this.isDark ? 'dark' : 'default', 'logo'],
44
- this
45
- )
46
- },
37
+ ...mapGetters('awesIo', ['isDarkTheme', 'logo']),
47
38
 
48
39
  background() {
49
40
  const { src, ...background } = pathOr(
@@ -51,7 +42,7 @@ export default {
51
42
  [
52
43
  '$awes',
53
44
  '_config',
54
- this.isDark ? 'dark' : 'default',
45
+ this.isDarkTheme ? 'dark' : 'default',
55
46
  'background'
56
47
  ],
57
48
  this
@@ -0,0 +1,15 @@
1
+ <template functional>
2
+ <NLink
3
+ to="/"
4
+ class="aw-layout-logo"
5
+ :class="[data.class, data.staticClass]"
6
+ >
7
+ <img v-if="props.logo" v-bind="props.logo" />
8
+ </NLink>
9
+ </template>
10
+
11
+ <script>
12
+ export default {
13
+ name: 'AwLayoutLogo'
14
+ }
15
+ </script>
@@ -5,10 +5,12 @@
5
5
  'aw-layout-menu--no-submenu': hideAside || !hasSubmenu
6
6
  }"
7
7
  >
8
- <slot name="logo" v-bind="logo">
9
- <NLink to="/" class="aw-layout-menu__logo">
10
- <img v-if="logo" v-bind="logo" />
11
- </NLink>
8
+ <slot name="logo">
9
+ <Component
10
+ :is="logoComponent.is"
11
+ v-bind="logoComponent.props"
12
+ class="aw-layout-menu__logo"
13
+ />
12
14
  </slot>
13
15
 
14
16
  <div class="aw-layout-menu__menu">
@@ -62,6 +64,7 @@
62
64
  import { mapGetters } from 'vuex'
63
65
  import { pathOr, viewOr, lensProp, omit } from 'rambdax'
64
66
  import AwMenuItemIcon from '@AwLayouts/_AwMenuItemIcon.vue'
67
+ import AwLayoutLogo from '@AwLayouts/_AwLayoutLogo.vue'
65
68
  import AwUserMenu from '@AwLayouts/_AwUserMenu.vue'
66
69
  import AwNav from '@AwLayouts/_AwNav.vue'
67
70
 
@@ -70,6 +73,7 @@ export default {
70
73
 
71
74
  components: {
72
75
  AwMenuItemIcon,
76
+ AwLayoutLogo,
73
77
  AwUserMenu,
74
78
  AwNav
75
79
  },
@@ -85,7 +89,7 @@ export default {
85
89
  },
86
90
 
87
91
  computed: {
88
- ...mapGetters('awesIo', ['user', 'isDarkTheme']),
92
+ ...mapGetters('awesIo', ['user', 'logoComponent']),
89
93
 
90
94
  mainMenu() {
91
95
  return viewOr([], lensProp('mainMenu'), this.layoutProvider)
@@ -115,14 +119,6 @@ export default {
115
119
  this.activeMenu
116
120
  )
117
121
  : ''
118
- },
119
-
120
- logo() {
121
- return pathOr(
122
- null,
123
- ['_config', this.isDarkTheme ? 'dark' : 'default', 'logo'],
124
- this.$awes
125
- )
126
122
  }
127
123
  },
128
124
 
@@ -46,7 +46,9 @@ export default {
46
46
  }
47
47
 
48
48
  if (this.shortParseFormat) {
49
- const dShort = this.dayjs(input, this.shortParseFormat)
49
+ const _formatWithYear = `${this.shortParseFormat}.YYYY`
50
+ const _inputWithYear = `${input}.2000` // 2000 is leap year
51
+ const dShort = this.dayjs(_inputWithYear, _formatWithYear)
50
52
  if (dShort.isValid()) {
51
53
  return dShort
52
54
  }
@@ -44,7 +44,7 @@ export const dayjs = {
44
44
  pattern: null,
45
45
  format: true
46
46
  },
47
- plugins: ['dayjs/plugin/relativeTime']
47
+ plugins: ['dayjs/plugin/relativeTime', 'dayjs/plugin/isLeapYear']
48
48
  }
49
49
 
50
50
  export const axios = {
@@ -6,6 +6,12 @@ export default ({ store, app }) => {
6
6
  */
7
7
  if (!store.hasModule('awesIo')) {
8
8
  store.registerModule('awesIo', storeModule)
9
+
10
+ // Set default logo
11
+ store.commit('awesIo/SET_LOGO', {
12
+ default: JSON.parse('<%= JSON.stringify(options.default.logo) %>'),
13
+ dark: JSON.parse('<%= JSON.stringify(options.dark.logo) %>')
14
+ })
9
15
  }
10
16
 
11
17
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awes-io/ui",
3
- "version": "2.34.0",
3
+ "version": "2.36.0",
4
4
  "description": "User Interface (UI) components",
5
5
  "keywords": [
6
6
  "ui",
@@ -124,5 +124,5 @@
124
124
  "vue-template-compiler": "^2.6.10",
125
125
  "webfonts-generator": "^0.4.0"
126
126
  },
127
- "gitHead": "7cf70f84e64609355c655b32e92cbee0452c4765"
127
+ "gitHead": "3ac5dc679b50b56efa3b57c967cd37b2c2eba154"
128
128
  }
package/store/awesIo.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import Vue from 'vue'
2
- import { pathOr, pick, isType } from 'rambdax'
2
+ import { pathOr, pick, isType, mergeDeepRight } from 'rambdax'
3
3
 
4
4
  const castArray = (val) => (Array.isArray(val) ? val : [])
5
5
 
@@ -20,6 +20,11 @@ export const state = () => ({
20
20
 
21
21
  profileUrl: null,
22
22
 
23
+ logo: {
24
+ default: { src: '' },
25
+ dark: { src: '' }
26
+ },
27
+
23
28
  menus: {
24
29
  main: [],
25
30
  secondary: [],
@@ -83,7 +88,22 @@ export const getters = {
83
88
  }
84
89
  },
85
90
 
86
- isDarkTheme: pathOr(false, 'isDarkTheme')
91
+ isDarkTheme: pathOr(false, 'isDarkTheme'),
92
+
93
+ logo(state, getters) {
94
+ return getters.isDarkTheme ? state.logo.dark : state.logo.default
95
+ },
96
+
97
+ logoComponent(state, getters) {
98
+ const logoComponent = pathOr(null, 'logo.component', state)
99
+
100
+ return logoComponent && logoComponent.is
101
+ ? logoComponent
102
+ : {
103
+ is: 'AwLayoutLogo',
104
+ props: { logo: getters.logo }
105
+ }
106
+ }
87
107
  }
88
108
 
89
109
  export const mutations = {
@@ -127,6 +147,26 @@ export const mutations = {
127
147
 
128
148
  TOGGLE_MOBILE_MENU(state, status = !state.mobileMenuOpened) {
129
149
  state.mobileMenuOpened = Boolean(status)
150
+ },
151
+
152
+ SET_LOGO(state, logo) {
153
+ if (typeof logo === 'string') {
154
+ state.logo = mergeDeepRight(state.logo, {
155
+ default: { src: logo },
156
+ dark: { src: logo }
157
+ })
158
+ } else if (typeof logo === 'object' && logo !== null) {
159
+ const _logo = {}
160
+ _logo.default = pathOr(state.logo.default, 'default', logo)
161
+ _logo.dark = pathOr(
162
+ pathOr(state.logo.dark, 'default', logo),
163
+ 'dark',
164
+ logo
165
+ )
166
+ _logo.component = pathOr(state.logo.component, 'component', logo)
167
+
168
+ state.logo = _logo
169
+ }
130
170
  }
131
171
  }
132
172