@pie-lib/config-ui 10.10.4-next.286 → 10.10.4-next.295
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/lib/alert-dialog.js.map +1 -1
- package/lib/checkbox.js.map +1 -1
- package/lib/choice-configuration/feedback-menu.js.map +1 -1
- package/lib/choice-configuration/index.js.map +1 -1
- package/lib/choice-utils.js.map +1 -1
- package/lib/feedback-config/feedback-selector.js.map +1 -1
- package/lib/feedback-config/group.js.map +1 -1
- package/lib/feedback-config/index.js.map +1 -1
- package/lib/form-section.js.map +1 -1
- package/lib/help.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/input.js.map +1 -1
- package/lib/inputs.js.map +1 -1
- package/lib/langs.js.map +1 -1
- package/lib/layout/config-layout.js.map +1 -1
- package/lib/layout/index.js.map +1 -1
- package/lib/layout/layout-contents.js.map +1 -1
- package/lib/layout/settings-box.js.map +1 -1
- package/lib/mui-box/index.js.map +1 -1
- package/lib/number-text-field-custom.js +105 -35
- package/lib/number-text-field-custom.js.map +1 -1
- package/lib/number-text-field.js.map +1 -1
- package/lib/radio-with-label.js.map +1 -1
- package/lib/settings/display-size.js.map +1 -1
- package/lib/settings/index.js.map +1 -1
- package/lib/settings/panel.js.map +1 -1
- package/lib/settings/settings-radio-label.js.map +1 -1
- package/lib/settings/toggle.js.map +1 -1
- package/lib/tabs/index.js.map +1 -1
- package/lib/tags-input/index.js.map +1 -1
- package/lib/two-choice.js.map +1 -1
- package/lib/with-stateful-model.js.map +1 -1
- package/package.json +2 -2
- package/src/number-text-field-custom.jsx +83 -17
package/lib/two-choice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"two-choice.js","names":["styles","theme","group","display","flexWrap","paddingLeft","marginTop","spacing","unit","vertical","flexDirection","RawNChoice","event","props","onChange","currentTarget","value","header","className","classes","customLabel","opts","direction","preppedOpts","map","o","label","LabelComponent","RadioWithLabel","classNames","index","handleChange","React","Component","PropTypes","string","isRequired","func","array","oneOf","object","NChoice","withStyles","labelValue","shape","TwoChoice","one","two","oneOfType"],"sources":["../src/two-choice.jsx"],"sourcesContent":["import { InputContainer } from '@pie-lib/render-ui';\nimport PropTypes from 'prop-types';\nimport RadioWithLabel from './radio-with-label';\nimport React from 'react';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\n\nconst styles = theme => ({\n group: {\n display: 'flex',\n flexWrap: 'wrap',\n paddingLeft: 0,\n marginTop: theme.spacing.unit\n },\n vertical: {\n flexDirection: 'column'\n }\n});\n\nclass RawNChoice extends React.Component {\n static propTypes = {\n header: PropTypes.string.isRequired,\n className: PropTypes.string,\n customLabel: PropTypes.func,\n opts: PropTypes.array.isRequired,\n value: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n direction: PropTypes.oneOf(['horizontal', 'vertical']),\n classes: PropTypes.object.isRequired\n };\n\n handleChange = event => {\n this.props.onChange(event.currentTarget.value);\n };\n\n render() {\n const { header, className, classes, customLabel, opts, value, direction } = this.props;\n\n const preppedOpts = opts.map(o => {\n return typeof o === 'string' ? { label: o, value: o } : o;\n });\n const LabelComponent = customLabel || RadioWithLabel;\n\n return (\n <InputContainer label={header} className={className}>\n <div className={classNames(classes.group, classes[direction])}>\n {preppedOpts.map((o, index) => (\n <LabelComponent\n value={o.value}\n key={index}\n checked={o.value === value}\n onChange={this.handleChange}\n label={o.label}\n />\n ))}\n </div>\n </InputContainer>\n );\n }\n}\n\nexport const NChoice = withStyles(styles)(RawNChoice);\n\nconst labelValue = PropTypes.shape({ label: PropTypes.string, value: PropTypes.string });\n\nclass TwoChoice extends React.Component {\n static propTypes = {\n header: PropTypes.string.isRequired,\n value: PropTypes.string.isRequired,\n onChange: PropTypes.func.isRequired,\n one: PropTypes.oneOfType([labelValue, PropTypes.string]),\n two: PropTypes.oneOfType([labelValue, PropTypes.string]),\n className: PropTypes.string,\n customLabel: PropTypes.func\n };\n\n render() {\n const { one, two, header, className, customLabel, value, onChange } = this.props;\n const opts = [one, two];\n\n return (\n <NChoice\n customLabel={customLabel}\n header={header}\n className={className}\n opts={opts}\n value={value}\n onChange={onChange}\n />\n );\n }\n}\n\nexport default withStyles(styles)(TwoChoice);\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACvBC,KAAK,EAAE;MACLC,OAAO,EAAE,MADJ;MAELC,QAAQ,EAAE,MAFL;MAGLC,WAAW,EAAE,CAHR;MAILC,SAAS,EAAEL,KAAK,CAACM,OAAN,CAAcC;IAJpB,CADgB;IAOvBC,QAAQ,EAAE;MACRC,aAAa,EAAE;IADP;EAPa,CAAL;AAAA,CAApB;;IAYMC,U;;;;;;;;;;;;;;;;mEAYW,UAAAC,KAAK,EAAI;MACtB,MAAKC,KAAL,CAAWC,QAAX,CAAoBF,KAAK,CAACG,aAAN,CAAoBC,KAAxC;IACD,C;;;;;;;WAED,kBAAS;MAAA;;MACP,kBAA4E,KAAKH,KAAjF;MAAA,IAAQI,MAAR,eAAQA,MAAR;MAAA,IAAgBC,SAAhB,eAAgBA,SAAhB;MAAA,IAA2BC,OAA3B,eAA2BA,OAA3B;MAAA,IAAoCC,WAApC,eAAoCA,WAApC;MAAA,IAAiDC,IAAjD,eAAiDA,IAAjD;MAAA,IAAuDL,KAAvD,eAAuDA,KAAvD;MAAA,IAA8DM,SAA9D,eAA8DA,SAA9D;MAEA,IAAMC,WAAW,GAAGF,IAAI,CAACG,GAAL,CAAS,UAAAC,CAAC,EAAI;QAChC,OAAO,OAAOA,CAAP,KAAa,QAAb,GAAwB;UAAEC,KAAK,EAAED,CAAT;UAAYT,KAAK,EAAES;QAAnB,CAAxB,GAAiDA,CAAxD;MACD,CAFmB,CAApB;MAGA,IAAME,cAAc,GAAGP,WAAW,IAAIQ,0BAA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.js","names":["withStatefulModel","Component","Stateful","props","model","setState","onChange","state","React","PropTypes","object","isRequired","func"],"sources":["../src/with-stateful-model.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst withStatefulModel = Component => {\n class Stateful extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired\n };\n\n constructor(props) {\n super(props);\n this.state = {\n model: props.model\n };\n }\n\n componentWillReceiveProps(props) {\n this.setState({ model: props.model });\n }\n\n onChange = model => {\n this.setState({ model }, () => {\n this.props.onChange(this.state.model);\n });\n };\n\n render() {\n return <Component model={this.state.model} onChange={this.onChange} />;\n }\n }\n\n return Stateful;\n};\n\nexport default withStatefulModel;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAAAC,SAAS,EAAI;EAAA,IAC/BC,QAD+B;IAAA;;IAAA;;IAOnC,kBAAYC,KAAZ,EAAmB;MAAA;;MAAA;;MACjB,0BAAMA,KAAN;;MADiB,2DAWR,UAAAC,KAAK,EAAI;QAClB,MAAKC,QAAL,CAAc;UAAED,KAAK,EAALA;QAAF,CAAd,EAAyB,YAAM;UAC7B,MAAKD,KAAL,CAAWG,QAAX,CAAoB,MAAKC,KAAL,CAAWH,KAA/B;QACD,CAFD;MAGD,CAfkB;;MAEjB,MAAKG,KAAL,GAAa;QACXH,KAAK,EAAED,KAAK,CAACC;MADF,CAAb;MAFiB;IAKlB;;IAZkC;MAAA;MAAA,OAcnC,mCAA0BD,KAA1B,EAAiC;QAC/B,KAAKE,QAAL,CAAc;UAAED,KAAK,EAAED,KAAK,CAACC;QAAf,CAAd;MACD;IAhBkC;MAAA;MAAA,OAwBnC,kBAAS;QACP,oBAAO,gCAAC,SAAD;UAAW,KAAK,EAAE,KAAKG,KAAL,CAAWH,KAA7B;UAAoC,QAAQ,EAAE,KAAKE;QAAnD,EAAP;MACD;IA1BkC;;IAAA;EAAA,EACdE,iBAAA,CAAMP,SADQ;;EAAA,gBAC/BC,QAD+B,eAEhB;IACjBE,KAAK,EAAEK,qBAAA,CAAUC,MAAV,CAAiBC,UADP;IAEjBL,QAAQ,EAAEG,qBAAA,CAAUG,IAAV,CAAeD;EAFR,CAFgB;;EA6BrC,OAAOT,QAAP;AACD,CA9BD;;eAgCeF,iB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/config-ui",
|
|
3
|
-
"version": "10.10.4-next.
|
|
3
|
+
"version": "10.10.4-next.295+f1c1237a",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": "^16.8.1"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "f1c1237ae254361246c15783d1e9c4b5f8256738"
|
|
30
30
|
}
|
|
@@ -46,6 +46,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
46
46
|
static propTypes = {
|
|
47
47
|
classes: PropTypes.object.isRequired,
|
|
48
48
|
className: PropTypes.string,
|
|
49
|
+
customValues: PropTypes.array,
|
|
49
50
|
disabled: PropTypes.bool,
|
|
50
51
|
error: PropTypes.bool,
|
|
51
52
|
inputClassName: PropTypes.string,
|
|
@@ -62,6 +63,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
62
63
|
|
|
63
64
|
static defaultProps = {
|
|
64
65
|
step: 1,
|
|
66
|
+
customValues: [],
|
|
65
67
|
textAlign: 'center',
|
|
66
68
|
variant: 'standard',
|
|
67
69
|
onlyIntegersAllowed: false
|
|
@@ -70,10 +72,18 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
70
72
|
constructor(props) {
|
|
71
73
|
super(props);
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
let value = this.clamp(props.value);
|
|
76
|
+
let currentIndex = (props.customValues || []).findIndex(val => val === value);
|
|
77
|
+
|
|
78
|
+
if ((props.customValues || []).length > 0 && currentIndex === -1) {
|
|
79
|
+
const closestValue = this.getClosestValue(value);
|
|
80
|
+
value = closestValue.value;
|
|
81
|
+
currentIndex = closestValue.index;
|
|
82
|
+
}
|
|
74
83
|
|
|
75
84
|
this.state = {
|
|
76
|
-
value
|
|
85
|
+
value,
|
|
86
|
+
currentIndex
|
|
77
87
|
};
|
|
78
88
|
|
|
79
89
|
if (value !== props.value) {
|
|
@@ -90,7 +100,11 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
90
100
|
}
|
|
91
101
|
|
|
92
102
|
clamp(value) {
|
|
93
|
-
const { min, max } = this.props;
|
|
103
|
+
const { min, max, customValues } = this.props;
|
|
104
|
+
|
|
105
|
+
if ((customValues || []).length > 0) {
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
94
108
|
|
|
95
109
|
if (!isFinite(value)) {
|
|
96
110
|
return fallbackNumber(min, max);
|
|
@@ -107,14 +121,37 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
107
121
|
return value;
|
|
108
122
|
}
|
|
109
123
|
|
|
124
|
+
getClosestValue = number => {
|
|
125
|
+
const { customValues } = this.props;
|
|
126
|
+
|
|
127
|
+
return customValues.reduce(
|
|
128
|
+
(closest, value, index) =>
|
|
129
|
+
Math.abs(value - number) < Math.abs(closest.value - number) ? { value, index } : closest,
|
|
130
|
+
{ value: customValues[0], index: 0 }
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
110
134
|
onBlur = event => {
|
|
111
|
-
const { onlyIntegersAllowed } = this.props;
|
|
135
|
+
const { customValues, onlyIntegersAllowed } = this.props;
|
|
112
136
|
const { value } = event.target;
|
|
113
137
|
const rawNumber = onlyIntegersAllowed ? parseInt(value) : parseFloat(value);
|
|
114
|
-
|
|
138
|
+
let number = this.clamp(rawNumber);
|
|
139
|
+
let updatedIndex = (customValues || []).findIndex(val => val === number);
|
|
140
|
+
|
|
141
|
+
if (customValues.length > 0 && updatedIndex === -1) {
|
|
142
|
+
const closestValue = this.getClosestValue(number);
|
|
143
|
+
number = closestValue.value;
|
|
144
|
+
updatedIndex = closestValue.index;
|
|
145
|
+
}
|
|
115
146
|
|
|
116
147
|
if (number !== this.state.value) {
|
|
117
|
-
this.setState(
|
|
148
|
+
this.setState(
|
|
149
|
+
{
|
|
150
|
+
value: number.toString(),
|
|
151
|
+
currentIndex: updatedIndex
|
|
152
|
+
},
|
|
153
|
+
() => this.props.onChange(event, number)
|
|
154
|
+
);
|
|
118
155
|
}
|
|
119
156
|
};
|
|
120
157
|
|
|
@@ -124,16 +161,37 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
124
161
|
this.setState({ value });
|
|
125
162
|
}
|
|
126
163
|
|
|
127
|
-
changeValue(event, sign = 1) {
|
|
164
|
+
changeValue(event, sign = 1, shouldUpdate = false) {
|
|
128
165
|
event.preventDefault();
|
|
129
166
|
|
|
130
|
-
const { step, onlyIntegersAllowed } = this.props;
|
|
131
|
-
const { value } = this.state;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
const number = this.clamp(updatedValue);
|
|
167
|
+
const { customValues, step, onlyIntegersAllowed, onChange } = this.props;
|
|
168
|
+
const { currentIndex, value } = this.state;
|
|
169
|
+
const updatedIndex = currentIndex + sign * 1;
|
|
170
|
+
let number;
|
|
135
171
|
|
|
136
|
-
|
|
172
|
+
if (customValues.length > 0) {
|
|
173
|
+
if (updatedIndex < 0 || updatedIndex >= customValues.length) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
number = customValues[updatedIndex];
|
|
178
|
+
} else {
|
|
179
|
+
const rawNumber = onlyIntegersAllowed ? parseInt(value) : parseFloat(value);
|
|
180
|
+
const updatedValue = (rawNumber * 10000 + step * sign * 10000) / 10000;
|
|
181
|
+
number = this.clamp(updatedValue);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
this.setState(
|
|
185
|
+
{
|
|
186
|
+
value: number.toString(),
|
|
187
|
+
currentIndex: updatedIndex
|
|
188
|
+
},
|
|
189
|
+
() => {
|
|
190
|
+
if (shouldUpdate) {
|
|
191
|
+
onChange(event, number);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
);
|
|
137
195
|
}
|
|
138
196
|
|
|
139
197
|
render() {
|
|
@@ -186,15 +244,23 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
186
244
|
className: inputClassName,
|
|
187
245
|
disableUnderline: disableUnderline,
|
|
188
246
|
startAdornment: (
|
|
189
|
-
<InputAdornment position="start"
|
|
190
|
-
<IconButton
|
|
247
|
+
<InputAdornment position="start">
|
|
248
|
+
<IconButton
|
|
249
|
+
className={classes.iconButton}
|
|
250
|
+
disabled={disabled}
|
|
251
|
+
onClick={e => this.changeValue(e, -1, true)}
|
|
252
|
+
>
|
|
191
253
|
<Remove fontSize="small" />
|
|
192
254
|
</IconButton>
|
|
193
255
|
</InputAdornment>
|
|
194
256
|
),
|
|
195
257
|
endAdornment: (
|
|
196
|
-
<InputAdornment position="end"
|
|
197
|
-
<IconButton
|
|
258
|
+
<InputAdornment position="end">
|
|
259
|
+
<IconButton
|
|
260
|
+
className={classes.iconButton}
|
|
261
|
+
disabled={disabled}
|
|
262
|
+
onClick={e => this.changeValue(e, 1, true)}
|
|
263
|
+
>
|
|
198
264
|
<Add fontSize="small" />
|
|
199
265
|
</IconButton>
|
|
200
266
|
</InputAdornment>
|