goodteditor-ui 1.0.21 → 1.0.23

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 (114) hide show
  1. package/.eslintrc.js +7 -7
  2. package/.prettierrc +14 -14
  3. package/README.md +35 -35
  4. package/babel.config.js +5 -5
  5. package/index.js +53 -53
  6. package/jsconfig.json +13 -13
  7. package/package.json +66 -70
  8. package/src/App.vue +36 -36
  9. package/src/components/ui/Avatar.md +68 -68
  10. package/src/components/ui/Avatar.vue +180 -177
  11. package/src/components/ui/Badge.md +20 -20
  12. package/src/components/ui/Badge.vue +75 -75
  13. package/src/components/ui/Collapse.md +90 -90
  14. package/src/components/ui/Collapse.vue +86 -86
  15. package/src/components/ui/ColorPicker/Alpha.vue +114 -114
  16. package/src/components/ui/ColorPicker/Colors.vue +117 -117
  17. package/src/components/ui/ColorPicker/Hue.vue +113 -113
  18. package/src/components/ui/ColorPicker/Preview.vue +55 -55
  19. package/src/components/ui/ColorPicker/Saturation.vue +123 -123
  20. package/src/components/ui/ColorPicker/mixin.js +105 -105
  21. package/src/components/ui/ColorPicker.md +17 -17
  22. package/src/components/ui/ColorPicker.vue +314 -314
  23. package/src/components/ui/Datalist.md +41 -41
  24. package/src/components/ui/Datalist.vue +157 -157
  25. package/src/components/ui/DatePicker.md +168 -168
  26. package/src/components/ui/DatePicker.vue +527 -527
  27. package/src/components/ui/FileSelector.md +105 -105
  28. package/src/components/ui/FileSelector.vue +82 -82
  29. package/src/components/ui/Grid.md +130 -130
  30. package/src/components/ui/Grid.vue +92 -92
  31. package/src/components/ui/Image.md +59 -59
  32. package/src/components/ui/Image.vue +57 -57
  33. package/src/components/ui/InputAutocomplete.md +115 -115
  34. package/src/components/ui/InputAutocomplete.vue +341 -341
  35. package/src/components/ui/InputColorPicker.md +51 -51
  36. package/src/components/ui/InputColorPicker.vue +151 -151
  37. package/src/components/ui/InputDatePicker.md +121 -121
  38. package/src/components/ui/InputDatePicker.vue +326 -326
  39. package/src/components/ui/InputTags.md +51 -51
  40. package/src/components/ui/InputTags.vue +184 -184
  41. package/src/components/ui/InputTimePicker.md +25 -25
  42. package/src/components/ui/InputTimePicker.vue +253 -253
  43. package/src/components/ui/InputUnits.md +20 -20
  44. package/src/components/ui/InputUnits.vue +257 -257
  45. package/src/components/ui/Lazy.md +37 -37
  46. package/src/components/ui/Lazy.vue +92 -92
  47. package/src/components/ui/Pagination.md +74 -74
  48. package/src/components/ui/Pagination.vue +138 -138
  49. package/src/components/ui/Paginator.md +34 -34
  50. package/src/components/ui/Paginator.vue +83 -83
  51. package/src/components/ui/Popover.md +34 -34
  52. package/src/components/ui/Popover.vue +274 -274
  53. package/src/components/ui/Popup.md +59 -59
  54. package/src/components/ui/Popup.vue +150 -150
  55. package/src/components/ui/ResponsiveContainer.md +58 -58
  56. package/src/components/ui/ResponsiveContainer.vue +99 -99
  57. package/src/components/ui/Select.md +187 -187
  58. package/src/components/ui/Select.vue +421 -421
  59. package/src/components/ui/TimePicker.md +50 -50
  60. package/src/components/ui/TimePicker.vue +252 -252
  61. package/src/components/ui/Tooltip.md +54 -114
  62. package/src/components/ui/Tooltip.vue +113 -113
  63. package/src/components/ui/WysiwygEditor/WysiwygEditor.d.ts +119 -119
  64. package/src/components/ui/WysiwygEditor/constants.js +264 -264
  65. package/src/components/ui/WysiwygEditor/extensions/blockquote.js +15 -15
  66. package/src/components/ui/WysiwygEditor/extensions/bold.js +15 -15
  67. package/src/components/ui/WysiwygEditor/extensions/bullet-list.js +15 -15
  68. package/src/components/ui/WysiwygEditor/extensions/code-block.js +13 -13
  69. package/src/components/ui/WysiwygEditor/extensions/code.js +13 -13
  70. package/src/components/ui/WysiwygEditor/extensions/font-size.js +34 -34
  71. package/src/components/ui/WysiwygEditor/extensions/formatting.js +14 -14
  72. package/src/components/ui/WysiwygEditor/extensions/heading.js +13 -13
  73. package/src/components/ui/WysiwygEditor/extensions/horizontal-rule.js +15 -15
  74. package/src/components/ui/WysiwygEditor/extensions/image.js +19 -19
  75. package/src/components/ui/WysiwygEditor/extensions/index.d.ts +32 -32
  76. package/src/components/ui/WysiwygEditor/extensions/index.js +32 -32
  77. package/src/components/ui/WysiwygEditor/extensions/italic.js +15 -15
  78. package/src/components/ui/WysiwygEditor/extensions/link.js +16 -16
  79. package/src/components/ui/WysiwygEditor/extensions/list-item.js +15 -15
  80. package/src/components/ui/WysiwygEditor/extensions/ordered-list.js +15 -15
  81. package/src/components/ui/WysiwygEditor/extensions/paragraph.js +23 -23
  82. package/src/components/ui/WysiwygEditor/extensions/strike.js +15 -15
  83. package/src/components/ui/WysiwygEditor/extensions/table-cell.js +13 -13
  84. package/src/components/ui/WysiwygEditor/extensions/table-header.js +15 -15
  85. package/src/components/ui/WysiwygEditor/extensions/table-row.js +15 -15
  86. package/src/components/ui/WysiwygEditor/extensions/table.js +29 -29
  87. package/src/components/ui/WysiwygEditor/extensions/text-align.js +6 -6
  88. package/src/components/ui/WysiwygEditor/extensions/text-style.js +15 -15
  89. package/src/components/ui/WysiwygEditor/extensions/underline.js +15 -15
  90. package/src/components/ui/WysiwygEditor/index.d.ts +4 -4
  91. package/src/components/ui/WysiwygEditor/index.js +4 -4
  92. package/src/components/ui/WysiwygEditor/renders/Button.vue +28 -28
  93. package/src/components/ui/WysiwygEditor/renders/ColorPicker.vue +41 -41
  94. package/src/components/ui/WysiwygEditor/renders/InputAuto.vue +34 -34
  95. package/src/components/ui/WysiwygEditor/renders/InputBrowse.vue +35 -35
  96. package/src/components/ui/WysiwygEditor/renders/InputUnits.vue +38 -38
  97. package/src/components/ui/WysiwygEditor/renders/Link.vue +87 -87
  98. package/src/components/ui/WysiwygEditor/renders/Select.vue +47 -47
  99. package/src/components/ui/WysiwygEditor/renders/ToolbarPopover.vue +49 -49
  100. package/src/components/ui/WysiwygEditor/renders/index.d.ts +8 -8
  101. package/src/components/ui/WysiwygEditor/renders/index.js +8 -8
  102. package/src/components/ui/WysiwygEditor/renders/mixins/RenderMixin.js +39 -39
  103. package/src/components/ui/WysiwygEditor/renders/mixins/index.js +1 -1
  104. package/src/components/ui/WysiwygEditor/tools-and-commands.js +704 -704
  105. package/src/components/ui/WysiwygEditor/utils.js +72 -72
  106. package/src/components/ui/WysiwygEditor.md +18 -18
  107. package/src/components/ui/WysiwygEditor.vue +271 -271
  108. package/src/components/ui/utils/FormComponent.js +107 -107
  109. package/src/components/ui/utils/Helpers.js +84 -84
  110. package/src/components/ui/utils/WithPopover.js +81 -99
  111. package/src/main.js +8 -8
  112. package/styleguide.config.js +37 -37
  113. package/vue.config.js +8 -8
  114. package/dist/js.png +0 -0
@@ -1,51 +1,51 @@
1
- Simple example
2
-
3
- ```vue
4
- <template>
5
- <div class="pad-l5">
6
- <p>value: {{ model }}</p>
7
- <input-color-picker class="w-6-12" v-model="model" v-bind="props"></input-color-picker>
8
- </div>
9
- </template>
10
- <script>
11
- export default {
12
- data() {
13
- return {
14
- model: '#f00',
15
- props: {
16
- placeholder: 'Pick a color',
17
- },
18
- };
19
- },
20
- };
21
- </script>
22
- ```
23
-
24
- Advanced example. Slots
25
-
26
- ```vue
27
- <template>
28
- <div class="pad-l5">
29
- <p>value: {{ model }}</p>
30
- <input-color-picker class="w-6-12" v-model="model" v-bind="props">
31
- <template #icon="{ toggle, value }">
32
- <div class="icon cursor-pointer" @click="toggle">
33
- <i class="mdi mdi-palette mdi-18px"></i>
34
- </div>
35
- </template>
36
- </input-color-picker>
37
- </div>
38
- </template>
39
- <script>
40
- export default {
41
- data() {
42
- return {
43
- model: '#f00',
44
- props: {
45
- placeholder: 'Pick a color',
46
- },
47
- };
48
- },
49
- };
50
- </script>
51
- ```
1
+ Simple example
2
+
3
+ ```vue
4
+ <template>
5
+ <div class="pad-l5">
6
+ <p>value: {{ model }}</p>
7
+ <input-color-picker class="w-6-12" v-model="model" v-bind="props"></input-color-picker>
8
+ </div>
9
+ </template>
10
+ <script>
11
+ export default {
12
+ data() {
13
+ return {
14
+ model: '#f00',
15
+ props: {
16
+ placeholder: 'Pick a color',
17
+ },
18
+ };
19
+ },
20
+ };
21
+ </script>
22
+ ```
23
+
24
+ Advanced example. Slots
25
+
26
+ ```vue
27
+ <template>
28
+ <div class="pad-l5">
29
+ <p>value: {{ model }}</p>
30
+ <input-color-picker class="w-6-12" v-model="model" v-bind="props">
31
+ <template #icon="{ toggle, value }">
32
+ <div class="icon cursor-pointer" @click="toggle">
33
+ <i class="mdi mdi-palette mdi-18px"></i>
34
+ </div>
35
+ </template>
36
+ </input-color-picker>
37
+ </div>
38
+ </template>
39
+ <script>
40
+ export default {
41
+ data() {
42
+ return {
43
+ model: '#f00',
44
+ props: {
45
+ placeholder: 'Pick a color',
46
+ },
47
+ };
48
+ },
49
+ };
50
+ </script>
51
+ ```
@@ -1,151 +1,151 @@
1
- <template>
2
- <div
3
- class="ui-input-color-picker form-elem"
4
- :class="cssClass"
5
- @focus="onRootFocus"
6
- tabindex="0"
7
- :data-popover="popoverTargetId"
8
- >
9
- <div class="ui-input-color-picker-wrapper d-flex flex-v-center w-100">
10
- <div style="flex: 1 0 0">
11
- <!--
12
- @slot Custom input slot
13
- @binding {String} id input id attribute value
14
- @binding {String} value input value
15
- @binding {Object} inputBinds input props (use v-bind)
16
- @binding {Object} inputEvents input events (use v-on)
17
- -->
18
- <slot name="input" v-bind="{ id: inputId, value, inputBinds, inputEvents }">
19
- <input
20
- :id="inputId"
21
- class="ui-input-color-picker-input w-100"
22
- type="text"
23
- :value="value"
24
- v-bind="inputBinds"
25
- v-on="inputEvents"
26
- />
27
- </slot>
28
- </div>
29
- <!--
30
- @slot Icon slot
31
- @binding {String} value current value
32
- @binding {Function} toggle function that toggles the color picker
33
- -->
34
- <slot name="icon" v-bind="{ value, toggle: togglePopover }">
35
- <div
36
- class="ui-input-color-picker-icon-preview mar-left-2 cursor-pointer"
37
- :style="{ background: value }"
38
- @click="togglePopover"
39
- ></div>
40
- </slot>
41
- </div>
42
- <ui-popover :show.sync="popoverShow" v-bind="popoverOptions">
43
- <color-picker
44
- class="ui-input-color-picker-cp pull-left"
45
- v-bind="{
46
- value,
47
- colorsDefault,
48
- showSubmit: true,
49
- }"
50
- @submit="onSubmit"
51
- ></color-picker>
52
- </ui-popover>
53
- </div>
54
- </template>
55
- <style lang="less" scoped>
56
- .ui-input-color-picker {
57
- display: inline-flex;
58
- &-wrapper {
59
- display: flex;
60
- }
61
- &-icon-preview {
62
- width: 1em;
63
- height: 1em;
64
- border: 1px solid var(--color-border);
65
- background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKAQMAAAC3/F3+AAAAA3NCSVQICAjb4U/gAAAABlBMVEXM1dv///9zs4+jAAAACXBIWXMAAAsSAAALEgHS3X78AAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJljYD/AgIx+MCAjAHyDCLzvUxo8AAAAAElFTkSuQmCC');
66
- }
67
- &-input {
68
- border: none;
69
- margin: 0;
70
- padding: 0;
71
- line-height: 1.5;
72
- color: inherit;
73
- background: transparent;
74
- outline: none;
75
- }
76
- }
77
- </style>
78
- <script>
79
- import ColorPicker from './ColorPicker.vue';
80
- import UiPopover from './Popover.vue';
81
- import FormComponent from './utils/FormComponent';
82
- import WithPopover from './utils/WithPopover';
83
-
84
- export default {
85
- mixins: [FormComponent, WithPopover],
86
- components: { ColorPicker, UiPopover },
87
- props: {
88
- /**
89
- * Whether the input is editable
90
- */
91
- editable: {
92
- type: Boolean,
93
- default: true,
94
- },
95
- /**
96
- * Default colors palette
97
- */
98
- colorsDefault: {
99
- type: Array,
100
- default() {
101
- return [];
102
- },
103
- },
104
- },
105
- data() {
106
- return {
107
- inputBinds: {
108
- placeholder: this.placeholder,
109
- readonly: this.readonly || !this.editable,
110
- },
111
- inputEvents: {
112
- change: this.onInputChange,
113
- focus: this.onInputFocus,
114
- blur: this.onInputBlur,
115
- },
116
- };
117
- },
118
- methods: {
119
- changeColor(val) {
120
- /**
121
- * Input event
122
- * @property {String} color
123
- */
124
- this.$emit('input', val);
125
- /**
126
- * Change event
127
- * @property {String} color
128
- */
129
- this.$emit('change', val);
130
- },
131
- onRootFocus(e) {
132
- let input = this.getInputRef();
133
- input && input.focus();
134
- },
135
- onInputChange(e) {
136
- this.changeColor(e.target.value);
137
- },
138
- onInputFocus(e) {
139
- this.rootHasFocus = true;
140
- },
141
- onInputBlur(e) {
142
- this.rootHasFocus = false;
143
- },
144
- onSubmit({ rgba }) {
145
- let { r, g, b, a } = rgba;
146
- this.changeColor(`rgba(${r}, ${g}, ${b}, ${a})`);
147
- this.popoverShow = false;
148
- },
149
- },
150
- };
151
- </script>
1
+ <template>
2
+ <div
3
+ class="ui-input-color-picker form-elem"
4
+ :class="cssClass"
5
+ @focus="onRootFocus"
6
+ tabindex="0"
7
+ :data-popover="popoverTargetId"
8
+ >
9
+ <div class="ui-input-color-picker-wrapper d-flex flex-v-center w-100">
10
+ <div style="flex: 1 0 0">
11
+ <!--
12
+ @slot Custom input slot
13
+ @binding {String} id input id attribute value
14
+ @binding {String} value input value
15
+ @binding {Object} inputBinds input props (use v-bind)
16
+ @binding {Object} inputEvents input events (use v-on)
17
+ -->
18
+ <slot name="input" v-bind="{ id: inputId, value, inputBinds, inputEvents }">
19
+ <input
20
+ :id="inputId"
21
+ class="ui-input-color-picker-input w-100"
22
+ type="text"
23
+ :value="value"
24
+ v-bind="inputBinds"
25
+ v-on="inputEvents"
26
+ />
27
+ </slot>
28
+ </div>
29
+ <!--
30
+ @slot Icon slot
31
+ @binding {String} value current value
32
+ @binding {Function} toggle function that toggles the color picker
33
+ -->
34
+ <slot name="icon" v-bind="{ value, toggle: togglePopover }">
35
+ <div
36
+ class="ui-input-color-picker-icon-preview mar-left-2 cursor-pointer"
37
+ :style="{ background: value }"
38
+ @click="togglePopover"
39
+ ></div>
40
+ </slot>
41
+ </div>
42
+ <ui-popover :show.sync="popoverShow" v-bind="popoverOptions">
43
+ <color-picker
44
+ class="ui-input-color-picker-cp pull-left"
45
+ v-bind="{
46
+ value,
47
+ colorsDefault,
48
+ showSubmit: true,
49
+ }"
50
+ @submit="onSubmit"
51
+ ></color-picker>
52
+ </ui-popover>
53
+ </div>
54
+ </template>
55
+ <style lang="less" scoped>
56
+ .ui-input-color-picker {
57
+ display: inline-flex;
58
+ &-wrapper {
59
+ display: flex;
60
+ }
61
+ &-icon-preview {
62
+ width: 1em;
63
+ height: 1em;
64
+ border: 1px solid var(--color-border);
65
+ background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKAQMAAAC3/F3+AAAAA3NCSVQICAjb4U/gAAAABlBMVEXM1dv///9zs4+jAAAACXBIWXMAAAsSAAALEgHS3X78AAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJljYD/AgIx+MCAjAHyDCLzvUxo8AAAAAElFTkSuQmCC');
66
+ }
67
+ &-input {
68
+ border: none;
69
+ margin: 0;
70
+ padding: 0;
71
+ line-height: 1.5;
72
+ color: inherit;
73
+ background: transparent;
74
+ outline: none;
75
+ }
76
+ }
77
+ </style>
78
+ <script>
79
+ import ColorPicker from './ColorPicker.vue';
80
+ import UiPopover from './Popover.vue';
81
+ import FormComponent from './utils/FormComponent';
82
+ import WithPopover from './utils/WithPopover';
83
+
84
+ export default {
85
+ mixins: [FormComponent, WithPopover],
86
+ components: { ColorPicker, UiPopover },
87
+ props: {
88
+ /**
89
+ * Whether the input is editable
90
+ */
91
+ editable: {
92
+ type: Boolean,
93
+ default: true,
94
+ },
95
+ /**
96
+ * Default colors palette
97
+ */
98
+ colorsDefault: {
99
+ type: Array,
100
+ default() {
101
+ return [];
102
+ },
103
+ },
104
+ },
105
+ data() {
106
+ return {
107
+ inputBinds: {
108
+ placeholder: this.placeholder,
109
+ readonly: this.readonly || !this.editable,
110
+ },
111
+ inputEvents: {
112
+ change: this.onInputChange,
113
+ focus: this.onInputFocus,
114
+ blur: this.onInputBlur,
115
+ },
116
+ };
117
+ },
118
+ methods: {
119
+ changeColor(val) {
120
+ /**
121
+ * Input event
122
+ * @property {String} color
123
+ */
124
+ this.$emit('input', val);
125
+ /**
126
+ * Change event
127
+ * @property {String} color
128
+ */
129
+ this.$emit('change', val);
130
+ },
131
+ onRootFocus(e) {
132
+ let input = this.getInputRef();
133
+ input && input.focus();
134
+ },
135
+ onInputChange(e) {
136
+ this.changeColor(e.target.value);
137
+ },
138
+ onInputFocus(e) {
139
+ this.rootHasFocus = true;
140
+ },
141
+ onInputBlur(e) {
142
+ this.rootHasFocus = false;
143
+ },
144
+ onSubmit({ rgba }) {
145
+ let { r, g, b, a } = rgba;
146
+ this.changeColor(`rgba(${r}, ${g}, ${b}, ${a})`);
147
+ this.popoverShow = false;
148
+ },
149
+ },
150
+ };
151
+ </script>
@@ -1,121 +1,121 @@
1
- Simple example
2
-
3
- ```vue
4
- <template>
5
- <div class="pad-l5">
6
- <p>value: {{ model }}</p>
7
- <div class="p">
8
- <label>
9
- <input
10
- class="checkbox checkbox-small"
11
- type="checkbox"
12
- v-model="props.datepicker.range"
13
- /><i></i>
14
- <span class="pad-left-2 v-mid">range</span>
15
- </label>
16
- </div>
17
- <input-date-picker class="w-6-12" v-model="model" v-bind="props"></input-date-picker>
18
- </div>
19
- </template>
20
- <script>
21
- export default {
22
- data() {
23
- return {
24
- model: '',
25
- props: {
26
- placeholder: 'Pick dates',
27
- datepicker: {
28
- range: false,
29
- },
30
- },
31
- };
32
- },
33
- };
34
- </script>
35
- ```
36
-
37
- Advanced example. Custom format, slots etc
38
-
39
- ```vue
40
- <template>
41
- <div class="pad-l5">
42
- <p>value: {{ model }}</p>
43
- <p>
44
- <input-date-picker class="w-6-12" v-model="model" v-bind="props" v-on="events">
45
- <template #clear="{ clear }">
46
- <b class="text-xsmall cursor-pointer color-red mar-h-2" @click="clear">clear</b>
47
- </template>
48
- <template #icon="{ toggle }">
49
- <b class="text-xsmall cursor-pointer" @click="toggle">DP</b>
50
- </template>
51
- <template #dp-left>
52
- <div class="mar-l1">
53
- <p v-for="n in offsets" :key="n">
54
- <span
55
- class="btn btn-small d-flex"
56
- :class="[offset == n ? 'btn-primary' : 'btn-ghost']"
57
- @click="setOffset(n)"
58
- >
59
- {{ n }} d
60
- </span>
61
- </p>
62
- </div>
63
- </template>
64
- </input-date-picker>
65
- </p>
66
- <pre style="height:8rem">{{ log }}</pre>
67
- </div>
68
- </template>
69
- <script>
70
- let dayjs = window.dayjs;
71
- dayjs.locale(window.dayjs_locale_ru);
72
- dayjs.extend(window.dayjs_plugin_customParseFormat);
73
-
74
- let format = 'DD MMM YYYY';
75
-
76
- export default {
77
- data() {
78
- return {
79
- log: '',
80
- offset: 0,
81
- offsets: [3, 7, 14],
82
- model: [],
83
- props: {
84
- placeholder: 'Pick a date',
85
- toDate(str) {
86
- return str ? dayjs(str, format).toDate() : null;
87
- },
88
- toValue(date) {
89
- return dayjs(date).format(format);
90
- },
91
- datepicker: {
92
- range: true,
93
- },
94
- },
95
- events: {
96
- clear: this.onClear,
97
- 'set-date': this.onSetDate,
98
- },
99
- };
100
- },
101
- methods: {
102
- onClear() {
103
- this.log = `event:clear\n` + this.log;
104
- },
105
- onSetDate(d) {
106
- let { toValue } = this.props;
107
- this.log = `event:set-date ${d}\n` + this.log;
108
- if (this.offset) {
109
- let d2 = dayjs(d)
110
- .add(this.offset, 'd')
111
- .toDate();
112
- this.model = [toValue(d), toValue(d2)];
113
- }
114
- },
115
- setOffset(n) {
116
- this.offset = this.offset == n ? 0 : n;
117
- },
118
- },
119
- };
120
- </script>
121
- ```
1
+ Simple example
2
+
3
+ ```vue
4
+ <template>
5
+ <div class="pad-l5">
6
+ <p>value: {{ model }}</p>
7
+ <div class="p">
8
+ <label>
9
+ <input
10
+ class="checkbox checkbox-small"
11
+ type="checkbox"
12
+ v-model="props.datepicker.range"
13
+ /><i></i>
14
+ <span class="pad-left-2 v-mid">range</span>
15
+ </label>
16
+ </div>
17
+ <input-date-picker class="w-6-12" v-model="model" v-bind="props"></input-date-picker>
18
+ </div>
19
+ </template>
20
+ <script>
21
+ export default {
22
+ data() {
23
+ return {
24
+ model: '',
25
+ props: {
26
+ placeholder: 'Pick dates',
27
+ datepicker: {
28
+ range: false,
29
+ },
30
+ },
31
+ };
32
+ },
33
+ };
34
+ </script>
35
+ ```
36
+
37
+ Advanced example. Custom format, slots etc
38
+
39
+ ```vue
40
+ <template>
41
+ <div class="pad-l5">
42
+ <p>value: {{ model }}</p>
43
+ <p>
44
+ <input-date-picker class="w-6-12" v-model="model" v-bind="props" v-on="events">
45
+ <template #clear="{ clear }">
46
+ <b class="text-xsmall cursor-pointer color-red mar-h-2" @click="clear">clear</b>
47
+ </template>
48
+ <template #icon="{ toggle }">
49
+ <b class="text-xsmall cursor-pointer" @click="toggle">DP</b>
50
+ </template>
51
+ <template #dp-left>
52
+ <div class="mar-l1">
53
+ <p v-for="n in offsets" :key="n">
54
+ <span
55
+ class="btn btn-small d-flex"
56
+ :class="[offset == n ? 'btn-primary' : 'btn-ghost']"
57
+ @click="setOffset(n)"
58
+ >
59
+ {{ n }} d
60
+ </span>
61
+ </p>
62
+ </div>
63
+ </template>
64
+ </input-date-picker>
65
+ </p>
66
+ <pre style="height:8rem">{{ log }}</pre>
67
+ </div>
68
+ </template>
69
+ <script>
70
+ let dayjs = window.dayjs;
71
+ dayjs.locale(window.dayjs_locale_ru);
72
+ dayjs.extend(window.dayjs_plugin_customParseFormat);
73
+
74
+ let format = 'DD MMM YYYY';
75
+
76
+ export default {
77
+ data() {
78
+ return {
79
+ log: '',
80
+ offset: 0,
81
+ offsets: [3, 7, 14],
82
+ model: [],
83
+ props: {
84
+ placeholder: 'Pick a date',
85
+ toDate(str) {
86
+ return str ? dayjs(str, format).toDate() : null;
87
+ },
88
+ toValue(date) {
89
+ return dayjs(date).format(format);
90
+ },
91
+ datepicker: {
92
+ range: true,
93
+ },
94
+ },
95
+ events: {
96
+ clear: this.onClear,
97
+ 'set-date': this.onSetDate,
98
+ },
99
+ };
100
+ },
101
+ methods: {
102
+ onClear() {
103
+ this.log = `event:clear\n` + this.log;
104
+ },
105
+ onSetDate(d) {
106
+ let { toValue } = this.props;
107
+ this.log = `event:set-date ${d}\n` + this.log;
108
+ if (this.offset) {
109
+ let d2 = dayjs(d)
110
+ .add(this.offset, 'd')
111
+ .toDate();
112
+ this.model = [toValue(d), toValue(d2)];
113
+ }
114
+ },
115
+ setOffset(n) {
116
+ this.offset = this.offset == n ? 0 : n;
117
+ },
118
+ },
119
+ };
120
+ </script>
121
+ ```