@zeedhi/common 1.69.0 → 1.70.0
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.
- package/dist/zd-common.esm.js +96 -37
- package/dist/zd-common.umd.js +96 -37
- package/package.json +2 -2
- package/types/components/zd-select-tree-multiple/interfaces.d.ts +3 -0
- package/types/components/zd-select-tree-multiple/select-tree-multiple.d.ts +11 -0
- package/types/components/zd-time/time-format-selector.d.ts +8 -0
- package/types/components/zd-time/time.d.ts +1 -2
package/dist/zd-common.esm.js
CHANGED
|
@@ -9985,8 +9985,9 @@ class SelectTree extends TextInput {
|
|
|
9985
9985
|
}
|
|
9986
9986
|
setValue(value) {
|
|
9987
9987
|
let val = value;
|
|
9988
|
+
const key = this.datasource ? this.dataValue : 'id';
|
|
9988
9989
|
if (typeof value === 'object' && !Array.isArray(value) && value !== null) {
|
|
9989
|
-
val = value[
|
|
9990
|
+
val = value[key];
|
|
9990
9991
|
}
|
|
9991
9992
|
else if (!value && value !== 0) {
|
|
9992
9993
|
val = null;
|
|
@@ -10042,9 +10043,14 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
10042
10043
|
* Changes the behavior of checked nodes that will be displayed in the array of values
|
|
10043
10044
|
*/
|
|
10044
10045
|
this.valueConsistsOf = 'LEAF_PRIORITY';
|
|
10046
|
+
/**
|
|
10047
|
+
* Show the selectAll option
|
|
10048
|
+
*/
|
|
10049
|
+
this.showSelectAll = false;
|
|
10045
10050
|
this.flat = this.getInitValue('flat', props.flat, this.flat);
|
|
10046
10051
|
this.limit = this.getInitValue('limit', props.limit, this.limit);
|
|
10047
10052
|
this.valueConsistsOf = this.getInitValue('valueConsistsOf', props.valueConsistsOf, this.valueConsistsOf);
|
|
10053
|
+
this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
|
|
10048
10054
|
this.createAccessors();
|
|
10049
10055
|
}
|
|
10050
10056
|
/**
|
|
@@ -10070,22 +10076,56 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
10070
10076
|
}
|
|
10071
10077
|
setValue(value) {
|
|
10072
10078
|
const arrValue = Array.isArray(value) ? value : [value];
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
if (typeof item !== 'object') {
|
|
10076
|
-
return { id: item };
|
|
10077
|
-
}
|
|
10078
|
-
return { id: item[this.dataValue] };
|
|
10079
|
-
});
|
|
10080
|
-
}
|
|
10081
|
-
else {
|
|
10079
|
+
const key = this.datasource ? this.dataValue : 'id';
|
|
10080
|
+
if (!this.returnObject) {
|
|
10082
10081
|
this.value = arrValue.map((item) => {
|
|
10083
10082
|
if (typeof item === 'object') {
|
|
10084
|
-
return item[
|
|
10083
|
+
return item[key];
|
|
10085
10084
|
}
|
|
10086
10085
|
return item;
|
|
10087
10086
|
});
|
|
10087
|
+
return;
|
|
10088
10088
|
}
|
|
10089
|
+
this.value = arrValue.map((item) => {
|
|
10090
|
+
if (typeof item !== 'object') {
|
|
10091
|
+
return { id: item };
|
|
10092
|
+
}
|
|
10093
|
+
return { id: item[key] };
|
|
10094
|
+
});
|
|
10095
|
+
}
|
|
10096
|
+
getAllNodes(nodes = this.nodes) {
|
|
10097
|
+
let result = nodes;
|
|
10098
|
+
nodes.forEach((node) => {
|
|
10099
|
+
if (!node.children)
|
|
10100
|
+
return;
|
|
10101
|
+
const childNodes = this.getAllNodes(node.children);
|
|
10102
|
+
result = [...result, ...childNodes];
|
|
10103
|
+
});
|
|
10104
|
+
return result;
|
|
10105
|
+
}
|
|
10106
|
+
/**
|
|
10107
|
+
* Dispatches select/unselect event
|
|
10108
|
+
*/
|
|
10109
|
+
onSelectAll(isSelected, event, element) {
|
|
10110
|
+
if (isSelected) {
|
|
10111
|
+
this.callEvent('selectedAll', { event, element, component: this });
|
|
10112
|
+
if (!event.defaultPrevented) {
|
|
10113
|
+
this.selectAllItems();
|
|
10114
|
+
}
|
|
10115
|
+
}
|
|
10116
|
+
else {
|
|
10117
|
+
this.callEvent('unselectedAll', { event, element, component: this });
|
|
10118
|
+
if (!event.defaultPrevented) {
|
|
10119
|
+
this.unSelectAllItems();
|
|
10120
|
+
}
|
|
10121
|
+
}
|
|
10122
|
+
}
|
|
10123
|
+
selectAllItems() {
|
|
10124
|
+
const allNodes = this.datasource ? this.datasource.data : this.getAllNodes();
|
|
10125
|
+
this.setValue(allNodes);
|
|
10126
|
+
}
|
|
10127
|
+
unSelectAllItems() {
|
|
10128
|
+
this.setValue([]);
|
|
10089
10129
|
}
|
|
10090
10130
|
}
|
|
10091
10131
|
|
|
@@ -10660,6 +10700,27 @@ class Textarea extends TextInput {
|
|
|
10660
10700
|
}
|
|
10661
10701
|
}
|
|
10662
10702
|
|
|
10703
|
+
/**
|
|
10704
|
+
* Selects the time format by the rule:
|
|
10705
|
+
* non-common format > common format
|
|
10706
|
+
* and if the format is a common format, it will be overriden by timeFormat
|
|
10707
|
+
*/
|
|
10708
|
+
class TimeFormatSelector {
|
|
10709
|
+
getFormat(format, timeFormat, useSeconds) {
|
|
10710
|
+
const commonsDisplay = ['hh:mm A', 'hh:mm:ss A', 'HH:mm:ss', 'HH:mm'];
|
|
10711
|
+
const seconds = useSeconds ? ':ss' : '';
|
|
10712
|
+
const defaultFormats = {
|
|
10713
|
+
ampm: `hh:mm${seconds} A`,
|
|
10714
|
+
'24hr': `HH:mm${seconds}`,
|
|
10715
|
+
};
|
|
10716
|
+
const timeFormats = ['ampm', '24hr'];
|
|
10717
|
+
if (commonsDisplay.includes(format) && timeFormats.includes(timeFormat)) {
|
|
10718
|
+
return defaultFormats[timeFormat];
|
|
10719
|
+
}
|
|
10720
|
+
return format;
|
|
10721
|
+
}
|
|
10722
|
+
}
|
|
10723
|
+
|
|
10663
10724
|
/**
|
|
10664
10725
|
* Base class for Time Picker component.
|
|
10665
10726
|
*/
|
|
@@ -10748,21 +10809,20 @@ class Time extends TextInput {
|
|
|
10748
10809
|
this.initialMask = this.getInitialMask();
|
|
10749
10810
|
this.isSimpleDisplay = this.isSimpleFormat(this.displayFormat);
|
|
10750
10811
|
}
|
|
10812
|
+
getFormat(format, timeFormat) {
|
|
10813
|
+
const timeFormatSelector = new TimeFormatSelector();
|
|
10814
|
+
const selectedFormat = timeFormatSelector.getFormat(format, timeFormat, this.useSeconds);
|
|
10815
|
+
return selectedFormat;
|
|
10816
|
+
}
|
|
10751
10817
|
get displayFormat() {
|
|
10752
|
-
|
|
10753
|
-
if (commonsDisplay.includes(this.displayFormatInternal)) {
|
|
10754
|
-
this.displayFormatInternal = this.defaultFormats[this.timeFormat];
|
|
10755
|
-
}
|
|
10818
|
+
this.displayFormatInternal = this.getFormat(this.displayFormatInternal, this.timeFormat);
|
|
10756
10819
|
return this.displayFormatInternal;
|
|
10757
10820
|
}
|
|
10758
10821
|
set displayFormat(value) {
|
|
10759
10822
|
this.displayFormatInternal = value;
|
|
10760
10823
|
}
|
|
10761
10824
|
get valueFormat() {
|
|
10762
|
-
|
|
10763
|
-
if (commonsDisplay.includes(this.valueFormatInternal)) {
|
|
10764
|
-
this.valueFormatInternal = this.defaultFormats['24hr'];
|
|
10765
|
-
}
|
|
10825
|
+
this.valueFormatInternal = this.getFormat(this.valueFormatInternal, '24hr');
|
|
10766
10826
|
return this.valueFormatInternal;
|
|
10767
10827
|
}
|
|
10768
10828
|
set valueFormat(value) {
|
|
@@ -10772,13 +10832,6 @@ class Time extends TextInput {
|
|
|
10772
10832
|
this.isoFormatValue = this.useSeconds ? 'HH:mm:ss' : 'HH:mm';
|
|
10773
10833
|
return this.isoFormatValue;
|
|
10774
10834
|
}
|
|
10775
|
-
get defaultFormats() {
|
|
10776
|
-
const seconds = this.useSeconds ? ':ss' : '';
|
|
10777
|
-
return {
|
|
10778
|
-
ampm: `hh:mm${seconds} A`,
|
|
10779
|
-
'24hr': `HH:mm${seconds}`,
|
|
10780
|
-
};
|
|
10781
|
-
}
|
|
10782
10835
|
getInitialMask() {
|
|
10783
10836
|
if (isUndefined(this.mask)) {
|
|
10784
10837
|
this.mask = this.inputFormat && this.maskFormat(this.inputFormat);
|
|
@@ -10985,45 +11038,51 @@ class Time extends TextInput {
|
|
|
10985
11038
|
this.change(this.value);
|
|
10986
11039
|
}
|
|
10987
11040
|
}
|
|
10988
|
-
FormatterParserProvider.registerFormatter('ZdTime', (value, { valueFormat = Config.valueTimeFormat, displayFormat = Config.displayTimeFormat, inputFormat = Config.timeInputFormat, mask = '', initialMask, isSimpleDisplay = false, } = {}) => {
|
|
11041
|
+
FormatterParserProvider.registerFormatter('ZdTime', (value, { valueFormat = Config.valueTimeFormat, displayFormat = Config.displayTimeFormat, inputFormat = Config.timeInputFormat, timeFormat = Config.timeFormat || 'ampm', useSeconds = false, mask = '', initialMask, isSimpleDisplay = false, } = {}) => {
|
|
10989
11042
|
if (!value) {
|
|
10990
11043
|
return '';
|
|
10991
11044
|
}
|
|
10992
|
-
const
|
|
11045
|
+
const timeFormatSelector = new TimeFormatSelector();
|
|
11046
|
+
const timeDisplayFormat = timeFormatSelector.getFormat(displayFormat, timeFormat, useSeconds);
|
|
11047
|
+
const timeValueFormat = timeFormatSelector.getFormat(valueFormat, '24hr', useSeconds);
|
|
11048
|
+
const isTimeValid = dayjs(value, timeValueFormat, true).isValid();
|
|
10993
11049
|
if (!isTimeValid) {
|
|
10994
11050
|
return value;
|
|
10995
11051
|
}
|
|
10996
11052
|
if (mask && initialMask) {
|
|
10997
11053
|
if (inputFormat) {
|
|
10998
|
-
return dayjs(value,
|
|
11054
|
+
return dayjs(value, timeValueFormat).format(inputFormat);
|
|
10999
11055
|
}
|
|
11000
11056
|
let valueToUnmask = value;
|
|
11001
11057
|
if (isSimpleDisplay) {
|
|
11002
|
-
valueToUnmask = dayjs(value,
|
|
11058
|
+
valueToUnmask = dayjs(value, timeValueFormat).format(timeDisplayFormat);
|
|
11003
11059
|
}
|
|
11004
11060
|
const unmasked = Mask.getValueWithoutMask(valueToUnmask);
|
|
11005
11061
|
const masked = Mask.getValueWithMask(unmasked, mask);
|
|
11006
11062
|
return masked;
|
|
11007
11063
|
}
|
|
11008
|
-
return dayjs(value,
|
|
11064
|
+
return dayjs(value, timeValueFormat).format(timeDisplayFormat);
|
|
11009
11065
|
});
|
|
11010
|
-
FormatterParserProvider.registerParser('ZdTime', (value, { displayFormat = Config.displayTimeFormat, valueFormat = Config.valueTimeFormat, mask = '', initialMask, } = {}) => {
|
|
11066
|
+
FormatterParserProvider.registerParser('ZdTime', (value, { displayFormat = Config.displayTimeFormat, valueFormat = Config.valueTimeFormat, timeFormat = Config.timeFormat || 'ampm', useSeconds = false, mask = '', initialMask, } = {}) => {
|
|
11011
11067
|
if (!value) {
|
|
11012
11068
|
return null;
|
|
11013
11069
|
}
|
|
11014
|
-
|
|
11015
|
-
|
|
11070
|
+
const timeFormatSelector = new TimeFormatSelector();
|
|
11071
|
+
const timeDisplayFormat = timeFormatSelector.getFormat(displayFormat, timeFormat, useSeconds);
|
|
11072
|
+
const timeValueFormat = timeFormatSelector.getFormat(valueFormat, '24hr', useSeconds);
|
|
11073
|
+
if (dayjs(value, timeDisplayFormat, true).isValid()) {
|
|
11074
|
+
return dayjs(value, timeDisplayFormat).format(timeValueFormat);
|
|
11016
11075
|
}
|
|
11017
11076
|
if (mask && Mask.checkMask(value, mask)) {
|
|
11018
11077
|
const unmasked = Mask.getValueWithoutMask(value);
|
|
11019
11078
|
let masked;
|
|
11020
11079
|
if (!initialMask) {
|
|
11021
|
-
const displayFmtMask =
|
|
11080
|
+
const displayFmtMask = timeDisplayFormat.replace(/[A-Za-z]/gi, '#');
|
|
11022
11081
|
masked = Mask.getValueWithMask(unmasked, displayFmtMask);
|
|
11023
11082
|
}
|
|
11024
|
-
const timeFmtMask =
|
|
11083
|
+
const timeFmtMask = timeValueFormat.replace(/[A-Za-z]/gi, '#');
|
|
11025
11084
|
masked = Mask.getValueWithMask(unmasked, timeFmtMask);
|
|
11026
|
-
if (dayjs(masked,
|
|
11085
|
+
if (dayjs(masked, timeValueFormat, true).format(timeValueFormat) === masked) {
|
|
11027
11086
|
return masked;
|
|
11028
11087
|
}
|
|
11029
11088
|
}
|
package/dist/zd-common.umd.js
CHANGED
|
@@ -9992,8 +9992,9 @@
|
|
|
9992
9992
|
}
|
|
9993
9993
|
setValue(value) {
|
|
9994
9994
|
let val = value;
|
|
9995
|
+
const key = this.datasource ? this.dataValue : 'id';
|
|
9995
9996
|
if (typeof value === 'object' && !Array.isArray(value) && value !== null) {
|
|
9996
|
-
val = value[
|
|
9997
|
+
val = value[key];
|
|
9997
9998
|
}
|
|
9998
9999
|
else if (!value && value !== 0) {
|
|
9999
10000
|
val = null;
|
|
@@ -10049,9 +10050,14 @@
|
|
|
10049
10050
|
* Changes the behavior of checked nodes that will be displayed in the array of values
|
|
10050
10051
|
*/
|
|
10051
10052
|
this.valueConsistsOf = 'LEAF_PRIORITY';
|
|
10053
|
+
/**
|
|
10054
|
+
* Show the selectAll option
|
|
10055
|
+
*/
|
|
10056
|
+
this.showSelectAll = false;
|
|
10052
10057
|
this.flat = this.getInitValue('flat', props.flat, this.flat);
|
|
10053
10058
|
this.limit = this.getInitValue('limit', props.limit, this.limit);
|
|
10054
10059
|
this.valueConsistsOf = this.getInitValue('valueConsistsOf', props.valueConsistsOf, this.valueConsistsOf);
|
|
10060
|
+
this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
|
|
10055
10061
|
this.createAccessors();
|
|
10056
10062
|
}
|
|
10057
10063
|
/**
|
|
@@ -10077,22 +10083,56 @@
|
|
|
10077
10083
|
}
|
|
10078
10084
|
setValue(value) {
|
|
10079
10085
|
const arrValue = Array.isArray(value) ? value : [value];
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
if (typeof item !== 'object') {
|
|
10083
|
-
return { id: item };
|
|
10084
|
-
}
|
|
10085
|
-
return { id: item[this.dataValue] };
|
|
10086
|
-
});
|
|
10087
|
-
}
|
|
10088
|
-
else {
|
|
10086
|
+
const key = this.datasource ? this.dataValue : 'id';
|
|
10087
|
+
if (!this.returnObject) {
|
|
10089
10088
|
this.value = arrValue.map((item) => {
|
|
10090
10089
|
if (typeof item === 'object') {
|
|
10091
|
-
return item[
|
|
10090
|
+
return item[key];
|
|
10092
10091
|
}
|
|
10093
10092
|
return item;
|
|
10094
10093
|
});
|
|
10094
|
+
return;
|
|
10095
10095
|
}
|
|
10096
|
+
this.value = arrValue.map((item) => {
|
|
10097
|
+
if (typeof item !== 'object') {
|
|
10098
|
+
return { id: item };
|
|
10099
|
+
}
|
|
10100
|
+
return { id: item[key] };
|
|
10101
|
+
});
|
|
10102
|
+
}
|
|
10103
|
+
getAllNodes(nodes = this.nodes) {
|
|
10104
|
+
let result = nodes;
|
|
10105
|
+
nodes.forEach((node) => {
|
|
10106
|
+
if (!node.children)
|
|
10107
|
+
return;
|
|
10108
|
+
const childNodes = this.getAllNodes(node.children);
|
|
10109
|
+
result = [...result, ...childNodes];
|
|
10110
|
+
});
|
|
10111
|
+
return result;
|
|
10112
|
+
}
|
|
10113
|
+
/**
|
|
10114
|
+
* Dispatches select/unselect event
|
|
10115
|
+
*/
|
|
10116
|
+
onSelectAll(isSelected, event, element) {
|
|
10117
|
+
if (isSelected) {
|
|
10118
|
+
this.callEvent('selectedAll', { event, element, component: this });
|
|
10119
|
+
if (!event.defaultPrevented) {
|
|
10120
|
+
this.selectAllItems();
|
|
10121
|
+
}
|
|
10122
|
+
}
|
|
10123
|
+
else {
|
|
10124
|
+
this.callEvent('unselectedAll', { event, element, component: this });
|
|
10125
|
+
if (!event.defaultPrevented) {
|
|
10126
|
+
this.unSelectAllItems();
|
|
10127
|
+
}
|
|
10128
|
+
}
|
|
10129
|
+
}
|
|
10130
|
+
selectAllItems() {
|
|
10131
|
+
const allNodes = this.datasource ? this.datasource.data : this.getAllNodes();
|
|
10132
|
+
this.setValue(allNodes);
|
|
10133
|
+
}
|
|
10134
|
+
unSelectAllItems() {
|
|
10135
|
+
this.setValue([]);
|
|
10096
10136
|
}
|
|
10097
10137
|
}
|
|
10098
10138
|
|
|
@@ -10667,6 +10707,27 @@
|
|
|
10667
10707
|
}
|
|
10668
10708
|
}
|
|
10669
10709
|
|
|
10710
|
+
/**
|
|
10711
|
+
* Selects the time format by the rule:
|
|
10712
|
+
* non-common format > common format
|
|
10713
|
+
* and if the format is a common format, it will be overriden by timeFormat
|
|
10714
|
+
*/
|
|
10715
|
+
class TimeFormatSelector {
|
|
10716
|
+
getFormat(format, timeFormat, useSeconds) {
|
|
10717
|
+
const commonsDisplay = ['hh:mm A', 'hh:mm:ss A', 'HH:mm:ss', 'HH:mm'];
|
|
10718
|
+
const seconds = useSeconds ? ':ss' : '';
|
|
10719
|
+
const defaultFormats = {
|
|
10720
|
+
ampm: `hh:mm${seconds} A`,
|
|
10721
|
+
'24hr': `HH:mm${seconds}`,
|
|
10722
|
+
};
|
|
10723
|
+
const timeFormats = ['ampm', '24hr'];
|
|
10724
|
+
if (commonsDisplay.includes(format) && timeFormats.includes(timeFormat)) {
|
|
10725
|
+
return defaultFormats[timeFormat];
|
|
10726
|
+
}
|
|
10727
|
+
return format;
|
|
10728
|
+
}
|
|
10729
|
+
}
|
|
10730
|
+
|
|
10670
10731
|
/**
|
|
10671
10732
|
* Base class for Time Picker component.
|
|
10672
10733
|
*/
|
|
@@ -10755,21 +10816,20 @@
|
|
|
10755
10816
|
this.initialMask = this.getInitialMask();
|
|
10756
10817
|
this.isSimpleDisplay = this.isSimpleFormat(this.displayFormat);
|
|
10757
10818
|
}
|
|
10819
|
+
getFormat(format, timeFormat) {
|
|
10820
|
+
const timeFormatSelector = new TimeFormatSelector();
|
|
10821
|
+
const selectedFormat = timeFormatSelector.getFormat(format, timeFormat, this.useSeconds);
|
|
10822
|
+
return selectedFormat;
|
|
10823
|
+
}
|
|
10758
10824
|
get displayFormat() {
|
|
10759
|
-
|
|
10760
|
-
if (commonsDisplay.includes(this.displayFormatInternal)) {
|
|
10761
|
-
this.displayFormatInternal = this.defaultFormats[this.timeFormat];
|
|
10762
|
-
}
|
|
10825
|
+
this.displayFormatInternal = this.getFormat(this.displayFormatInternal, this.timeFormat);
|
|
10763
10826
|
return this.displayFormatInternal;
|
|
10764
10827
|
}
|
|
10765
10828
|
set displayFormat(value) {
|
|
10766
10829
|
this.displayFormatInternal = value;
|
|
10767
10830
|
}
|
|
10768
10831
|
get valueFormat() {
|
|
10769
|
-
|
|
10770
|
-
if (commonsDisplay.includes(this.valueFormatInternal)) {
|
|
10771
|
-
this.valueFormatInternal = this.defaultFormats['24hr'];
|
|
10772
|
-
}
|
|
10832
|
+
this.valueFormatInternal = this.getFormat(this.valueFormatInternal, '24hr');
|
|
10773
10833
|
return this.valueFormatInternal;
|
|
10774
10834
|
}
|
|
10775
10835
|
set valueFormat(value) {
|
|
@@ -10779,13 +10839,6 @@
|
|
|
10779
10839
|
this.isoFormatValue = this.useSeconds ? 'HH:mm:ss' : 'HH:mm';
|
|
10780
10840
|
return this.isoFormatValue;
|
|
10781
10841
|
}
|
|
10782
|
-
get defaultFormats() {
|
|
10783
|
-
const seconds = this.useSeconds ? ':ss' : '';
|
|
10784
|
-
return {
|
|
10785
|
-
ampm: `hh:mm${seconds} A`,
|
|
10786
|
-
'24hr': `HH:mm${seconds}`,
|
|
10787
|
-
};
|
|
10788
|
-
}
|
|
10789
10842
|
getInitialMask() {
|
|
10790
10843
|
if (isUndefined__default["default"](this.mask)) {
|
|
10791
10844
|
this.mask = this.inputFormat && this.maskFormat(this.inputFormat);
|
|
@@ -10992,45 +11045,51 @@
|
|
|
10992
11045
|
this.change(this.value);
|
|
10993
11046
|
}
|
|
10994
11047
|
}
|
|
10995
|
-
core.FormatterParserProvider.registerFormatter('ZdTime', (value, { valueFormat = core.Config.valueTimeFormat, displayFormat = core.Config.displayTimeFormat, inputFormat = core.Config.timeInputFormat, mask = '', initialMask, isSimpleDisplay = false, } = {}) => {
|
|
11048
|
+
core.FormatterParserProvider.registerFormatter('ZdTime', (value, { valueFormat = core.Config.valueTimeFormat, displayFormat = core.Config.displayTimeFormat, inputFormat = core.Config.timeInputFormat, timeFormat = core.Config.timeFormat || 'ampm', useSeconds = false, mask = '', initialMask, isSimpleDisplay = false, } = {}) => {
|
|
10996
11049
|
if (!value) {
|
|
10997
11050
|
return '';
|
|
10998
11051
|
}
|
|
10999
|
-
const
|
|
11052
|
+
const timeFormatSelector = new TimeFormatSelector();
|
|
11053
|
+
const timeDisplayFormat = timeFormatSelector.getFormat(displayFormat, timeFormat, useSeconds);
|
|
11054
|
+
const timeValueFormat = timeFormatSelector.getFormat(valueFormat, '24hr', useSeconds);
|
|
11055
|
+
const isTimeValid = core.dayjs(value, timeValueFormat, true).isValid();
|
|
11000
11056
|
if (!isTimeValid) {
|
|
11001
11057
|
return value;
|
|
11002
11058
|
}
|
|
11003
11059
|
if (mask && initialMask) {
|
|
11004
11060
|
if (inputFormat) {
|
|
11005
|
-
return core.dayjs(value,
|
|
11061
|
+
return core.dayjs(value, timeValueFormat).format(inputFormat);
|
|
11006
11062
|
}
|
|
11007
11063
|
let valueToUnmask = value;
|
|
11008
11064
|
if (isSimpleDisplay) {
|
|
11009
|
-
valueToUnmask = core.dayjs(value,
|
|
11065
|
+
valueToUnmask = core.dayjs(value, timeValueFormat).format(timeDisplayFormat);
|
|
11010
11066
|
}
|
|
11011
11067
|
const unmasked = core.Mask.getValueWithoutMask(valueToUnmask);
|
|
11012
11068
|
const masked = core.Mask.getValueWithMask(unmasked, mask);
|
|
11013
11069
|
return masked;
|
|
11014
11070
|
}
|
|
11015
|
-
return core.dayjs(value,
|
|
11071
|
+
return core.dayjs(value, timeValueFormat).format(timeDisplayFormat);
|
|
11016
11072
|
});
|
|
11017
|
-
core.FormatterParserProvider.registerParser('ZdTime', (value, { displayFormat = core.Config.displayTimeFormat, valueFormat = core.Config.valueTimeFormat, mask = '', initialMask, } = {}) => {
|
|
11073
|
+
core.FormatterParserProvider.registerParser('ZdTime', (value, { displayFormat = core.Config.displayTimeFormat, valueFormat = core.Config.valueTimeFormat, timeFormat = core.Config.timeFormat || 'ampm', useSeconds = false, mask = '', initialMask, } = {}) => {
|
|
11018
11074
|
if (!value) {
|
|
11019
11075
|
return null;
|
|
11020
11076
|
}
|
|
11021
|
-
|
|
11022
|
-
|
|
11077
|
+
const timeFormatSelector = new TimeFormatSelector();
|
|
11078
|
+
const timeDisplayFormat = timeFormatSelector.getFormat(displayFormat, timeFormat, useSeconds);
|
|
11079
|
+
const timeValueFormat = timeFormatSelector.getFormat(valueFormat, '24hr', useSeconds);
|
|
11080
|
+
if (core.dayjs(value, timeDisplayFormat, true).isValid()) {
|
|
11081
|
+
return core.dayjs(value, timeDisplayFormat).format(timeValueFormat);
|
|
11023
11082
|
}
|
|
11024
11083
|
if (mask && core.Mask.checkMask(value, mask)) {
|
|
11025
11084
|
const unmasked = core.Mask.getValueWithoutMask(value);
|
|
11026
11085
|
let masked;
|
|
11027
11086
|
if (!initialMask) {
|
|
11028
|
-
const displayFmtMask =
|
|
11087
|
+
const displayFmtMask = timeDisplayFormat.replace(/[A-Za-z]/gi, '#');
|
|
11029
11088
|
masked = core.Mask.getValueWithMask(unmasked, displayFmtMask);
|
|
11030
11089
|
}
|
|
11031
|
-
const timeFmtMask =
|
|
11090
|
+
const timeFmtMask = timeValueFormat.replace(/[A-Za-z]/gi, '#');
|
|
11032
11091
|
masked = core.Mask.getValueWithMask(unmasked, timeFmtMask);
|
|
11033
|
-
if (core.dayjs(masked,
|
|
11092
|
+
if (core.dayjs(masked, timeValueFormat, true).format(timeValueFormat) === masked) {
|
|
11034
11093
|
return masked;
|
|
11035
11094
|
}
|
|
11036
11095
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.70.0",
|
|
4
4
|
"description": "Zeedhi Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"lodash.times": "^4.3.2",
|
|
40
40
|
"mockdate": "^3.0.2"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "5d3e8cfdd580a87208edf3d4033e2a974161fd1a"
|
|
43
43
|
}
|
|
@@ -13,6 +13,7 @@ export interface ISelectTreeMultiple extends ISelectTree {
|
|
|
13
13
|
limit?: number;
|
|
14
14
|
events?: ISelectTreeMultipleEvents;
|
|
15
15
|
valueConsistsOf?: string;
|
|
16
|
+
showSelectAll?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export interface ISelectTreeMultipleSelectedNodesEvent extends IEventParam<SelectTreeMultiple> {
|
|
18
19
|
selectedNodes: ISelectTreeMultipleNode<IDictionary>[];
|
|
@@ -23,4 +24,6 @@ export interface ISelectTreeMultipleDeselectEvent extends IEventParam<SelectTree
|
|
|
23
24
|
export interface ISelectTreeMultipleEvents extends ISelectTreeEvents {
|
|
24
25
|
onChangeSelectedNodes?: IEvent<ISelectTreeMultipleSelectedNodesEvent> | string;
|
|
25
26
|
onDeselect?: IEvent<ISelectTreeMultipleDeselectEvent> | string;
|
|
27
|
+
selectedAll?: IEvent<IEventParam<any>> | string;
|
|
28
|
+
unselectedAll?: IEvent<IEventParam<any>> | string;
|
|
26
29
|
}
|
|
@@ -26,6 +26,10 @@ export declare class SelectTreeMultiple extends SelectTree implements ISelectTre
|
|
|
26
26
|
* Changes the behavior of checked nodes that will be displayed in the array of values
|
|
27
27
|
*/
|
|
28
28
|
valueConsistsOf: string;
|
|
29
|
+
/**
|
|
30
|
+
* Show the selectAll option
|
|
31
|
+
*/
|
|
32
|
+
showSelectAll: boolean;
|
|
29
33
|
/**
|
|
30
34
|
* Creates a new instance of Select Tree Multiple
|
|
31
35
|
* @param props
|
|
@@ -42,4 +46,11 @@ export declare class SelectTreeMultiple extends SelectTree implements ISelectTre
|
|
|
42
46
|
get value(): any;
|
|
43
47
|
set value(value: any);
|
|
44
48
|
setValue(value: any): void;
|
|
49
|
+
getAllNodes(nodes?: import("..").ISelectTreeNode<IDictionary<any>>[]): import("..").ISelectTreeNode<IDictionary<any>>[];
|
|
50
|
+
/**
|
|
51
|
+
* Dispatches select/unselect event
|
|
52
|
+
*/
|
|
53
|
+
onSelectAll(isSelected: boolean, event: Event, element: any): void;
|
|
54
|
+
selectAllItems(): void;
|
|
55
|
+
unSelectAllItems(): void;
|
|
45
56
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Selects the time format by the rule:
|
|
3
|
+
* non-common format > common format
|
|
4
|
+
* and if the format is a common format, it will be overriden by timeFormat
|
|
5
|
+
*/
|
|
6
|
+
export declare class TimeFormatSelector {
|
|
7
|
+
getFormat(format: string, timeFormat: string, useSeconds: boolean): any;
|
|
8
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IDictionary } from '@zeedhi/core';
|
|
2
1
|
import { ITime } from './interfaces';
|
|
3
2
|
import { TextInput } from '../zd-text-input/text-input';
|
|
4
3
|
/**
|
|
@@ -78,12 +77,12 @@ export declare class Time extends TextInput implements ITime {
|
|
|
78
77
|
* @param props Time properties
|
|
79
78
|
*/
|
|
80
79
|
constructor(props: ITime);
|
|
80
|
+
private getFormat;
|
|
81
81
|
get displayFormat(): string;
|
|
82
82
|
set displayFormat(value: string);
|
|
83
83
|
get valueFormat(): string;
|
|
84
84
|
set valueFormat(value: string);
|
|
85
85
|
private get isoFormat();
|
|
86
|
-
protected get defaultFormats(): IDictionary<string>;
|
|
87
86
|
private getInitialMask;
|
|
88
87
|
formatter(value: string): string;
|
|
89
88
|
parser(value: string): any;
|