@talxis/base-controls 1.2406.13 → 1.2406.15
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/Lookup-85a4c52d.js +1 -3413
- package/dist/Numeral-a0284afb.js +1 -63
- package/dist/components/DateTime/DateTime.js +1 -302
- package/dist/components/Decimal/Decimal.js +1 -167
- package/dist/components/Duration/Duration.js +1 -180
- package/dist/components/Grid/Grid.js +2 -74619
- package/dist/components/Lookup/Lookup.js +1 -14
- package/dist/components/MultiSelectOptionSet/MultiSelectOptionSet.js +1 -72
- package/dist/components/OptionSet/OptionSet.js +1 -59
- package/dist/components/TextField/TextField.js +1 -86
- package/dist/components/TwoOptions/TwoOptions.js +1 -40
- package/dist/hooks/index.js +1 -6
- package/dist/hooks/useComponent.js +1 -83
- package/dist/hooks/useComponentSizing.js +1 -14
- package/dist/hooks/useFocusIn.js +1 -24
- package/dist/hooks/useInputBasedComponent.js +1 -42
- package/dist/hooks/useMouseOver.js +1 -24
- package/package.json +1 -1
|
@@ -1,180 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ComboBox } from '@talxis/react-components/dist/components/ComboBox';
|
|
3
|
-
import { useInputBasedComponent } from '../../hooks/useInputBasedComponent.js';
|
|
4
|
-
import numeral from 'numeral';
|
|
5
|
-
import { N as Numeral } from '../../Numeral-a0284afb.js';
|
|
6
|
-
import 'react';
|
|
7
|
-
import '../../hooks/useComponent.js';
|
|
8
|
-
import 'fast-deep-equal/es6';
|
|
9
|
-
import 'merge-anything';
|
|
10
|
-
import 'liquidjs';
|
|
11
|
-
import '../../hooks/useComponentSizing.js';
|
|
12
|
-
|
|
13
|
-
const durationOptions = [
|
|
14
|
-
{ Label: '1', Value: 1, Color: '' },
|
|
15
|
-
{ Label: '15', Value: 2, Color: '' },
|
|
16
|
-
{ Label: '30', Value: 3, Color: '' },
|
|
17
|
-
{ Label: '45', Value: 4, Color: '' },
|
|
18
|
-
{ Label: '60', Value: 5, Color: '' },
|
|
19
|
-
{ Label: '90', Value: 6, Color: '' },
|
|
20
|
-
{ Label: '120', Value: 7, Color: '' },
|
|
21
|
-
{ Label: '150', Value: 8, Color: '' },
|
|
22
|
-
{ Label: '180', Value: 9, Color: '' },
|
|
23
|
-
{ Label: '210', Value: 10, Color: '' },
|
|
24
|
-
{ Label: '240', Value: 11, Color: '' },
|
|
25
|
-
{ Label: '270', Value: 12, Color: '' },
|
|
26
|
-
{ Label: '300', Value: 13, Color: '' },
|
|
27
|
-
{ Label: '330', Value: 14, Color: '' },
|
|
28
|
-
{ Label: '360', Value: 15, Color: '' },
|
|
29
|
-
{ Label: '390', Value: 16, Color: '' },
|
|
30
|
-
{ Label: '420', Value: 17, Color: '' },
|
|
31
|
-
{ Label: '450', Value: 18, Color: '' },
|
|
32
|
-
{ Label: '480', Value: 19, Color: '' },
|
|
33
|
-
{ Label: '1440', Value: 20, Color: '' },
|
|
34
|
-
{ Label: '2880', Value: 21, Color: '' },
|
|
35
|
-
{ Label: '4320', Value: 22, Color: '' },
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
const getDefaultDurationTranslations = () => {
|
|
39
|
-
return {
|
|
40
|
-
minute: {
|
|
41
|
-
1029: ['min', 'minuta', 'minuty', 'minute', 'minutu', 'minutě', 'minutou', 'minuta', 'minuty', 'minute', 'minutu', 'minute', 'minutou'],
|
|
42
|
-
1033: ['min', 'minute']
|
|
43
|
-
},
|
|
44
|
-
minutes: {
|
|
45
|
-
1029: ['minuty', 'minut', 'minutám', 'minutách', 'minutami', 'minuty', 'minut', 'minutam', 'minutach', 'minutami'],
|
|
46
|
-
1033: ['minutes']
|
|
47
|
-
},
|
|
48
|
-
hour: {
|
|
49
|
-
1029: ['hod', 'hodina', 'hodiny', 'hodině', 'hodinu', 'hodinou', 'hodina', 'hodiny', 'hodine', 'hodinu', 'hodinou'],
|
|
50
|
-
1033: ['hour']
|
|
51
|
-
},
|
|
52
|
-
hours: {
|
|
53
|
-
1029: ['hodiny', 'hodin', 'hodinám', 'hodinách', 'hodinami', 'hodiny', 'hodin', 'hodinam', 'hodinach', 'hodinami'],
|
|
54
|
-
1033: ['hours']
|
|
55
|
-
},
|
|
56
|
-
day: {
|
|
57
|
-
1029: ['den', 'dne', 'dni', 'dnu', 'dnem', 'den', 'dne', 'dni', 'dnu', 'dnem'],
|
|
58
|
-
1033: ['day']
|
|
59
|
-
},
|
|
60
|
-
days: {
|
|
61
|
-
1029: ['dny', 'dnů', 'dnům', 'dnech', 'dny', 'dní', 'dny', 'dnu', 'dnom', 'dnech', 'dny', 'dni'],
|
|
62
|
-
1033: ['days']
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const Duration = (props) => {
|
|
68
|
-
var _a, _b;
|
|
69
|
-
const parameters = props.parameters;
|
|
70
|
-
const boundValue = parameters.value;
|
|
71
|
-
const context = props.context;
|
|
72
|
-
const humanizeDuration = require("humanize-duration");
|
|
73
|
-
const formattingInfo = context.userSettings;
|
|
74
|
-
const language = formattingInfo.locale;
|
|
75
|
-
const numberFormatting = context.userSettings.numberFormattingInfo;
|
|
76
|
-
const formatter = (value) => {
|
|
77
|
-
//all duration formatting should happen here
|
|
78
|
-
if (value === null)
|
|
79
|
-
return null;
|
|
80
|
-
const durationInMilliseconds = value * 60000;
|
|
81
|
-
const units = value < 60 ? ['m'] : value >= 1440 ? ['d'] : ['h'];
|
|
82
|
-
const options = {
|
|
83
|
-
units: units,
|
|
84
|
-
maxDecimalPoints: 2,
|
|
85
|
-
language: language.slice(0, language.indexOf("-")),
|
|
86
|
-
decimal: context.userSettings.numberFormattingInfo.numberDecimalSeparator,
|
|
87
|
-
fallbacks: ["en"]
|
|
88
|
-
};
|
|
89
|
-
return humanizeDuration(durationInMilliseconds, options);
|
|
90
|
-
};
|
|
91
|
-
const valueExtractor = (str) => {
|
|
92
|
-
//extraction of number of minutes from formatted string should happen here
|
|
93
|
-
// parsing because labels are string that represent array of strings
|
|
94
|
-
const minuteLabels = JSON.parse(labels.minute());
|
|
95
|
-
const minutesLabels = JSON.parse(labels.minutes());
|
|
96
|
-
const hourLabels = JSON.parse(labels.hour());
|
|
97
|
-
const hoursLabels = JSON.parse(labels.hours());
|
|
98
|
-
const dayLabels = JSON.parse(labels.day());
|
|
99
|
-
const daysLabels = JSON.parse(labels.days());
|
|
100
|
-
const minuteRegex = new RegExp("^(" + minuteLabels.join('|') + ")\\s|\\s(" + minuteLabels.join('|') + ")$|^(" + minutesLabels.join('|') + ")\\s|\\s(" + minutesLabels.join('|') + ")$", "i");
|
|
101
|
-
const hourRegex = new RegExp("^(" + hourLabels.join('|') + ")\\s|\\s(" + hourLabels.join('|') + ")$|^(" + hoursLabels.join('|') + ")\\s|\\s(" + hoursLabels.join('|') + ")$", "i");
|
|
102
|
-
const dayRegex = new RegExp("^(" + dayLabels.join('|') + ")\\s|\\s(" + dayLabels.join('|') + ")$|^(" + daysLabels.join('|') + ")\\s|\\s(" + daysLabels.join('|') + ")$", "i");
|
|
103
|
-
if (str && str.trim()) {
|
|
104
|
-
let input = str.trim().toLowerCase();
|
|
105
|
-
let unit = 'minute';
|
|
106
|
-
if (minuteRegex.test(input)) {
|
|
107
|
-
input = input.replace(minuteRegex, "").trim();
|
|
108
|
-
}
|
|
109
|
-
else if (hourRegex.test(input)) {
|
|
110
|
-
input = input.replace(hourRegex, "").trim();
|
|
111
|
-
unit = 'hour';
|
|
112
|
-
}
|
|
113
|
-
else if (dayRegex.test(input)) {
|
|
114
|
-
input = input.replace(dayRegex, "").trim();
|
|
115
|
-
unit = 'day';
|
|
116
|
-
}
|
|
117
|
-
const parsedNumber = parseNumber(input);
|
|
118
|
-
if (parsedNumber && !isNaN(parsedNumber)) {
|
|
119
|
-
return getDurationInMinutes(parsedNumber, unit);
|
|
120
|
-
}
|
|
121
|
-
return NaN;
|
|
122
|
-
}
|
|
123
|
-
return undefined;
|
|
124
|
-
};
|
|
125
|
-
const parseNumber = (input) => {
|
|
126
|
-
var _a;
|
|
127
|
-
Numeral.decimal(numberFormatting);
|
|
128
|
-
return (_a = numeral(input).value()) !== null && _a !== void 0 ? _a : undefined;
|
|
129
|
-
};
|
|
130
|
-
const getDurationInMinutes = (value, unit) => {
|
|
131
|
-
switch (unit) {
|
|
132
|
-
case 'hour':
|
|
133
|
-
return 60 * value;
|
|
134
|
-
case 'day':
|
|
135
|
-
return 60 * value * 24;
|
|
136
|
-
case 'minute':
|
|
137
|
-
default:
|
|
138
|
-
return value;
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
const presetOptions = () => {
|
|
142
|
-
const formattedOptions = durationOptions.map(option => ({
|
|
143
|
-
key: option.Value.toString(),
|
|
144
|
-
text: formatter(parseInt(option.Label)),
|
|
145
|
-
}));
|
|
146
|
-
return formattedOptions;
|
|
147
|
-
};
|
|
148
|
-
const comboBoxOptions = presetOptions();
|
|
149
|
-
const { value, labels, sizing, setValue, onNotifyOutputChanged } = useInputBasedComponent('Duration', props, {
|
|
150
|
-
formatter: formatter,
|
|
151
|
-
valueExtractor: valueExtractor,
|
|
152
|
-
defaultTranslations: getDefaultDurationTranslations(),
|
|
153
|
-
});
|
|
154
|
-
return (jsx(ComboBox, { borderless: ((_a = parameters.EnableBorder) === null || _a === void 0 ? void 0 : _a.raw) === false, options: comboBoxOptions, allowFreeInput: true, autoComplete: 'on', autofill: ((_b = parameters.AutoFocus) === null || _b === void 0 ? void 0 : _b.raw) === true ? {
|
|
155
|
-
autoFocus: true
|
|
156
|
-
} : undefined, readOnly: context.mode.isControlDisabled, useComboBoxAsMenuWidth: true, errorMessage: boundValue.errorMessage, text: value !== null && value !== void 0 ? value : '', styles: {
|
|
157
|
-
root: {
|
|
158
|
-
height: sizing.height,
|
|
159
|
-
width: sizing.width,
|
|
160
|
-
display: 'flex',
|
|
161
|
-
alignItems: 'center',
|
|
162
|
-
},
|
|
163
|
-
callout: {
|
|
164
|
-
height: 300
|
|
165
|
-
}
|
|
166
|
-
}, onInputValueChange: (text) => {
|
|
167
|
-
setValue(text !== null && text !== void 0 ? text : '');
|
|
168
|
-
}, onBlur: (event) => {
|
|
169
|
-
onNotifyOutputChanged({
|
|
170
|
-
value: valueExtractor(value)
|
|
171
|
-
});
|
|
172
|
-
}, onChange: (e, value) => {
|
|
173
|
-
var _a;
|
|
174
|
-
onNotifyOutputChanged({
|
|
175
|
-
value: valueExtractor((_a = value === null || value === void 0 ? void 0 : value.text) !== null && _a !== void 0 ? _a : '')
|
|
176
|
-
});
|
|
177
|
-
} }));
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export { Duration };
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{ComboBox as o}from"@talxis/react-components/dist/components/ComboBox";import{useInputBasedComponent as n}from"../../hooks/useInputBasedComponent.js";import a from"numeral";import{N as i}from"../../Numeral-a0284afb.js";import"react";import"../../hooks/useComponent.js";import"fast-deep-equal/es6";import"merge-anything";import"liquidjs";import"../../hooks/useComponentSizing.js";const t=[{Label:"1",Value:1,Color:""},{Label:"15",Value:2,Color:""},{Label:"30",Value:3,Color:""},{Label:"45",Value:4,Color:""},{Label:"60",Value:5,Color:""},{Label:"90",Value:6,Color:""},{Label:"120",Value:7,Color:""},{Label:"150",Value:8,Color:""},{Label:"180",Value:9,Color:""},{Label:"210",Value:10,Color:""},{Label:"240",Value:11,Color:""},{Label:"270",Value:12,Color:""},{Label:"300",Value:13,Color:""},{Label:"330",Value:14,Color:""},{Label:"360",Value:15,Color:""},{Label:"390",Value:16,Color:""},{Label:"420",Value:17,Color:""},{Label:"450",Value:18,Color:""},{Label:"480",Value:19,Color:""},{Label:"1440",Value:20,Color:""},{Label:"2880",Value:21,Color:""},{Label:"4320",Value:22,Color:""}],l=l=>{var u,r;const s=l.parameters,m=s.value,d=l.context,h=require("humanize-duration"),p=d.userSettings.locale,c=d.userSettings.numberFormattingInfo,b=e=>{if(null===e)return null;const o=6e4*e,n={units:e<60?["m"]:e>=1440?["d"]:["h"],maxDecimalPoints:2,language:p.slice(0,p.indexOf("-")),decimal:d.userSettings.numberFormattingInfo.numberDecimalSeparator,fallbacks:["en"]};return h(o,n)},C=e=>{const o=JSON.parse(f.minute()),n=JSON.parse(f.minutes()),a=JSON.parse(f.hour()),i=JSON.parse(f.hours()),t=JSON.parse(f.day()),l=JSON.parse(f.days()),u=new RegExp("^("+o.join("|")+")\\s|\\s("+o.join("|")+")$|^("+n.join("|")+")\\s|\\s("+n.join("|")+")$","i"),r=new RegExp("^("+a.join("|")+")\\s|\\s("+a.join("|")+")$|^("+i.join("|")+")\\s|\\s("+i.join("|")+")$","i"),s=new RegExp("^("+t.join("|")+")\\s|\\s("+t.join("|")+")$|^("+l.join("|")+")\\s|\\s("+l.join("|")+")$","i");if(e&&e.trim()){let o=e.trim().toLowerCase(),n="minute";u.test(o)?o=o.replace(u,"").trim():r.test(o)?(o=o.replace(r,"").trim(),n="hour"):s.test(o)&&(o=o.replace(s,"").trim(),n="day");const a=y(o);return a&&!isNaN(a)?V(a,n):NaN}},y=e=>{var o;return i.decimal(c),null!==(o=a(e).value())&&void 0!==o?o:void 0},V=(e,o)=>{switch(o){case"hour":return 60*e;case"day":return 60*e*24;default:return e}},g=t.map((e=>({key:e.Value.toString(),text:b(parseInt(e.Label))}))),{value:L,labels:f,sizing:j,setValue:v,onNotifyOutputChanged:x}=n("Duration",l,{formatter:b,valueExtractor:C,defaultTranslations:{minute:{1029:["min","minuta","minuty","minute","minutu","minutě","minutou","minuta","minuty","minute","minutu","minute","minutou"],1033:["min","minute"]},minutes:{1029:["minuty","minut","minutám","minutách","minutami","minuty","minut","minutam","minutach","minutami"],1033:["minutes"]},hour:{1029:["hod","hodina","hodiny","hodině","hodinu","hodinou","hodina","hodiny","hodine","hodinu","hodinou"],1033:["hour"]},hours:{1029:["hodiny","hodin","hodinám","hodinách","hodinami","hodiny","hodin","hodinam","hodinach","hodinami"],1033:["hours"]},day:{1029:["den","dne","dni","dnu","dnem","den","dne","dni","dnu","dnem"],1033:["day"]},days:{1029:["dny","dnů","dnům","dnech","dny","dní","dny","dnu","dnom","dnech","dny","dni"],1033:["days"]}}});return e(o,{borderless:!1===(null===(u=s.EnableBorder)||void 0===u?void 0:u.raw),options:g,allowFreeInput:!0,autoComplete:"on",autofill:!0===(null===(r=s.AutoFocus)||void 0===r?void 0:r.raw)?{autoFocus:!0}:void 0,readOnly:d.mode.isControlDisabled,useComboBoxAsMenuWidth:!0,errorMessage:m.errorMessage,text:null!=L?L:"",styles:{root:{height:j.height,width:j.width,display:"flex",alignItems:"center"},callout:{height:300}},onInputValueChange:e=>{v(null!=e?e:"")},onBlur:e=>{x({value:C(L)})},onChange:(e,o)=>{var n;x({value:C(null!==(n=null==o?void 0:o.text)&&void 0!==n?n:"")})}})};export{l as Duration};
|