ywana-core8 0.0.880 → 0.0.882
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 +33 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +33 -8
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +33 -8
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/button.js +2 -4
- package/src/html/text.js +18 -6
- package/src/html/text.test.js +1 -0
- package/src/html/textfield.js +4 -3
- package/src/html/textfield.test.js +1 -1
- package/src/site/site.js +6 -0
package/dist/index.cjs
CHANGED
@@ -208,15 +208,18 @@ var TEXTFORMATS = {
|
|
208
208
|
TIME: 'time',
|
209
209
|
EMAIL: 'email',
|
210
210
|
HTML: 'HTML',
|
211
|
-
URL: 'URL'
|
211
|
+
URL: 'URL',
|
212
|
+
STRING: 'string'
|
212
213
|
};
|
213
214
|
|
214
215
|
/**
|
215
216
|
* Text
|
216
217
|
*/
|
217
218
|
var Text = function Text(_ref) {
|
218
|
-
var format = _ref.format,
|
219
|
-
|
219
|
+
var _ref$format = _ref.format,
|
220
|
+
format = _ref$format === void 0 ? TEXTFORMATS.HTML : _ref$format,
|
221
|
+
children = _ref.children,
|
222
|
+
className = _ref.className;
|
220
223
|
var site = React.useContext(SiteContext);
|
221
224
|
var value = children;
|
222
225
|
if (site) {
|
@@ -233,7 +236,23 @@ var Text = function Text(_ref) {
|
|
233
236
|
value = formatter.format(children);
|
234
237
|
break;
|
235
238
|
}
|
236
|
-
|
239
|
+
switch (format) {
|
240
|
+
case TEXTFORMATS.DATE:
|
241
|
+
value = new Date(children).toLocaleDateString();
|
242
|
+
break;
|
243
|
+
case TEXTFORMATS.TIME:
|
244
|
+
value = new Date(children).toLocaleTimeString();
|
245
|
+
break;
|
246
|
+
}
|
247
|
+
if (!children) return '';
|
248
|
+
switch (format) {
|
249
|
+
case TEXTFORMATS.STRING:
|
250
|
+
return value;
|
251
|
+
default:
|
252
|
+
return /*#__PURE__*/React__default["default"].createElement("span", {
|
253
|
+
className: className
|
254
|
+
}, value);
|
255
|
+
}
|
237
256
|
};
|
238
257
|
|
239
258
|
/**
|
@@ -421,7 +440,7 @@ var Button = function Button(_ref) {
|
|
421
440
|
size: "small",
|
422
441
|
clickable: true,
|
423
442
|
action: click
|
424
|
-
}) : null, /*#__PURE__*/React__default["default"].createElement(
|
443
|
+
}) : null, /*#__PURE__*/React__default["default"].createElement(Text, null, label));
|
425
444
|
};
|
426
445
|
|
427
446
|
/**
|
@@ -1273,7 +1292,7 @@ var Content = /*#__PURE__*/function () {
|
|
1273
1292
|
* Text Field
|
1274
1293
|
*/
|
1275
1294
|
var TextField = function TextField(props) {
|
1276
|
-
React.useContext(SiteContext);
|
1295
|
+
var site = React.useContext(SiteContext);
|
1277
1296
|
var id = props.id,
|
1278
1297
|
_props$type = props.type,
|
1279
1298
|
type = _props$type === void 0 ? 'text' : _props$type,
|
@@ -1318,7 +1337,7 @@ var TextField = function TextField(props) {
|
|
1318
1337
|
var labelPositionStyle = labelPosition == 'left' ? "label-left" : "label-top";
|
1319
1338
|
var style = labelStyle + " " + labelPositionStyle + " " + borderStyle + " textfield-" + type;
|
1320
1339
|
var labelTxt = /*#__PURE__*/React__default["default"].createElement(Text, null, label);
|
1321
|
-
var placeholderTxt =
|
1340
|
+
var placeholderTxt = site.translate ? site.translate(placeholder) : placeholder;
|
1322
1341
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
1323
1342
|
className: style + " " + id,
|
1324
1343
|
onClick: onClick
|
@@ -1389,7 +1408,7 @@ var TextArea = function TextArea(props) {
|
|
1389
1408
|
var labelStyle = label ? "" : "no-label";
|
1390
1409
|
var style = "textarea " + labelStyle + " textarea-" + type;
|
1391
1410
|
var labelTxt = /*#__PURE__*/React__default["default"].createElement(Text, null, label);
|
1392
|
-
var placeholderTxt =
|
1411
|
+
var placeholderTxt = site.translate ? site.translate(placeholder) : placeholder;
|
1393
1412
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
1394
1413
|
className: "" + style,
|
1395
1414
|
onClick: onClick
|
@@ -3778,6 +3797,12 @@ var SiteProvider = function SiteProvider(_ref) {
|
|
3778
3797
|
setLang: setLang,
|
3779
3798
|
dictionary: dictionary,
|
3780
3799
|
setDictionary: setDictionary,
|
3800
|
+
translate: function translate(key) {
|
3801
|
+
if (!key) return key;
|
3802
|
+
if (dictionary === undefined) return key;
|
3803
|
+
var term = dictionary[key];
|
3804
|
+
return term ? term[lang] : key;
|
3805
|
+
},
|
3781
3806
|
sideNav: sideNav,
|
3782
3807
|
setSideNav: setSideNav,
|
3783
3808
|
showNav: showNav,
|