inviton-powerduck 0.0.158 → 0.0.160
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.
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
.pd-dropdown-open-animation {
|
|
2
|
+
animation: pdInputShowAnimationIn 180ms cubic-bezier(.2, .8, .2, 1);
|
|
3
|
+
transform-origin: top center;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.pd-dropdown-open-animation-above {
|
|
7
|
+
animation: pdInputShowAnimationInAbove 180ms cubic-bezier(.2, .8, .2, 1);
|
|
8
|
+
transform-origin: bottom center;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.pd-dropdown-close-animation {
|
|
12
|
+
animation: pdInputHideAnimationInAbove 160ms cubic-bezier(.4, .2, .2, 1);
|
|
13
|
+
transform-origin: top center;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.pd-dropdown-close-animation-above {
|
|
17
|
+
animation: pdInputHideAnimationInAboveAbove 160ms cubic-bezier(.4, .2, .2, 1);
|
|
18
|
+
transform-origin: bottom center;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@keyframes pdInputShowAnimationIn {
|
|
23
|
+
0% {
|
|
24
|
+
opacity: 0;
|
|
25
|
+
transform: translateY(-6px) scale(.95);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
100% {
|
|
29
|
+
opacity: 1;
|
|
30
|
+
transform: translateY(0) scale(1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@keyframes pdInputShowAnimationInAbove {
|
|
35
|
+
0% {
|
|
36
|
+
opacity: 0;
|
|
37
|
+
transform: translateY(6px) scale(.95);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
100% {
|
|
41
|
+
opacity: 1;
|
|
42
|
+
transform: translateY(0) scale(1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@keyframes pdInputHideAnimationInAbove {
|
|
47
|
+
0% {
|
|
48
|
+
opacity: 1;
|
|
49
|
+
transform: translateY(0) scale(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
100% {
|
|
53
|
+
opacity: 0;
|
|
54
|
+
transform: translateY(-6px) scale(.96);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@keyframes pdInputHideAnimationInAboveAbove {
|
|
59
|
+
0% {
|
|
60
|
+
opacity: 1;
|
|
61
|
+
transform: translateY(0) scale(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
100% {
|
|
65
|
+
opacity: 0;
|
|
66
|
+
transform: translateY(6px) scale(.96);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@media (prefers-reduced-motion: reduce) {
|
|
72
|
+
|
|
73
|
+
.pd-dropdown-open-animation,
|
|
74
|
+
.pd-dropdown-open-animation-above-above {
|
|
75
|
+
animation: none;
|
|
76
|
+
}
|
|
77
|
+
}
|
package/common/validation.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Validation } from '@vuelidate/core';
|
|
2
2
|
import type { PowerduckViewModelBase } from './base-component';
|
|
3
3
|
import type { IValidationSet, ValidationRuleset, ValidationState } from './static-wrappers/interfaces/validation-interface';
|
|
4
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
4
5
|
import {
|
|
5
6
|
alpha,
|
|
6
7
|
alphaNum,
|
|
@@ -21,10 +22,11 @@ import {
|
|
|
21
22
|
requiredUnless,
|
|
22
23
|
url,
|
|
23
24
|
} from '@vuelidate/validators';
|
|
25
|
+
import { unref } from 'vue';
|
|
24
26
|
import PowerduckState from '../app/powerduck-state';
|
|
27
|
+
import { capitalize } from './extensions/string-extensions';
|
|
25
28
|
import LocalizedValueHelper from './localized-value-helper';
|
|
26
29
|
import { isNullOrEmpty } from './utils/is-null-or-empty';
|
|
27
|
-
import { capitalize } from './extensions/string-extensions';
|
|
28
30
|
|
|
29
31
|
const getFirstUnsattisfiedValidatorName = (valProp: Validation): string | null => {
|
|
30
32
|
const errors = valProp?.$errors || [];
|
|
@@ -134,6 +136,43 @@ export class ValidationHelper {
|
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
|
|
139
|
+
const customReq = (value: any): boolean => {
|
|
140
|
+
value = unref(value);
|
|
141
|
+
|
|
142
|
+
if (Array.isArray(value)) {
|
|
143
|
+
return !!value.length;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (value === undefined || value === null) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (value === false) {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (value instanceof Date) {
|
|
155
|
+
return !isNaN(value.getTime());
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (typeof Temporal !== 'undefined') {
|
|
159
|
+
if (value instanceof Temporal.PlainDateTime || value instanceof Temporal.PlainDate || value instanceof Temporal.ZonedDateTime || value instanceof Temporal.Instant) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (typeof value === 'object') {
|
|
165
|
+
// eslint-disable-next-line no-unreachable-loop
|
|
166
|
+
for (const _ in value) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return !!String(value).length;
|
|
174
|
+
};
|
|
175
|
+
|
|
137
176
|
export class ValidationBuilder {
|
|
138
177
|
private _validationArgs: any = {};
|
|
139
178
|
|
|
@@ -150,8 +189,30 @@ export class ValidationBuilder {
|
|
|
150
189
|
return this;
|
|
151
190
|
}
|
|
152
191
|
|
|
153
|
-
requiredIf
|
|
154
|
-
|
|
192
|
+
requiredIf(field: string | ((vm: any, parentVm?: PowerduckViewModelBase) => boolean)): ValidationBuilder {
|
|
193
|
+
const requireIf = (propOrFunction: boolean | string | ((...args: any[]) => boolean)) => {
|
|
194
|
+
const validate = (prop: any, val: any) => prop ? customReq(typeof val === 'string' ? val.trim() : val) : true;
|
|
195
|
+
|
|
196
|
+
return function (
|
|
197
|
+
this: any,
|
|
198
|
+
value: any,
|
|
199
|
+
parentVM: any,
|
|
200
|
+
) {
|
|
201
|
+
if (typeof propOrFunction != 'function') {
|
|
202
|
+
return validate((propOrFunction), value);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const result = propOrFunction.call(
|
|
206
|
+
this,
|
|
207
|
+
value,
|
|
208
|
+
parentVM,
|
|
209
|
+
);
|
|
210
|
+
return validate(result, value);
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
this._validationArgs.requiredIf = requireIf(field);
|
|
215
|
+
|
|
155
216
|
return this;
|
|
156
217
|
}
|
|
157
218
|
|
|
@@ -29,7 +29,7 @@ function getFlaggedResult(h, state, originator): void {
|
|
|
29
29
|
if (originator == 'mobile') {
|
|
30
30
|
return (<span>{state.text}</span>);
|
|
31
31
|
} else {
|
|
32
|
-
return (<span><span class={`fi fi-${state.
|
|
32
|
+
return (<span><span class={`fi fi-${state.twoLetters}`}></span> {state.text}</span>);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -14,6 +14,7 @@ import FilterableSelect from './mobile/legacy_fdd';
|
|
|
14
14
|
import 'select2';
|
|
15
15
|
import './ts/select2-multi-checkboxes';
|
|
16
16
|
import 'select2/dist/css/select2.css';
|
|
17
|
+
import './../../app/css/input-effects.css';
|
|
17
18
|
import './css/dropdown.css';
|
|
18
19
|
import { capitalize } from '../../common/extensions/string-extensions';
|
|
19
20
|
|
|
@@ -447,10 +448,10 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
447
448
|
const self = this;
|
|
448
449
|
return (row) => {
|
|
449
450
|
const retVal = $(`<span class="s2-ri-withtb">${row.text
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
451
|
+
}<button class="s2-trailing-button ${self.trailingButton.cssClass || ''
|
|
452
|
+
} btn-sm">${self.trailingButton.icon != null ? `<i class="${self.trailingButton.icon}"></i> ` : ''
|
|
453
|
+
}${self.trailingButton.text || ''
|
|
454
|
+
}</button></span>`);
|
|
454
455
|
retVal.find('button').click((e) => {
|
|
455
456
|
try {
|
|
456
457
|
clearTimeout(self.preventDefaultTimeout);
|
|
@@ -541,10 +542,10 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
541
542
|
useListviewBuilder: false,
|
|
542
543
|
formatSelection: this.customRenderSelectionResult != null
|
|
543
544
|
? this.handleCustomRenderResult(
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
545
|
+
h,
|
|
546
|
+
this.customRenderSelectionResult,
|
|
547
|
+
'mobile',
|
|
548
|
+
)
|
|
548
549
|
: null,
|
|
549
550
|
formatResult: this.getCustomFormatOptions(h, 'mobile'),
|
|
550
551
|
onItemSelected: (items, exclusivity) => {
|
|
@@ -759,6 +760,21 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
759
760
|
s2Elem
|
|
760
761
|
.attr('data-vebound', 'true')
|
|
761
762
|
.on('select2:close', () => {
|
|
763
|
+
const $container = DropdownSelect2Helper.getSelect2Instance(this.getSelect2RootElement()).$dropdown;
|
|
764
|
+
$container.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above');
|
|
765
|
+
$container[0].offsetWidth;
|
|
766
|
+
|
|
767
|
+
if ($container.hasClass('select2-container--above')) {
|
|
768
|
+
$container.addClass('pd-dropdown-close-animation-above');
|
|
769
|
+
} else {
|
|
770
|
+
$container.addClass('pd-dropdown-close-animation');
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
$container.one('animationend', function () {
|
|
774
|
+
$container.removeClass('pd-dropdown-close-animation pd-dropdown-close-animation-above');
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
|
|
762
778
|
if (self.pendingChange != null) {
|
|
763
779
|
const data = self.pendingChange?.data;
|
|
764
780
|
self.pendingChange = null;
|
|
@@ -772,6 +788,17 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
772
788
|
e.stopPropagation();
|
|
773
789
|
}
|
|
774
790
|
})
|
|
791
|
+
.on('select2:open', () => {
|
|
792
|
+
const $container = DropdownSelect2Helper.getSelect2Instance(this.getSelect2RootElement()).$dropdown;
|
|
793
|
+
$container.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above pd-dropdown-close-animation pd-dropdown-close-animation-above');
|
|
794
|
+
$container[0].offsetWidth; // reflow
|
|
795
|
+
|
|
796
|
+
if ($container.hasClass('select2-container--above')) {
|
|
797
|
+
$container.addClass('pd-dropdown-open-animation-above');
|
|
798
|
+
} else {
|
|
799
|
+
$container.addClass('pd-dropdown-open-animation');
|
|
800
|
+
}
|
|
801
|
+
})
|
|
775
802
|
.on('select2:unselect', (e) => {
|
|
776
803
|
(self as any).preventOpen = true;
|
|
777
804
|
setTimeout(() => {
|
|
@@ -1069,11 +1069,15 @@ import { utcEpochMilliseconds } from '../../../../common/extensions/temporal-ext
|
|
|
1069
1069
|
});
|
|
1070
1070
|
});
|
|
1071
1071
|
} else {
|
|
1072
|
-
box
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1072
|
+
box.show();
|
|
1073
|
+
box.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above');
|
|
1074
|
+
box[0].offsetWidth; // reflow
|
|
1075
|
+
|
|
1076
|
+
if (box.hasClass('select2-container--above')) {
|
|
1077
|
+
box.addClass('pd-dropdown-open-animation-above');
|
|
1078
|
+
} else {
|
|
1079
|
+
box.addClass('pd-dropdown-open-animation');
|
|
1080
|
+
}
|
|
1077
1081
|
}
|
|
1078
1082
|
|
|
1079
1083
|
$(self).trigger('datepicker-open', {
|
|
@@ -1932,7 +1936,9 @@ import { utcEpochMilliseconds } from '../../../../common/extensions/temporal-ext
|
|
|
1932
1936
|
}
|
|
1933
1937
|
|
|
1934
1938
|
function closeDatePicker(): void {
|
|
1935
|
-
if (opt.alwaysOpen) {
|
|
1939
|
+
if (opt.alwaysOpen) {
|
|
1940
|
+
return;
|
|
1941
|
+
}
|
|
1936
1942
|
|
|
1937
1943
|
const afterAnim = function () {
|
|
1938
1944
|
$(self).data('date-picker-opened', false);
|
|
@@ -1943,7 +1949,14 @@ import { utcEpochMilliseconds } from '../../../../common/extensions/temporal-ext
|
|
|
1943
1949
|
if (opt.customCloseAnimation) {
|
|
1944
1950
|
opt.customCloseAnimation.call(box.get(0), afterAnim);
|
|
1945
1951
|
} else {
|
|
1946
|
-
|
|
1952
|
+
box.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above pd-dropdown-close-animation pd-dropdown-close-animation-above');
|
|
1953
|
+
box[0].offsetWidth; // reflow
|
|
1954
|
+
box.addClass('pd-dropdown-close-animation');
|
|
1955
|
+
|
|
1956
|
+
box.one('animationend', function () {
|
|
1957
|
+
box.hide();
|
|
1958
|
+
box.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above pd-dropdown-close-animation pd-dropdown-close-animation-above');
|
|
1959
|
+
});
|
|
1947
1960
|
}
|
|
1948
1961
|
|
|
1949
1962
|
$(self).trigger('datepicker-close', {
|