@kizmann/nano-ui 0.8.15 → 0.8.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,400 @@
1
+ import { Obj, Now, Any, Locale } from "@kizmann/pico-js";
2
+
3
+ export default {
4
+
5
+ name: 'NDatetimepicker',
6
+
7
+ props: {
8
+
9
+ modelValue: {
10
+ default()
11
+ {
12
+ return null;
13
+ }
14
+ },
15
+
16
+ clearValue: {
17
+ default()
18
+ {
19
+ return null;
20
+ }
21
+ },
22
+
23
+ minDate: {
24
+ default()
25
+ {
26
+ return null;
27
+ }
28
+ },
29
+
30
+ maxDate: {
31
+ default()
32
+ {
33
+ return null;
34
+ }
35
+ },
36
+
37
+ size: {
38
+ default()
39
+ {
40
+ return 'md';
41
+ },
42
+ type: [String]
43
+ },
44
+
45
+ type: {
46
+ default()
47
+ {
48
+ return 'primary';
49
+ },
50
+ type: [String]
51
+ },
52
+
53
+ placeholder: {
54
+ default()
55
+ {
56
+ return Locale.trans('Select datetime');
57
+ },
58
+ type: [String]
59
+ },
60
+
61
+ monthPanels: {
62
+ default()
63
+ {
64
+ return 1;
65
+ },
66
+ type: [Number]
67
+ },
68
+
69
+ boundary: {
70
+ default()
71
+ {
72
+ return null;
73
+ }
74
+ },
75
+
76
+ position: {
77
+ default()
78
+ {
79
+ return 'bottom-start';
80
+ },
81
+ type: [String]
82
+ },
83
+
84
+ disabled: {
85
+ default()
86
+ {
87
+ return false;
88
+ },
89
+ type: [Boolean]
90
+ },
91
+
92
+ clearable: {
93
+ default()
94
+ {
95
+ return false;
96
+ },
97
+ type: [Boolean]
98
+ },
99
+
100
+ format: {
101
+ default()
102
+ {
103
+ return Locale.trans('YYYY-MM-DD HH:mm:ss');
104
+ },
105
+ type: [String]
106
+ },
107
+
108
+ displayFormat: {
109
+ default()
110
+ {
111
+ return Locale.trans('YYYY-MM-DD HH:mm:ss');
112
+ },
113
+ type: [String]
114
+ },
115
+
116
+ weekdays: {
117
+ default()
118
+ {
119
+ return [
120
+ Locale.trans('Mo'),
121
+ Locale.trans('Tu'),
122
+ Locale.trans('We'),
123
+ Locale.trans('Th'),
124
+ Locale.trans('Fr'),
125
+ Locale.trans('Sa'),
126
+ Locale.trans('Su'),
127
+ ];
128
+ },
129
+ type: [Array]
130
+ },
131
+
132
+ months: {
133
+ default()
134
+ {
135
+ return [
136
+ Locale.trans('Jan'),
137
+ Locale.trans('Feb'),
138
+ Locale.trans('Mar'),
139
+ Locale.trans('Apr'),
140
+ Locale.trans('May'),
141
+ Locale.trans('Jun'),
142
+ Locale.trans('Jul'),
143
+ Locale.trans('Aug'),
144
+ Locale.trans('Sep'),
145
+ Locale.trans('Oct'),
146
+ Locale.trans('Nov'),
147
+ Locale.trans('Dec'),
148
+ ];
149
+ },
150
+ type: [Array]
151
+ }
152
+
153
+ },
154
+
155
+
156
+ watch: {
157
+
158
+ modelValue(value)
159
+ {
160
+ if ( value !== this.tempValue.format(this.format) ) {
161
+ this.tempValue = Now.make(value);
162
+ }
163
+ },
164
+
165
+ },
166
+
167
+ data()
168
+ {
169
+ return {
170
+ focus: false, tempValue: Now.make(this.modelValue, this.format),
171
+ };
172
+ },
173
+
174
+ methods: {
175
+
176
+ clearDatetimepicker()
177
+ {
178
+ this.tempValue = Now.make(this.clearValue,
179
+ this.format);
180
+
181
+ this.$emit('update:modelValue', this.clearValue);
182
+ },
183
+
184
+ onPopoverInput(value)
185
+ {
186
+ this.focus = value;
187
+ },
188
+
189
+ onValueInput(event)
190
+ {
191
+ let isNotSameLength = this.displayFormat.length !==
192
+ event.target.value.length;
193
+
194
+ if ( isNotSameLength ) {
195
+ return;
196
+ }
197
+
198
+ let value = Now.make(event.target.value,
199
+ this.displayFormat);
200
+
201
+ if ( ! value.moment.isValid() ) {
202
+ return;
203
+ }
204
+
205
+ let moment = this.tempValue.moment.set({
206
+ year: value.moment.year(),
207
+ month: value.moment.month(),
208
+ date: value.moment.date(),
209
+ hour: value.moment.hour(),
210
+ minute: value.moment.minute(),
211
+ second: value.moment.second(),
212
+ });
213
+
214
+ this.tempValue = Now.make(moment);
215
+
216
+ this.$emit('update:modelValue',
217
+ this.tempValue.format(this.format));
218
+ },
219
+
220
+ onDatepickerInput(value)
221
+ {
222
+ this.tempValue = Now.make(value,
223
+ this.format);
224
+
225
+ this.$emit('update:modelValue', value);
226
+ },
227
+
228
+ onTimepickerInput(value)
229
+ {
230
+ this.tempValue = Now.make(value,
231
+ this.format);
232
+
233
+ this.$emit('update:modelValue', value);
234
+ },
235
+
236
+ },
237
+
238
+
239
+ renderLabelClear()
240
+ {
241
+ let isEmpty = ! this.tempValue.initialDate;
242
+
243
+ if ( ! this.clearable || isEmpty ) {
244
+ return null;
245
+ }
246
+
247
+ let props = {};
248
+
249
+ if ( ! this.disabled ) {
250
+ props.onMousedown = this.clearDatetimepicker;
251
+ }
252
+
253
+ return (
254
+ <div class="n-datetimepicker__clear" {...props}>
255
+ <i class={ nano.Icons.times }></i>
256
+ </div>
257
+ );
258
+ },
259
+
260
+ renderLabelAngle()
261
+ {
262
+ return (
263
+ <div class="n-datetimepicker__angle">
264
+ <i class={ nano.Icons.angleDown }></i>
265
+ </div>
266
+ );
267
+ },
268
+
269
+ renderSingle()
270
+ {
271
+ let props = {
272
+ value: '',
273
+ disabled: this.disabled,
274
+ placeholder: this.placeholder,
275
+ onInput: this.onValueInput,
276
+ };
277
+
278
+ if ( this.tempValue.valid() ) {
279
+ props.value = this.tempValue.format(
280
+ this.displayFormat, true);
281
+ }
282
+
283
+ return (
284
+ <div class="n-datetimepicker__input">
285
+ <input {...props}/>
286
+ </div>
287
+ );
288
+ },
289
+
290
+ renderDisplay()
291
+ {
292
+ let classList = [
293
+ 'n-datetimepicker__display'
294
+ ];
295
+
296
+ if ( this.range ) {
297
+ classList.push('n-range');
298
+ }
299
+
300
+ return (
301
+ <div class={classList}>
302
+ { this.ctor('renderLabelClear')() }
303
+ { this.ctor('renderSingle')() }
304
+ { this.ctor('renderLabelAngle')() }
305
+ </div>
306
+ );
307
+ },
308
+
309
+ renderPanels()
310
+ {
311
+ return (
312
+ <div class="n-datetimepicker__body">
313
+ {[this.ctor('renderDatePanel')(), this.ctor('renderTimePanel')()]}
314
+ </div>
315
+ );
316
+ },
317
+
318
+ renderDatePanel()
319
+ {
320
+
321
+ let props = Obj.except(this.$props, ['modelValue'], {
322
+ modelValue: this.tempValue.format(this.format) || null,
323
+ });
324
+
325
+ props['onUpdate:modelValue'] = this.onDatepickerInput;
326
+
327
+ return (
328
+ <NDatepickerPanel class="n-datetimepicker__date-panel" {...props}></NDatepickerPanel>
329
+ );
330
+ },
331
+
332
+ renderTimePanel()
333
+ {
334
+
335
+ let props = Obj.except(this.$props, ['modelValue'], {
336
+ modelValue: this.tempValue.format(this.format) || null,
337
+ });
338
+
339
+ props['onUpdate:modelValue'] = this.onTimepickerInput;
340
+
341
+ return (
342
+ <NTimepickerPanel class="n-datetimepicker__time-panel" {...props}></NTimepickerPanel>
343
+ );
344
+ },
345
+
346
+ renderPopover()
347
+ {
348
+ let props = {
349
+ trigger: 'click',
350
+ width: 0,
351
+ size: this.size,
352
+ position: this.position,
353
+ scrollClose: true,
354
+ disabled: this.disabled
355
+ };
356
+
357
+ let slots = {
358
+ raw: this.ctor('renderPanels')
359
+ };
360
+
361
+ return (
362
+ <NPopover ref="popover" vModel={this.focus} {...props} v-slots={slots} />
363
+ );
364
+ },
365
+
366
+ render()
367
+ {
368
+ let classList = [
369
+ 'n-datetimepicker',
370
+ 'n-datetimepicker--' + this.type,
371
+ 'n-datetimepicker--' + this.size,
372
+ ];
373
+
374
+ let isEmpty = ! this.tempValue.initialDate;
375
+
376
+ if ( isEmpty ) {
377
+ classList.push('n-empty');
378
+ }
379
+
380
+ if ( this.clearable ) {
381
+ classList.push('n-clearable');
382
+ }
383
+
384
+ if ( this.focus ) {
385
+ classList.push('n-focus');
386
+ }
387
+
388
+ if ( this.disabled ) {
389
+ classList.push('n-disabled');
390
+ }
391
+
392
+ return (
393
+ <div class={classList}>
394
+ { this.ctor('renderDisplay')() }
395
+ { this.ctor('renderPopover')() }
396
+ </div>
397
+ );
398
+ }
399
+
400
+ }
@@ -0,0 +1,188 @@
1
+ @import "../../../root/vars";
2
+
3
+ .n-datetimepicker {
4
+ display: flex;
5
+ flex-direction: row;
6
+ align-items: stretch;
7
+ justify-content: stretch;
8
+ width: 100%;
9
+ border: 1px solid transparent;
10
+ }
11
+
12
+ .n-datetimepicker.n-disabled {
13
+ cursor: not-allowed;
14
+ opacity: 0.7;
15
+ }
16
+
17
+ .n-datetimepicker__display {
18
+ display: flex;
19
+ flex-direction: row;
20
+ align-items: stretch;
21
+ justify-content: stretch;
22
+ width: 100%;
23
+ }
24
+
25
+ .n-datetimepicker__seperator {
26
+ flex: 0 0 auto;
27
+ display: flex;
28
+ flex-direction: row;
29
+ align-items: center;
30
+ justify-content: center;
31
+ }
32
+
33
+ .n-datetimepicker__input {
34
+ flex: 1 1 auto;
35
+ display: flex;
36
+ flex-direction: row;
37
+ align-items: stretch;
38
+ justify-content: stretch;
39
+ width: 50%;
40
+ }
41
+
42
+ .n-datetimepicker__input input {
43
+ cursor: default;
44
+ appearance: none;
45
+ display: block;
46
+ width: 100%;
47
+ white-space: nowrap;
48
+ text-decoration: none;
49
+ line-height: 1.2;
50
+ border: none;
51
+ background: transparent;
52
+ box-shadow: none;
53
+ }
54
+
55
+ .n-disabled .n-datetimepicker__input input {
56
+ cursor: not-allowed;
57
+ }
58
+
59
+ .n-datetimepicker__clear,
60
+ .n-datetimepicker__angle {
61
+ order: 100;
62
+ flex: 0 0 auto;
63
+ display: flex;
64
+ flex-direction: row;
65
+ align-items: center;
66
+ justify-content: center;
67
+ }
68
+
69
+ .n-datetimepicker__clear {
70
+ display: none;
71
+ }
72
+
73
+ .n-datetimepicker:hover.n-clearable:not(.n-empty) .n-datetimepicker__clear,
74
+ .n-datetimepicker.n-focus.n-clearable:not(.n-empty) .n-datetimepicker__clear {
75
+ display: flex;
76
+ }
77
+
78
+ .n-datetimepicker:hover.n-clearable:not(.n-empty) .n-datetimepicker__angle,
79
+ .n-datetimepicker.n-focus.n-clearable:not(.n-empty) .n-datetimepicker__angle {
80
+ display: none;
81
+ }
82
+
83
+ .n-datetimepicker__angle {
84
+ transition: transform 0.25s;
85
+ }
86
+
87
+ .n-datetimepicker.n-focus .n-datetimepicker__angle {
88
+ transform: scaleY(-1);
89
+ }
90
+
91
+ .n-datetimepicker__clear i,
92
+ .n-datetimepicker__angle i {
93
+ text-align: center;
94
+ }
95
+
96
+ .n-datetimepicker__clear i {
97
+ border-radius: 500px;
98
+ }
99
+
100
+ .n-datetimepicker__placeholder {
101
+ flex: 1 1 auto;
102
+ display: inline-flex;
103
+ flex-direction: row;
104
+ flex-wrap: wrap;
105
+ align-items: center;
106
+ justify-content: flex-start;
107
+ width: 100%;
108
+ }
109
+
110
+ .n-datetimepicker__body,
111
+ .n-datetimepicker__empty {
112
+ overflow: hidden;
113
+ margin: 1px 0;
114
+ border: 0;
115
+ }
116
+
117
+ .n-datetimepicker__body {
118
+ display: flex;
119
+ flex-direction: row;
120
+ justify-content: stretch;
121
+ align-items: stretch;
122
+ }
123
+
124
+ .n-datetimepicker__date-panel.n-datepicker-panel {
125
+ border: none;
126
+ }
127
+
128
+ .n-datetimepicker__time-panel.n-timepicker-panel {
129
+ border: none;
130
+ border-left: 1px solid $color-gray-10;
131
+ background: rgba($color-gray-05, 0.5);
132
+ }
133
+
134
+ .n-datetimepicker__empty {
135
+ text-align: center;
136
+ }
137
+
138
+ @each $suffix, $values in $form {
139
+
140
+ $-datepicker-font: map-get($values, 'font');
141
+ $-datepicker-size: map-get($values, 'size');
142
+ $-datepicker-radius: map-get($values, 'radius');
143
+ $-datepicker-ratio: map-get($values, 'ratio');
144
+
145
+ .n-datetimepicker--#{$suffix} {
146
+ min-height: $-datepicker-size;
147
+ font-size: $-datepicker-font;
148
+ border-radius: $-datepicker-radius;
149
+ }
150
+
151
+ $-datepicker-padding: $-datepicker-size * $-datepicker-ratio * 0.5;
152
+
153
+ .n-datetimepicker--#{$suffix} .n-datetimepicker__display,
154
+ .n-datetimepicker--#{$suffix} .n-datetimepicker__seperator,
155
+ .n-datetimepicker--#{$suffix} .n-datetimepicker__input input {
156
+ padding: 0 $-datepicker-padding;
157
+ }
158
+
159
+ .n-datetimepicker--#{$suffix} .n-datetimepicker__clear,
160
+ .n-datetimepicker--#{$suffix} .n-datetimepicker__angle {
161
+ width: $-datepicker-size;
162
+ margin: 0 -#{$-datepicker-padding} 0 -#{$-datepicker-padding};
163
+ }
164
+ .n-datetimepicker--#{$suffix} .n-datetimepicker__clear i,
165
+ .n-datetimepicker--#{$suffix} .n-datetimepicker__angle i {
166
+ width: $-datepicker-size - 14;
167
+ height: $-datepicker-size - 14;
168
+ line-height: $-datepicker-size - 14;
169
+ }
170
+
171
+ .n-datetimepicker--#{$suffix} .n-datetimepicker__angle i {
172
+ font-size: $-datepicker-font - 2;
173
+ }
174
+
175
+ .n-datetimepicker--#{$suffix} .n-datetimepicker__clear i {
176
+ font-size: $-datepicker-font - 4;
177
+ }
178
+
179
+ .n-popover--#{$suffix} .n-datetimepicker__body,
180
+ .n-popover--#{$suffix} .n-datetimepicker__empty {
181
+ border-radius: $-datepicker-radius;
182
+ }
183
+
184
+ .n-popover--#{$suffix} .n-datetimepicker__empty {
185
+ padding: $-datepicker-padding;
186
+ }
187
+
188
+ }
package/src/index.js CHANGED
@@ -79,7 +79,7 @@ export function Install(App, Icons = {}, Styles = {})
79
79
  require('./cascader/index').default(App);
80
80
  require('./datepicker/index').default(App);
81
81
  require('./timepicker/index').default(App);
82
- // require('./datetimepicker/index'); 18.1
82
+ require('./datetimepicker/index').default(App);
83
83
  require('./transfer/index').default(App);
84
84
  require('./form/index').default(App); // check
85
85
  require('./tabs/index').default(App);
@@ -93,9 +93,6 @@ export function Install(App, Icons = {}, Styles = {})
93
93
  require('./file/index').default(App);
94
94
  require('./rating/index').default(App);
95
95
 
96
- // SX only ez 17.1
97
- // require('./file-list/index'); // SX only 17.1
98
-
99
96
  // require('./chart/index'); // Ignore
100
97
  // require('./wysiwyg/index'); // Ignore
101
98
  }
package/src/index.scss CHANGED
@@ -19,6 +19,7 @@
19
19
  @import "./cascader/index";
20
20
  @import "./datepicker/index";
21
21
  @import "./timepicker/index";
22
+ @import "./datetimepicker/index";
22
23
  @import "./transfer/index";
23
24
  @import "./file/index";
24
25
  @import "./popover/index";
@@ -143,7 +143,7 @@ export default {
143
143
  {
144
144
  return (
145
145
  <div class="n-timepicker-panel__toolbar">
146
- <div class="n-timepicker-panel-display">
146
+ <div class="n-timepicker-panel__display">
147
147
  <span class="n-timepicker-panel__time">
148
148
  { this.tempValue.format(this.displayFormat) || this.placeholder }
149
149
  </span>
@@ -10,13 +10,19 @@
10
10
  }
11
11
 
12
12
  .n-timepicker-panel__body {
13
+ flex: 1 0 auto;
13
14
  display: flex;
14
15
  flex-direction: row;
15
16
  align-items: stretch;
16
17
  justify-content: stretch;
17
18
  }
18
19
 
19
- .n-timepicker-panel-display,
20
+ .n-timepicker-panel__panel {
21
+ flex: 1 0 auto;
22
+ min-height: 0;
23
+ }
24
+
25
+ .n-timepicker-panel__display,
20
26
  .n-timepicker-panel__item {
21
27
  display: flex;
22
28
  flex-direction: row;
@@ -42,7 +48,11 @@
42
48
 
43
49
  .n-timepicker-panel--#{$suffix} .n-timepicker-panel__panel {
44
50
  width: $-timepicker-panel-size * 2;
45
- height: $-timepicker-panel-size * 5;
51
+ min-height: $-timepicker-panel-size * 5;
52
+ }
53
+
54
+ .n-timepicker-panel--#{$suffix} .n-timepicker-panel__display {
55
+ height: $-timepicker-panel-size - 4;
46
56
  }
47
57
 
48
58
  $-timepicker-panel-padding: $-timepicker-panel-size * $-timepicker-panel-ratio;
@@ -0,0 +1 @@
1
+ @import "./src/datetimepicker/datetimepicker";
@@ -0,0 +1,49 @@
1
+ @import "../../../root/vars";
2
+
3
+ .n-datetimepicker {
4
+ border: 1px solid $color-gray-15;
5
+ }
6
+
7
+ .n-datetimepicker.n-disabled {
8
+ background: rgba($color-gray-15, 0.3);
9
+ }
10
+
11
+ .n-datetimepicker__seperator {
12
+ color: $color-gray-60;
13
+ }
14
+
15
+ .n-datetimepicker__clear,
16
+ .n-datetimepicker__angle {
17
+ color: $color-gray-60;
18
+ }
19
+
20
+ .n-datetimepicker__clear i {
21
+ background: rgba($color-gray-15, 0.6);
22
+ }
23
+
24
+ .n-datetimepicker__placeholder {
25
+ color: rgba($color-black, 0.5);
26
+ }
27
+
28
+ .n-datetimepicker__body,
29
+ .n-datetimepicker__empty {
30
+ background: $color-white;
31
+ box-shadow: 0 1px 3px 1px rgba($color-shadow, 0.15);
32
+ }
33
+
34
+ .n-datetimepicker__empty {
35
+ color: $color-gray-60;
36
+ }
37
+
38
+ @each $color, $values in $colors {
39
+
40
+ $-color-base: map_get($values, 'base');
41
+ $-color-light: map_get($values, 'light');
42
+ $-color-dark: map_get($values, 'dark');
43
+
44
+ .n-datetimepicker--#{$color}:not(.n-disabled):hover,
45
+ .n-datetimepicker--#{$color}:not(.n-disabled).n-focus {
46
+ border-color: $-color-base;
47
+ }
48
+
49
+ }
@@ -19,6 +19,7 @@
19
19
  @import "./cascader/index";
20
20
  @import "./datepicker/index";
21
21
  @import "./timepicker/index";
22
+ @import "./datetimepicker/index";
22
23
  @import "./transfer/index";
23
24
  @import "./popover/index";
24
25
  @import "./modal/index";