From 425c5dfc16a9a34c0fdfef0179bfd1c0c14beeab Mon Sep 17 00:00:00 2001 From: Phoenix Wong Date: Tue, 27 Aug 2019 00:11:10 +0800 Subject: [PATCH] New `minute-range` and `second-range` support. Companioned with `hide-disabled-minutes`, `hide-disabled-seconds`, and an overall `hide-disabled-items` helper. --- README.md | 73 ++++++-- demo/src/components/SampleBlock.vue | 24 ++- demo/src/components/Samples.vue | 110 ++++++++--- src/vue-timepicker.vue | 271 ++++++++++++++++++++-------- 4 files changed, 359 insertions(+), 119 deletions(-) diff --git a/README.md b/README.md index 1c13833..4662141 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ Section | Token | Output > If not set, the `format` string is default to "HH:mm" -### Customized Picker interval +### Customized Picker Interval ```html @@ -393,13 +393,47 @@ Sometimes you may want to limit hours picker to a specific range. The `hour-rang ``` -### Hide Disabled Hour Ranges +### Set Minute and Second Range + +Similar to `hour-range`, you can determine values in the minutes and seconds dropdown by using `minute-range` and `second-range`. + +```html + + + + + + + +``` + +When implemented together with `minute-interval` and `second-interval`, the customized intervals take the priority. + +```html + + + + + + + +``` + +### Hide Disabled Items + +There're four kinds of helper properties to let you hide the values excluded by `hour-range`, `minute-range`, and `second-range`. + +- **hide-disabled-items**: Hide **all** disabled items - hour, minute, and seconds. +- **hide-disabled-hours**: Hide disabled **hour** values only. +- **hide-disabled-minutes**: Hide disabled **minute** values only. +- **hide-disabled-seconds**: Hide disabled **second** values only. ```html + ``` -It's a pair with the above `hour-range` parameter. In this sample, the hour picker hides the invalid hours (_0, 1, 2, 3, 4, 6, 7, 13, 18, 20, 21, 22, 23_) and display the valid hours (_5, 8, 9, ..._) only. +Here we take the `hide-disabled-hours` as an example. It's a pair with the `hour-range` parameter. In this case, the hour picker hides the invalid hours (_0, 1, 2, 3, 4, 6, 7, 13, 18, 20, 21, 22, 23_) and display the valid hours (_5, 8, 9, ..._) only. ### Enable Debug Mode @@ -431,24 +465,29 @@ Let's create a "bug" as an example -- Then, in the console window, you should see a debug log saying: ```console -DEBUG: The input string in 'v-model' does NOT match the 'format' pattern +DEBUG: The input string in "v-model" does NOT match the "format" pattern format: h:mm:ss A v-model: e:mm:05 A ``` -## Main Props API - -Prop | Type | Required | Default Value ------------------------ | ------------------ | -------- | ------------- -**v-model** | _Object_, _String_ | no | _undefined_ -**format** | _String_ | no | "HH:mm" -**minute-interval** | _Number_ | no | _undefined_ -**second-interval** | _Number_ | no | _undefined_ -**hide-clear-button** | _Boolean_ | no | false -**disabled** | _Boolean_ | no | false -**hour-range** | _Array_ | no | _undefined_ -**hide-disabled-hours** | _Boolean_ | no | false -**debug-mode** | _Boolean_ | no | false +## Main Props API Overview + +Prop | Type | Required | Default Value +------------------------- | ------------------ | -------- | ------------- +**v-model** | _Object_, _String_ | no | _undefined_ +**format** | _String_ | no | "HH:mm" +**minute-interval** | _Number_ | no | _undefined_ +**second-interval** | _Number_ | no | _undefined_ +**hide-clear-button** | _Boolean_ | no | false +**disabled** | _Boolean_ | no | false +**hour-range** | _Array_ | no | _undefined_ +**minute-range** | _Array_ | no | _undefined_ +**second-range** | _Array_ | no | _undefined_ +**hide-disabled-hours** | _Boolean_ | no | false +**hide-disabled-minutes** | _Boolean_ | no | false +**hide-disabled-seconds** | _Boolean_ | no | false +**hide-disabled-items** | _Boolean_ | no | false +**debug-mode** | _Boolean_ | no | false ## Input Props API diff --git a/demo/src/components/SampleBlock.vue b/demo/src/components/SampleBlock.vue index 9e6b95e..4b0d57c 100644 --- a/demo/src/components/SampleBlock.vue +++ b/demo/src/components/SampleBlock.vue @@ -1,13 +1,24 @@