ywana-core8 0.0.488 → 0.0.491
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/index.cjs +440 -369
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +25 -18
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +440 -370
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +440 -369
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.js +43 -7
- package/src/domain/index.js +1 -1
- package/src/html/table.css +7 -0
- package/src/html/table.js +19 -7
- package/src/html/table.test.js +13 -12
- package/src/site/site.test.js +36 -2
package/dist/index.umd.js
CHANGED
@@ -921,307 +921,6 @@
|
|
921
921
|
return /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, child);
|
922
922
|
};
|
923
923
|
|
924
|
-
/**
|
925
|
-
* Text Field
|
926
|
-
*/
|
927
|
-
|
928
|
-
var TextField = function TextField(props) {
|
929
|
-
var site = React.useContext(SiteContext);
|
930
|
-
var id = props.id,
|
931
|
-
_props$type = props.type,
|
932
|
-
type = _props$type === void 0 ? 'text' : _props$type,
|
933
|
-
label = props.label,
|
934
|
-
placeholder = props.placeholder,
|
935
|
-
value = props.value,
|
936
|
-
outlined = props.outlined,
|
937
|
-
_props$readOnly = props.readOnly,
|
938
|
-
readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
|
939
|
-
_props$canClear = props.canClear,
|
940
|
-
canClear = _props$canClear === void 0 ? true : _props$canClear,
|
941
|
-
onChange = props.onChange,
|
942
|
-
onEnter = props.onEnter,
|
943
|
-
onClick = props.onClick,
|
944
|
-
onBlur = props.onBlur;
|
945
|
-
|
946
|
-
function onKeyPress(event) {
|
947
|
-
var key = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;
|
948
|
-
|
949
|
-
if (key == 13) {
|
950
|
-
if (onEnter) onEnter();
|
951
|
-
}
|
952
|
-
}
|
953
|
-
|
954
|
-
function change(event) {
|
955
|
-
event.stopPropagation();
|
956
|
-
event.preventDefault();
|
957
|
-
var value = event.target.value;
|
958
|
-
if (onChange) onChange(id, value);
|
959
|
-
}
|
960
|
-
|
961
|
-
function focus() {
|
962
|
-
if (site && site.changeFocus) {
|
963
|
-
site.changeFocus({
|
964
|
-
lose: function lose() {// DO NOTHING
|
965
|
-
}
|
966
|
-
});
|
967
|
-
}
|
968
|
-
}
|
969
|
-
|
970
|
-
function blur() {
|
971
|
-
if (onBlur) onBlur();
|
972
|
-
}
|
973
|
-
|
974
|
-
function clear() {
|
975
|
-
if (onChange) onChange(id, "");
|
976
|
-
}
|
977
|
-
|
978
|
-
var borderStyle = outlined ? "textfield-outlined" : "textfield";
|
979
|
-
var labelStyle = label ? "" : "no-label";
|
980
|
-
var style = labelStyle + " " + borderStyle + " textfield-" + type;
|
981
|
-
var labelTxt = /*#__PURE__*/React__default["default"].createElement(Text, null, label);
|
982
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
983
|
-
className: "" + style,
|
984
|
-
onClick: onClick
|
985
|
-
}, /*#__PURE__*/React__default["default"].createElement("input", {
|
986
|
-
id: id,
|
987
|
-
type: type,
|
988
|
-
placeholder: placeholder,
|
989
|
-
value: value,
|
990
|
-
required: true,
|
991
|
-
onChange: change,
|
992
|
-
onKeyDown: onKeyPress,
|
993
|
-
onFocus: focus,
|
994
|
-
onBlur: blur,
|
995
|
-
readOnly: readOnly
|
996
|
-
}), canClear && value && value.length > 0 ? /*#__PURE__*/React__default["default"].createElement(Icon, {
|
997
|
-
icon: "close",
|
998
|
-
clickable: true,
|
999
|
-
size: "small",
|
1000
|
-
action: clear
|
1001
|
-
}) : null, /*#__PURE__*/React__default["default"].createElement("span", {
|
1002
|
-
className: "bar"
|
1003
|
-
}), label ? /*#__PURE__*/React__default["default"].createElement("label", null, labelTxt) : null);
|
1004
|
-
};
|
1005
|
-
/**
|
1006
|
-
* Text Area
|
1007
|
-
*/
|
1008
|
-
|
1009
|
-
var TextArea = function TextArea(props) {
|
1010
|
-
var site = React.useContext(SiteContext);
|
1011
|
-
var id = props.id,
|
1012
|
-
_props$type2 = props.type,
|
1013
|
-
type = _props$type2 === void 0 ? 'text' : _props$type2,
|
1014
|
-
label = props.label,
|
1015
|
-
placeholder = props.placeholder,
|
1016
|
-
value = props.value,
|
1017
|
-
_props$readOnly2 = props.readOnly,
|
1018
|
-
readOnly = _props$readOnly2 === void 0 ? false : _props$readOnly2,
|
1019
|
-
_props$canClear2 = props.canClear,
|
1020
|
-
canClear = _props$canClear2 === void 0 ? true : _props$canClear2,
|
1021
|
-
onChange = props.onChange,
|
1022
|
-
onEnter = props.onEnter,
|
1023
|
-
onClick = props.onClick;
|
1024
|
-
|
1025
|
-
function onKeyPress(event) {
|
1026
|
-
var key = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;
|
1027
|
-
|
1028
|
-
if (key == 13) {
|
1029
|
-
if (onEnter) onEnter();
|
1030
|
-
}
|
1031
|
-
}
|
1032
|
-
|
1033
|
-
function change(event) {
|
1034
|
-
event.stopPropagation();
|
1035
|
-
event.preventDefault();
|
1036
|
-
var value = event.target.value;
|
1037
|
-
if (onChange) onChange(id, value);
|
1038
|
-
}
|
1039
|
-
|
1040
|
-
function focus() {
|
1041
|
-
if (site && site.changeFocus) {
|
1042
|
-
site.changeFocus({
|
1043
|
-
lose: function lose() {// DO NOTHING
|
1044
|
-
}
|
1045
|
-
});
|
1046
|
-
}
|
1047
|
-
}
|
1048
|
-
|
1049
|
-
function clear() {
|
1050
|
-
if (onChange) onChange(id, "");
|
1051
|
-
}
|
1052
|
-
|
1053
|
-
var labelStyle = label ? "" : "no-label";
|
1054
|
-
var style = "textarea " + labelStyle + " textarea-" + type;
|
1055
|
-
var labelTxt = /*#__PURE__*/React__default["default"].createElement(Text, null, label);
|
1056
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
1057
|
-
className: "" + style,
|
1058
|
-
onClick: onClick
|
1059
|
-
}, /*#__PURE__*/React__default["default"].createElement("textarea", {
|
1060
|
-
id: id,
|
1061
|
-
placeholder: placeholder,
|
1062
|
-
value: value,
|
1063
|
-
required: true,
|
1064
|
-
onChange: change,
|
1065
|
-
onKeyDown: onKeyPress,
|
1066
|
-
onFocus: focus,
|
1067
|
-
readOnly: readOnly
|
1068
|
-
}), canClear && value && value.length > 0 ? /*#__PURE__*/React__default["default"].createElement(Icon, {
|
1069
|
-
icon: "close",
|
1070
|
-
clickable: true,
|
1071
|
-
size: "small",
|
1072
|
-
action: clear
|
1073
|
-
}) : null, /*#__PURE__*/React__default["default"].createElement("span", {
|
1074
|
-
className: "bar"
|
1075
|
-
}), label ? /*#__PURE__*/React__default["default"].createElement("label", null, labelTxt) : null);
|
1076
|
-
};
|
1077
|
-
/**
|
1078
|
-
* Dropdown
|
1079
|
-
*/
|
1080
|
-
|
1081
|
-
var DropDown = function DropDown(props) {
|
1082
|
-
var site = React.useContext(SiteContext);
|
1083
|
-
var id = props.id,
|
1084
|
-
_props$options = props.options,
|
1085
|
-
options = _props$options === void 0 ? [] : _props$options,
|
1086
|
-
value = props.value,
|
1087
|
-
onChange = props.onChange,
|
1088
|
-
_props$predictive = props.predictive,
|
1089
|
-
predictive = _props$predictive === void 0 ? false : _props$predictive,
|
1090
|
-
_props$readOnly3 = props.readOnly,
|
1091
|
-
readOnly = _props$readOnly3 === void 0 ? false : _props$readOnly3,
|
1092
|
-
_props$verbose = props.verbose,
|
1093
|
-
verbose = _props$verbose === void 0 ? true : _props$verbose,
|
1094
|
-
onBlur = props.onBlur;
|
1095
|
-
|
1096
|
-
var _useState = React.useState(false),
|
1097
|
-
open = _useState[0],
|
1098
|
-
setOpen = _useState[1];
|
1099
|
-
|
1100
|
-
var _useState2 = React.useState(),
|
1101
|
-
label = _useState2[0],
|
1102
|
-
setLabel = _useState2[1];
|
1103
|
-
|
1104
|
-
React.useEffect(function () {
|
1105
|
-
if (Array.isArray(options)) {
|
1106
|
-
var option = options.find(function (option) {
|
1107
|
-
return option.value === value;
|
1108
|
-
});
|
1109
|
-
|
1110
|
-
var _label = option ? option.label : "";
|
1111
|
-
|
1112
|
-
setLabel(_label);
|
1113
|
-
}
|
1114
|
-
}, [value]);
|
1115
|
-
|
1116
|
-
function change(id, value) {
|
1117
|
-
if (predictive) {
|
1118
|
-
setLabel(value);
|
1119
|
-
} else {
|
1120
|
-
if (onChange) onChange(id, value);
|
1121
|
-
}
|
1122
|
-
}
|
1123
|
-
|
1124
|
-
function toggle() {
|
1125
|
-
if (site && site.changeFocus) {
|
1126
|
-
site.changeFocus({
|
1127
|
-
lose: function lose() {
|
1128
|
-
setOpen(false);
|
1129
|
-
}
|
1130
|
-
});
|
1131
|
-
}
|
1132
|
-
|
1133
|
-
if (!readOnly) setOpen(!open);
|
1134
|
-
}
|
1135
|
-
|
1136
|
-
function select(event) {
|
1137
|
-
var next = event.target.getAttribute("value");
|
1138
|
-
var option = options.find(function (option) {
|
1139
|
-
return option.value === next;
|
1140
|
-
});
|
1141
|
-
setOpen(false);
|
1142
|
-
var label = verbose ? option.label : "";
|
1143
|
-
setLabel(label);
|
1144
|
-
if (onChange) onChange(id, next);
|
1145
|
-
}
|
1146
|
-
|
1147
|
-
function blur() {
|
1148
|
-
if (onBlur) onBlur();
|
1149
|
-
}
|
1150
|
-
|
1151
|
-
function renderOptions() {
|
1152
|
-
var canShow = open == true && Array.isArray(options);
|
1153
|
-
|
1154
|
-
if (canShow) {
|
1155
|
-
var filterActive = predictive === true && label && label.length > 0;
|
1156
|
-
var items = filterActive ? options.filter(function (option) {
|
1157
|
-
return option.label.toUpperCase().indexOf(label.toUpperCase()) >= 0;
|
1158
|
-
}) : options;
|
1159
|
-
var lis = items.map(function (option) {
|
1160
|
-
return /*#__PURE__*/React__default["default"].createElement("li", {
|
1161
|
-
key: option.value,
|
1162
|
-
value: option.value
|
1163
|
-
}, option.label);
|
1164
|
-
});
|
1165
|
-
return /*#__PURE__*/React__default["default"].createElement("menu", null, /*#__PURE__*/React__default["default"].createElement("ul", {
|
1166
|
-
onMouseDown: select
|
1167
|
-
}, lis));
|
1168
|
-
} else {
|
1169
|
-
return null;
|
1170
|
-
}
|
1171
|
-
}
|
1172
|
-
|
1173
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
1174
|
-
className: "dropdown"
|
1175
|
-
}, /*#__PURE__*/React__default["default"].createElement(TextField, _extends({}, props, {
|
1176
|
-
onClick: toggle,
|
1177
|
-
value: label,
|
1178
|
-
onChange: change,
|
1179
|
-
onBlur: blur,
|
1180
|
-
readOnly: !predictive
|
1181
|
-
})), !readOnly ? /*#__PURE__*/React__default["default"].createElement(Icon, {
|
1182
|
-
icon: "expand_more",
|
1183
|
-
clickable: true,
|
1184
|
-
size: "small",
|
1185
|
-
action: toggle
|
1186
|
-
}) : null, renderOptions());
|
1187
|
-
};
|
1188
|
-
var DateRange = function DateRange(props) {
|
1189
|
-
var id = props.id,
|
1190
|
-
label = props.label,
|
1191
|
-
onChange = props.onChange;
|
1192
|
-
|
1193
|
-
var _useState3 = React.useState({}),
|
1194
|
-
form = _useState3[0],
|
1195
|
-
setForm = _useState3[1];
|
1196
|
-
|
1197
|
-
React.useEffect(function () {
|
1198
|
-
if (onChange) onChange(id, form);
|
1199
|
-
}, [form]);
|
1200
|
-
|
1201
|
-
function change(id, value) {
|
1202
|
-
var _Object$assign;
|
1203
|
-
|
1204
|
-
var next = Object.assign({}, form, (_Object$assign = {}, _Object$assign[id] = value, _Object$assign));
|
1205
|
-
setForm(next);
|
1206
|
-
}
|
1207
|
-
|
1208
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
1209
|
-
className: "date-range"
|
1210
|
-
}, label ? /*#__PURE__*/React__default["default"].createElement("label", null, label) : null, /*#__PURE__*/React__default["default"].createElement(TextField, {
|
1211
|
-
id: "from",
|
1212
|
-
type: "date",
|
1213
|
-
label: "From",
|
1214
|
-
value: form.from,
|
1215
|
-
onChange: change
|
1216
|
-
}), /*#__PURE__*/React__default["default"].createElement(TextField, {
|
1217
|
-
id: "to",
|
1218
|
-
type: "date",
|
1219
|
-
label: "To",
|
1220
|
-
value: form.to,
|
1221
|
-
onChange: change
|
1222
|
-
}));
|
1223
|
-
};
|
1224
|
-
|
1225
924
|
/**
|
1226
925
|
* TYPES
|
1227
926
|
*/
|
@@ -1408,77 +1107,354 @@
|
|
1408
1107
|
}) : [];
|
1409
1108
|
}
|
1410
1109
|
|
1411
|
-
break;
|
1110
|
+
break;
|
1111
|
+
|
1112
|
+
default:
|
1113
|
+
next[name] = field;
|
1114
|
+
break;
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
return next;
|
1118
|
+
}, {});
|
1119
|
+
return next;
|
1120
|
+
};
|
1121
|
+
|
1122
|
+
return ContentType;
|
1123
|
+
}();
|
1124
|
+
/**
|
1125
|
+
* Content
|
1126
|
+
*/
|
1127
|
+
|
1128
|
+
var Content = /*#__PURE__*/function () {
|
1129
|
+
function Content(type, value) {
|
1130
|
+
this.type = type;
|
1131
|
+
this._type = new ContentType(type);
|
1132
|
+
this._value = value;
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
var _proto2 = Content.prototype;
|
1136
|
+
|
1137
|
+
_proto2.isValid = function isValid() {
|
1138
|
+
return this._type.validate(this._value);
|
1139
|
+
};
|
1140
|
+
|
1141
|
+
_proto2.value = function value() {
|
1142
|
+
return this._type.value(this._value);
|
1143
|
+
};
|
1144
|
+
|
1145
|
+
_proto2.form = function form() {
|
1146
|
+
return this._type.form(this._value);
|
1147
|
+
};
|
1148
|
+
|
1149
|
+
_proto2.sections = function sections() {
|
1150
|
+
return this._type.sections(this._value);
|
1151
|
+
};
|
1152
|
+
|
1153
|
+
_proto2.update = function update(value) {
|
1154
|
+
this._value = value;
|
1155
|
+
};
|
1156
|
+
|
1157
|
+
return Content;
|
1158
|
+
}();
|
1159
|
+
|
1160
|
+
/**
|
1161
|
+
* Text Field
|
1162
|
+
*/
|
1163
|
+
|
1164
|
+
var TextField = function TextField(props) {
|
1165
|
+
var site = React.useContext(SiteContext);
|
1166
|
+
var id = props.id,
|
1167
|
+
_props$type = props.type,
|
1168
|
+
type = _props$type === void 0 ? 'text' : _props$type,
|
1169
|
+
label = props.label,
|
1170
|
+
placeholder = props.placeholder,
|
1171
|
+
value = props.value,
|
1172
|
+
outlined = props.outlined,
|
1173
|
+
_props$readOnly = props.readOnly,
|
1174
|
+
readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
|
1175
|
+
_props$canClear = props.canClear,
|
1176
|
+
canClear = _props$canClear === void 0 ? true : _props$canClear,
|
1177
|
+
onChange = props.onChange,
|
1178
|
+
onEnter = props.onEnter,
|
1179
|
+
onClick = props.onClick,
|
1180
|
+
onBlur = props.onBlur;
|
1181
|
+
|
1182
|
+
function onKeyPress(event) {
|
1183
|
+
var key = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;
|
1184
|
+
|
1185
|
+
if (key == 13) {
|
1186
|
+
if (onEnter) onEnter();
|
1187
|
+
}
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
function change(event) {
|
1191
|
+
event.stopPropagation();
|
1192
|
+
event.preventDefault();
|
1193
|
+
var value = event.target.value;
|
1194
|
+
if (onChange) onChange(id, value);
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
function focus() {
|
1198
|
+
if (site && site.changeFocus) {
|
1199
|
+
site.changeFocus({
|
1200
|
+
lose: function lose() {// DO NOTHING
|
1201
|
+
}
|
1202
|
+
});
|
1203
|
+
}
|
1204
|
+
}
|
1205
|
+
|
1206
|
+
function blur() {
|
1207
|
+
if (onBlur) onBlur();
|
1208
|
+
}
|
1209
|
+
|
1210
|
+
function clear() {
|
1211
|
+
if (onChange) onChange(id, "");
|
1212
|
+
}
|
1213
|
+
|
1214
|
+
var borderStyle = outlined ? "textfield-outlined" : "textfield";
|
1215
|
+
var labelStyle = label ? "" : "no-label";
|
1216
|
+
var style = labelStyle + " " + borderStyle + " textfield-" + type;
|
1217
|
+
var labelTxt = /*#__PURE__*/React__default["default"].createElement(Text, null, label);
|
1218
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
1219
|
+
className: "" + style,
|
1220
|
+
onClick: onClick
|
1221
|
+
}, /*#__PURE__*/React__default["default"].createElement("input", {
|
1222
|
+
id: id,
|
1223
|
+
type: type,
|
1224
|
+
placeholder: placeholder,
|
1225
|
+
value: value,
|
1226
|
+
required: true,
|
1227
|
+
onChange: change,
|
1228
|
+
onKeyDown: onKeyPress,
|
1229
|
+
onFocus: focus,
|
1230
|
+
onBlur: blur,
|
1231
|
+
readOnly: readOnly
|
1232
|
+
}), canClear && value && value.length > 0 ? /*#__PURE__*/React__default["default"].createElement(Icon, {
|
1233
|
+
icon: "close",
|
1234
|
+
clickable: true,
|
1235
|
+
size: "small",
|
1236
|
+
action: clear
|
1237
|
+
}) : null, /*#__PURE__*/React__default["default"].createElement("span", {
|
1238
|
+
className: "bar"
|
1239
|
+
}), label ? /*#__PURE__*/React__default["default"].createElement("label", null, labelTxt) : null);
|
1240
|
+
};
|
1241
|
+
/**
|
1242
|
+
* Text Area
|
1243
|
+
*/
|
1244
|
+
|
1245
|
+
var TextArea = function TextArea(props) {
|
1246
|
+
var site = React.useContext(SiteContext);
|
1247
|
+
var id = props.id,
|
1248
|
+
_props$type2 = props.type,
|
1249
|
+
type = _props$type2 === void 0 ? 'text' : _props$type2,
|
1250
|
+
label = props.label,
|
1251
|
+
placeholder = props.placeholder,
|
1252
|
+
value = props.value,
|
1253
|
+
_props$readOnly2 = props.readOnly,
|
1254
|
+
readOnly = _props$readOnly2 === void 0 ? false : _props$readOnly2,
|
1255
|
+
_props$canClear2 = props.canClear,
|
1256
|
+
canClear = _props$canClear2 === void 0 ? true : _props$canClear2,
|
1257
|
+
onChange = props.onChange,
|
1258
|
+
onEnter = props.onEnter,
|
1259
|
+
onClick = props.onClick;
|
1260
|
+
|
1261
|
+
function onKeyPress(event) {
|
1262
|
+
var key = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;
|
1263
|
+
|
1264
|
+
if (key == 13) {
|
1265
|
+
if (onEnter) onEnter();
|
1266
|
+
}
|
1267
|
+
}
|
1268
|
+
|
1269
|
+
function change(event) {
|
1270
|
+
event.stopPropagation();
|
1271
|
+
event.preventDefault();
|
1272
|
+
var value = event.target.value;
|
1273
|
+
if (onChange) onChange(id, value);
|
1274
|
+
}
|
1275
|
+
|
1276
|
+
function focus() {
|
1277
|
+
if (site && site.changeFocus) {
|
1278
|
+
site.changeFocus({
|
1279
|
+
lose: function lose() {// DO NOTHING
|
1280
|
+
}
|
1281
|
+
});
|
1282
|
+
}
|
1283
|
+
}
|
1284
|
+
|
1285
|
+
function clear() {
|
1286
|
+
if (onChange) onChange(id, "");
|
1287
|
+
}
|
1288
|
+
|
1289
|
+
var labelStyle = label ? "" : "no-label";
|
1290
|
+
var style = "textarea " + labelStyle + " textarea-" + type;
|
1291
|
+
var labelTxt = /*#__PURE__*/React__default["default"].createElement(Text, null, label);
|
1292
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
1293
|
+
className: "" + style,
|
1294
|
+
onClick: onClick
|
1295
|
+
}, /*#__PURE__*/React__default["default"].createElement("textarea", {
|
1296
|
+
id: id,
|
1297
|
+
placeholder: placeholder,
|
1298
|
+
value: value,
|
1299
|
+
required: true,
|
1300
|
+
onChange: change,
|
1301
|
+
onKeyDown: onKeyPress,
|
1302
|
+
onFocus: focus,
|
1303
|
+
readOnly: readOnly
|
1304
|
+
}), canClear && value && value.length > 0 ? /*#__PURE__*/React__default["default"].createElement(Icon, {
|
1305
|
+
icon: "close",
|
1306
|
+
clickable: true,
|
1307
|
+
size: "small",
|
1308
|
+
action: clear
|
1309
|
+
}) : null, /*#__PURE__*/React__default["default"].createElement("span", {
|
1310
|
+
className: "bar"
|
1311
|
+
}), label ? /*#__PURE__*/React__default["default"].createElement("label", null, labelTxt) : null);
|
1312
|
+
};
|
1313
|
+
/**
|
1314
|
+
* Dropdown
|
1315
|
+
*/
|
1316
|
+
|
1317
|
+
var DropDown = function DropDown(props) {
|
1318
|
+
var site = React.useContext(SiteContext);
|
1319
|
+
var id = props.id,
|
1320
|
+
_props$options = props.options,
|
1321
|
+
options = _props$options === void 0 ? [] : _props$options,
|
1322
|
+
value = props.value,
|
1323
|
+
onChange = props.onChange,
|
1324
|
+
_props$predictive = props.predictive,
|
1325
|
+
predictive = _props$predictive === void 0 ? false : _props$predictive,
|
1326
|
+
_props$readOnly3 = props.readOnly,
|
1327
|
+
readOnly = _props$readOnly3 === void 0 ? false : _props$readOnly3,
|
1328
|
+
_props$verbose = props.verbose,
|
1329
|
+
verbose = _props$verbose === void 0 ? true : _props$verbose,
|
1330
|
+
onBlur = props.onBlur;
|
1331
|
+
|
1332
|
+
var _useState = React.useState(false),
|
1333
|
+
open = _useState[0],
|
1334
|
+
setOpen = _useState[1];
|
1335
|
+
|
1336
|
+
var _useState2 = React.useState(),
|
1337
|
+
label = _useState2[0],
|
1338
|
+
setLabel = _useState2[1];
|
1412
1339
|
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1340
|
+
React.useEffect(function () {
|
1341
|
+
if (Array.isArray(options)) {
|
1342
|
+
var option = options.find(function (option) {
|
1343
|
+
return option.value === value;
|
1344
|
+
});
|
1417
1345
|
|
1418
|
-
|
1419
|
-
}, {});
|
1420
|
-
return next;
|
1421
|
-
};
|
1346
|
+
var _label = option ? option.label : "";
|
1422
1347
|
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
* Content
|
1427
|
-
*/
|
1348
|
+
setLabel(_label);
|
1349
|
+
}
|
1350
|
+
}, [value]);
|
1428
1351
|
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1352
|
+
function change(id, value) {
|
1353
|
+
if (predictive) {
|
1354
|
+
setLabel(value);
|
1355
|
+
} else {
|
1356
|
+
if (onChange) onChange(id, value);
|
1357
|
+
}
|
1434
1358
|
}
|
1435
1359
|
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1360
|
+
function toggle() {
|
1361
|
+
if (site && site.changeFocus) {
|
1362
|
+
site.changeFocus({
|
1363
|
+
lose: function lose() {
|
1364
|
+
setOpen(false);
|
1365
|
+
}
|
1366
|
+
});
|
1367
|
+
}
|
1441
1368
|
|
1442
|
-
|
1443
|
-
|
1444
|
-
};
|
1369
|
+
if (!readOnly) setOpen(!open);
|
1370
|
+
}
|
1445
1371
|
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1372
|
+
function select(event) {
|
1373
|
+
var next = event.target.getAttribute("value");
|
1374
|
+
var option = options.find(function (option) {
|
1375
|
+
return option.value === next;
|
1376
|
+
});
|
1377
|
+
setOpen(false);
|
1378
|
+
var label = verbose ? option.label : "";
|
1379
|
+
setLabel(label);
|
1380
|
+
if (onChange) onChange(id, next);
|
1381
|
+
}
|
1449
1382
|
|
1450
|
-
|
1451
|
-
|
1452
|
-
}
|
1383
|
+
function blur() {
|
1384
|
+
if (onBlur) onBlur();
|
1385
|
+
}
|
1453
1386
|
|
1454
|
-
|
1455
|
-
|
1456
|
-
};
|
1387
|
+
function renderOptions() {
|
1388
|
+
var canShow = open == true && Array.isArray(options);
|
1457
1389
|
|
1458
|
-
|
1459
|
-
|
1390
|
+
if (canShow) {
|
1391
|
+
var filterActive = predictive === true && label && label.length > 0;
|
1392
|
+
var items = filterActive ? options.filter(function (option) {
|
1393
|
+
return option.label.toUpperCase().indexOf(label.toUpperCase()) >= 0;
|
1394
|
+
}) : options;
|
1395
|
+
var lis = items.map(function (option) {
|
1396
|
+
return /*#__PURE__*/React__default["default"].createElement("li", {
|
1397
|
+
key: option.value,
|
1398
|
+
value: option.value
|
1399
|
+
}, option.label);
|
1400
|
+
});
|
1401
|
+
return /*#__PURE__*/React__default["default"].createElement("menu", null, /*#__PURE__*/React__default["default"].createElement("ul", {
|
1402
|
+
onMouseDown: select
|
1403
|
+
}, lis));
|
1404
|
+
} else {
|
1405
|
+
return null;
|
1406
|
+
}
|
1407
|
+
}
|
1460
1408
|
|
1461
|
-
|
1409
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
1410
|
+
className: "dropdown"
|
1411
|
+
}, /*#__PURE__*/React__default["default"].createElement(TextField, _extends({}, props, {
|
1412
|
+
onClick: toggle,
|
1413
|
+
value: label,
|
1414
|
+
onChange: change,
|
1415
|
+
onBlur: blur,
|
1416
|
+
readOnly: !predictive
|
1417
|
+
})), !readOnly ? /*#__PURE__*/React__default["default"].createElement(Icon, {
|
1418
|
+
icon: "expand_more",
|
1419
|
+
clickable: true,
|
1420
|
+
size: "small",
|
1421
|
+
action: toggle
|
1422
|
+
}) : null, renderOptions());
|
1423
|
+
};
|
1424
|
+
var DateRange = function DateRange(props) {
|
1462
1425
|
var id = props.id,
|
1463
|
-
|
1464
|
-
label = _props$label === void 0 ? "Color" : _props$label,
|
1465
|
-
value = props.value,
|
1426
|
+
label = props.label,
|
1466
1427
|
onChange = props.onChange;
|
1467
1428
|
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1429
|
+
var _useState3 = React.useState({}),
|
1430
|
+
form = _useState3[0],
|
1431
|
+
setForm = _useState3[1];
|
1432
|
+
|
1433
|
+
React.useEffect(function () {
|
1434
|
+
if (onChange) onChange(id, form);
|
1435
|
+
}, [form]);
|
1436
|
+
|
1437
|
+
function change(id, value) {
|
1438
|
+
var _Object$assign;
|
1439
|
+
|
1440
|
+
var next = Object.assign({}, form, (_Object$assign = {}, _Object$assign[id] = value, _Object$assign));
|
1441
|
+
setForm(next);
|
1471
1442
|
}
|
1472
1443
|
|
1473
1444
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
1474
|
-
className: "
|
1475
|
-
}, /*#__PURE__*/React__default["default"].createElement("label", {
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
onChange: change
|
1481
|
-
|
1445
|
+
className: "date-range"
|
1446
|
+
}, label ? /*#__PURE__*/React__default["default"].createElement("label", null, label) : null, /*#__PURE__*/React__default["default"].createElement(TextField, {
|
1447
|
+
id: "from",
|
1448
|
+
type: "date",
|
1449
|
+
label: "From",
|
1450
|
+
value: form.from,
|
1451
|
+
onChange: change
|
1452
|
+
}), /*#__PURE__*/React__default["default"].createElement(TextField, {
|
1453
|
+
id: "to",
|
1454
|
+
type: "date",
|
1455
|
+
label: "To",
|
1456
|
+
value: form.to,
|
1457
|
+
onChange: change
|
1482
1458
|
}));
|
1483
1459
|
};
|
1484
1460
|
|
@@ -1505,17 +1481,31 @@
|
|
1505
1481
|
className = props.className;
|
1506
1482
|
|
1507
1483
|
var _useState = React.useState({}),
|
1508
|
-
sortDir = _useState[0]
|
1484
|
+
sortDir = _useState[0],
|
1485
|
+
setSortDir = _useState[1];
|
1509
1486
|
|
1510
1487
|
var _useState2 = React.useState(false),
|
1511
1488
|
allChecked = _useState2[0],
|
1512
1489
|
setAllChecked = _useState2[1];
|
1513
1490
|
|
1491
|
+
React.useEffect(function () {
|
1492
|
+
console.log(sortDir);
|
1493
|
+
}, [sortDir]);
|
1494
|
+
|
1495
|
+
function changeSort(id) {
|
1496
|
+
var _Object$assign;
|
1497
|
+
|
1498
|
+
var nextDir = sortDir[id] ? sortDir[id] * -1 : 1;
|
1499
|
+
var next = Object.assign({}, sortDir, (_Object$assign = {}, _Object$assign[id] = nextDir, _Object$assign));
|
1500
|
+
setSortDir(next);
|
1501
|
+
}
|
1502
|
+
|
1514
1503
|
function multiSort(array, sortObject) {
|
1515
1504
|
if (sortObject === void 0) {
|
1516
1505
|
sortObject = {};
|
1517
1506
|
}
|
1518
1507
|
|
1508
|
+
console.log('multisort', sortObject);
|
1519
1509
|
var sortKeys = Object.keys(sortObject);
|
1520
1510
|
|
1521
1511
|
if (!sortKeys.length) {
|
@@ -1558,7 +1548,7 @@
|
|
1558
1548
|
}
|
1559
1549
|
}
|
1560
1550
|
|
1561
|
-
function
|
1551
|
+
function moveRow(dragged, dropped) {
|
1562
1552
|
if (onSort) onSort(dragged, dropped);
|
1563
1553
|
}
|
1564
1554
|
|
@@ -1590,16 +1580,19 @@
|
|
1590
1580
|
key: id,
|
1591
1581
|
rowSpan: rowspan,
|
1592
1582
|
colSpan: colspan
|
1593
|
-
}, id === "checked" ? /*#__PURE__*/React__default["default"].createElement(CheckBox, {
|
1583
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", null, id === "checked" ? /*#__PURE__*/React__default["default"].createElement(CheckBox, {
|
1594
1584
|
onChange: checkAll,
|
1595
1585
|
value: allChecked
|
1596
1586
|
}) : /*#__PURE__*/React__default["default"].createElement(Text, {
|
1597
1587
|
key: "th_" + id
|
1598
1588
|
}, label), sortable ? /*#__PURE__*/React__default["default"].createElement(Icon, {
|
1599
|
-
icon: "
|
1589
|
+
icon: "expand_less",
|
1600
1590
|
size: "small",
|
1601
|
-
clickable: true
|
1602
|
-
|
1591
|
+
clickable: true,
|
1592
|
+
action: function action() {
|
1593
|
+
return changeSort(id);
|
1594
|
+
}
|
1595
|
+
}) : null));
|
1603
1596
|
}), /*#__PURE__*/React__default["default"].createElement("th", {
|
1604
1597
|
rowSpan: 2,
|
1605
1598
|
colSpan: 1
|
@@ -1620,7 +1613,7 @@
|
|
1620
1613
|
row: row,
|
1621
1614
|
columns: columns,
|
1622
1615
|
onSelect: select,
|
1623
|
-
onDrop:
|
1616
|
+
onDrop: moveRow,
|
1624
1617
|
editable: editable,
|
1625
1618
|
expanded: expanded
|
1626
1619
|
});
|
@@ -3819,6 +3812,30 @@
|
|
3819
3812
|
});
|
3820
3813
|
};
|
3821
3814
|
|
3815
|
+
var ColorField = function ColorField(props) {
|
3816
|
+
var id = props.id,
|
3817
|
+
_props$label = props.label,
|
3818
|
+
label = _props$label === void 0 ? "Color" : _props$label,
|
3819
|
+
value = props.value,
|
3820
|
+
onChange = props.onChange;
|
3821
|
+
|
3822
|
+
function change(event) {
|
3823
|
+
var color = event.target.value;
|
3824
|
+
if (onChange) onChange(id, color);
|
3825
|
+
}
|
3826
|
+
|
3827
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
3828
|
+
className: "color-field"
|
3829
|
+
}, /*#__PURE__*/React__default["default"].createElement("label", {
|
3830
|
+
htmlFor: id
|
3831
|
+
}, label), /*#__PURE__*/React__default["default"].createElement("input", {
|
3832
|
+
id: id,
|
3833
|
+
type: "color",
|
3834
|
+
onChange: change,
|
3835
|
+
value: value
|
3836
|
+
}));
|
3837
|
+
};
|
3838
|
+
|
3822
3839
|
/**
|
3823
3840
|
* Content Editor
|
3824
3841
|
*/
|
@@ -4867,17 +4884,70 @@
|
|
4867
4884
|
delay: delay
|
4868
4885
|
}), children ? /*#__PURE__*/React__default["default"].createElement("article", null, children) : null));
|
4869
4886
|
};
|
4870
|
-
|
4871
4887
|
var CollectionFilters = function CollectionFilters(props) {
|
4872
|
-
|
4873
|
-
|
4874
|
-
|
4888
|
+
var change = function change(next) {
|
4889
|
+
try {
|
4890
|
+
setForm(next);
|
4891
|
+
return Promise.resolve();
|
4892
|
+
} catch (e) {
|
4893
|
+
return Promise.reject(e);
|
4894
|
+
}
|
4895
|
+
};
|
4896
|
+
|
4897
|
+
var schema = props.schema,
|
4898
|
+
onChange = props.onChange;
|
4899
|
+
|
4900
|
+
var _useState = React.useState({}),
|
4901
|
+
form = _useState[0],
|
4902
|
+
setForm = _useState[1];
|
4903
|
+
|
4904
|
+
var filterSchema = React.useMemo(function () {
|
4905
|
+
var filterSchema = Object.assign({}, schema);
|
4906
|
+
|
4907
|
+
for (var key in filterSchema) {
|
4908
|
+
if (filterSchema[key].filter === false) {
|
4909
|
+
delete filterSchema[key];
|
4910
|
+
} else {
|
4911
|
+
if (filterSchema[key].type === TYPES.ENTITY) {
|
4912
|
+
var fs = filterSchema[key].item;
|
4913
|
+
|
4914
|
+
for (var key in fs) {
|
4915
|
+
if (fs[key].filter === false) delete fs[key];
|
4916
|
+
}
|
4917
|
+
}
|
4918
|
+
}
|
4919
|
+
}
|
4920
|
+
|
4921
|
+
return filterSchema;
|
4922
|
+
}, [schema]);
|
4923
|
+
React.useEffect(function () {
|
4924
|
+
if (onChange) onChange(form);
|
4925
|
+
}, [form]);
|
4926
|
+
|
4927
|
+
function clear() {
|
4928
|
+
change({});
|
4929
|
+
}
|
4930
|
+
|
4931
|
+
var content = new Content(filterSchema, form);
|
4932
|
+
return /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, /*#__PURE__*/React__default["default"].createElement(Header, {
|
4933
|
+
className: "table-filters",
|
4934
|
+
title: /*#__PURE__*/React__default["default"].createElement(Text, null, "Filters")
|
4935
|
+
}, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
4936
|
+
icon: "filter_list_off",
|
4937
|
+
size: "small",
|
4938
|
+
clickable: true,
|
4939
|
+
action: clear
|
4940
|
+
})), /*#__PURE__*/React__default["default"].createElement("main", {
|
4941
|
+
className: "table-filters"
|
4942
|
+
}, /*#__PURE__*/React__default["default"].createElement(ContentEditor, {
|
4943
|
+
content: content,
|
4944
|
+
onChange: change
|
4945
|
+
})));
|
4875
4946
|
};
|
4876
4947
|
/**
|
4877
4948
|
* Collection List
|
4878
4949
|
*/
|
4879
4950
|
|
4880
|
-
|
4881
4951
|
var CollectionList = function CollectionList(props) {
|
4882
4952
|
var select = function select(id) {
|
4883
4953
|
try {
|
@@ -5047,9 +5117,9 @@
|
|
5047
5117
|
delay = _props$delay2 === void 0 ? 1000 : _props$delay2;
|
5048
5118
|
var timer = React.useRef(null);
|
5049
5119
|
|
5050
|
-
var
|
5051
|
-
form =
|
5052
|
-
setForm =
|
5120
|
+
var _useState2 = React.useState(selected),
|
5121
|
+
form = _useState2[0],
|
5122
|
+
setForm = _useState2[1];
|
5053
5123
|
|
5054
5124
|
React.useEffect(function () {
|
5055
5125
|
setForm(selected);
|
@@ -7586,6 +7656,7 @@
|
|
7586
7656
|
exports.CircularProgress = CircularProgress;
|
7587
7657
|
exports.CollectionContext = CollectionContext;
|
7588
7658
|
exports.CollectionEditor = CollectionEditor$1;
|
7659
|
+
exports.CollectionFilters = CollectionFilters;
|
7589
7660
|
exports.CollectionPage = CollectionPage;
|
7590
7661
|
exports.CollectionTree = CollectionTree;
|
7591
7662
|
exports.Content = Content;
|