Skip to content

Commit fef3099

Browse files
committed
npm pu
1 parent be86710 commit fef3099

31 files changed

+2084
-1899
lines changed

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,49 @@ We need help translating the language files. Below are listed the available ones
161161
162162
---
163163
164+
# change default icons at Runtime
165+
default icons are reactive, so all components will update properly if you change the $qdtp.icons object.
166+
167+
example 01: in a boot
168+
```js
169+
import { boot } from 'quasar/wrappers'
170+
171+
export default boot(function ({ app }) {
172+
app.qdtp.icons.date = 'mdi-calendar'
173+
app.qdtp.icons.time = 'mdi-clock-outline'
174+
})
175+
```
176+
177+
example 02: in a component
178+
```js
179+
export default {
180+
mounted () {
181+
this.$qdtp.icons.date = 'mdi-calendar'
182+
this.$qdtp.icons.time = 'mdi-clock-outline'
183+
}
184+
}
185+
```
186+
187+
example 03: in a vuex module
188+
```js
189+
export default {
190+
actions: {
191+
updateIcons () {
192+
this.$qdtp.icons.date = 'mdi-calendar'
193+
this.$qdtp.icons.time = 'mdi-clock-outline'
194+
}
195+
}
196+
}
197+
```
198+
199+
example 04: everywhere else
200+
```js
201+
import { icons } from 'quasar-app-extension-qdatetimepicker/src/component'
202+
203+
icons.date = 'mdi-calendar'
204+
icons.time = 'mdi-clock-outline'
205+
```
206+
164207
# QDatetimePicker Vue Properties
165208
| Vue Property | Type | Description |
166209
|---|---|---|
@@ -192,7 +235,9 @@ We need help translating the language files. Below are listed the available ones
192235
| mode | String | Display Mode (`date`, `time`, `datetime`) (default: `date`) |
193236
| format24h | Boolean | Show the timepicker in 24 hour format. The masked value will not be affected. |
194237
| display-value | Boolean or String | If the value is `true` or a `string`, the internal QInput will be readonly. If the value is `true` the calendar and numeric system used to format the date will not be forced to be the gregorian calendar and latin numbers. If value is a `string`, the format function will be ignored and the `display-value` will be used directly in the `input` (default: `false`) |
195-
| icon | String | The icon of the picker (default: `access_time` when the mode is `time`, otherwise `event`) |
238+
| icon | String | The icon of the picker (default: `access_time` when the mode is `time`, otherwise `event`) (obs: `date-icon` and/or `time-icon` props has a high priority) |
239+
| date-icon | String | The icon of the picker when the mode is equals to `date` or `datetime` (default: `event`) |
240+
| time-icon | String | The icon of the picker when the mode is equals to `time` (default: `access_time`) |
196241
| landscape | Boolean | Show the picker in landscape mode (default: false) |
197242
| today-btn | Boolean | Display a button that selects the current day (`date` and `datetime` modes only) (default: false) |
198243
| now-btn | Boolean | Display a button that selects the current time (`time` and `datetime` modes only) (default: false) |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "quasar-app-extension-qdatetimepicker",
3-
"version": "1.0.0-rc.15",
3+
"version": "1.0.0-rc.16",
44
"description": "QDatetimePicker for Quasar",
55
"author": "Tobias Mesquita <[email protected]>",
66
"main": "src/index.js",

src/boot/qdatetimepicker.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
// import 'q-datetimepicker-styl'
2-
import QDatetimePicker from 'quasar-app-extension-qdatetimepicker/src/component/QDatetimePicker.js'
2+
import { QDatetimePicker, icons } from 'quasar-app-extension-qdatetimepicker/src/component'
33

4-
export default ({ Vue, ssrContext }) => {
4+
export default ({ Vue, app, store, ssrContext }) => {
5+
const options = { icons }
6+
app.qdtp = options
7+
if (store) {
8+
store.$qdtp = options
9+
}
510
Vue.component('q-datetime-picker', QDatetimePicker({ ssrContext }))
11+
Vue.mixin({
12+
beforeCreate () {
13+
const options = this.$options
14+
if (options.qdtp) {
15+
this.$qdtp = options.qdtp
16+
} else if (options.parent) {
17+
this.$qdtp = options.parent.$qdtp
18+
}
19+
}
20+
})
621
}

src/component/QDatetimePicker.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from 'vue'
22
import * as meta from 'quasar-app-extension-qdatetimepicker/src/services/meta.js'
33
import * as date from 'quasar-app-extension-qdatetimepicker/src/services/date.js'
4-
import Render from 'quasar-app-extension-qdatetimepicker/src/services/render.js'
4+
import Render, { icons } from 'quasar-app-extension-qdatetimepicker/src/services/render.js'
55

66
import {
77
dom,
@@ -53,6 +53,14 @@ const { value, clearable, ...props } = {
5353
type: String,
5454
default: undefined
5555
},
56+
dateIcon: {
57+
type: String,
58+
default: undefined
59+
},
60+
timeIcon: {
61+
type: String,
62+
default: undefined
63+
},
5664
defaultStandard: {
5765
type: String,
5866
default: 'iso',
@@ -370,3 +378,5 @@ export default function ({ ssrContext }) {
370378
}
371379
})
372380
}
381+
382+
export { icons }

src/component/QDatetimePicker.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@
118118
"type": [ "String" ],
119119
"desc": "The icon of the picker (default: 'access_time' when the mode is 'time', otherwise 'event')"
120120
},
121+
"date-icon": {
122+
"type": [ "String" ],
123+
"desc": "The icon of the picker when the mode is equals to date (default: 'event')"
124+
},
125+
"time-icon": {
126+
"type": [ "String" ],
127+
"desc": "The icon of the picker when the mode is equals to time (default: 'access_time')"
128+
},
121129
"landscape": {
122130
"type": [ "Boolean" ],
123131
"desc": "Show the picker in landscape mode (default: 'false')"

src/component/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import QDatetimePicker from './QDatetimePicker.js'
1+
import QDatetimePicker, { icons } from './QDatetimePicker.js'
22

33
export {
4-
QDatetimePicker
4+
QDatetimePicker,
5+
icons
56
}

src/services/render.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import {
1414
QTabPanel
1515
} from 'quasar'
1616

17+
import Vue from 'vue'
18+
const icons = new Vue.observable({
19+
date: 'event',
20+
time: 'access_time'
21+
})
22+
1723
const Render = function (self, h) {
1824
this.h = h
1925
this.self = self
@@ -146,10 +152,12 @@ Render.prototype.suffix = function () {
146152

147153
Render.prototype.trigger = function () {
148154
let { h, self } = this
155+
let icon = self.mode === 'time' ? self.timeIcon : self.dateIcon;
156+
let _default = self.mode === 'time' ? icons.time : icons.date
149157
let trigger = h(QIcon, {
150158
staticClass: 'cursor-pointer',
151159
props: {
152-
name: self.icon || (self.mode === 'time' ? 'access_time' : 'event')
160+
name: icon || self.icon || _default
153161
}
154162
}, [this.popup()])
155163
return trigger
@@ -295,14 +303,14 @@ Render.prototype.tabsTitle = function () {
295303
h(QTab, {
296304
props: {
297305
name: 'date',
298-
icon: 'event',
306+
icon: self.dateIcon || icons.date,
299307
label: self.isoLang.dateTimePicker.date
300308
}
301309
}, []),
302310
h(QTab, {
303311
props: {
304312
name: 'time',
305-
icon: 'access_time',
313+
icon: self.timeIcon || icons.time,
306314
label: self.isoLang.dateTimePicker.time
307315
}
308316
}, [])
@@ -377,3 +385,4 @@ Render.prototype.time = function () {
377385
}
378386

379387
export default Render
388+
export { icons }

test/app/package.json

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
"test:unit:ui": "majestic"
1919
},
2020
"dependencies": {
21-
"@quasar/extras": "^1.8.1",
21+
"@quasar/extras": "^1.9.13",
2222
"axios": "^0.18.0",
23-
"quasar": "^1.12.2",
23+
"core-js": "^3.0.0",
24+
"quasar": "^1.15.0",
2425
"vue-i18n": "^7.3.3"
2526
},
2627
"devDependencies": {
27-
"@quasar/app": "^1.9.3",
28-
"@quasar/quasar-app-extension-testing": "^1.0.0",
28+
"@quasar/app": "^2.1.14",
29+
"@quasar/quasar-app-extension-testing": "^1.0.3",
2930
"@vue/eslint-config-standard": "^4.0.0",
3031
"babel-eslint": "^10.0.1",
3132
"eslint": "^5.10.0",
@@ -34,17 +35,23 @@
3435
"majestic": "^1.2.24",
3536
"quasar-app-extension-qdatetimepicker": "link:../../",
3637
"strip-ansi": "=3.0.1",
37-
"wallaby-vue-compiler": "^1.0.3"
38+
"wallaby-vue-compiler": "^1.0.3",
39+
"workbox-webpack-plugin": "^5.0.0"
3840
},
3941
"engines": {
4042
"node": ">= 8.9.0",
4143
"npm": ">= 5.6.0",
4244
"yarn": ">= 1.6.0"
4345
},
4446
"browserslist": [
45-
"last 1 version, not dead, ie >= 11"
46-
],
47-
"resolutions": {
48-
"ajv": "6.8.1"
49-
}
47+
"last 10 Chrome versions",
48+
"last 10 Firefox versions",
49+
"last 4 Edge versions",
50+
"last 7 Safari versions",
51+
"last 8 Android versions",
52+
"last 8 ChromeAndroid versions",
53+
"last 8 FirefoxAndroid versions",
54+
"last 10 iOS versions",
55+
"last 5 Opera versions"
56+
]
5057
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)