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.
@@ -199,15 +199,18 @@ var TEXTFORMATS = {
199
199
  TIME: 'time',
200
200
  EMAIL: 'email',
201
201
  HTML: 'HTML',
202
- URL: 'URL'
202
+ URL: 'URL',
203
+ STRING: 'string'
203
204
  };
204
205
 
205
206
  /**
206
207
  * Text
207
208
  */
208
209
  var Text = function Text(_ref) {
209
- var format = _ref.format,
210
- children = _ref.children;
210
+ var _ref$format = _ref.format,
211
+ format = _ref$format === void 0 ? TEXTFORMATS.HTML : _ref$format,
212
+ children = _ref.children,
213
+ className = _ref.className;
211
214
  var site = useContext(SiteContext);
212
215
  var value = children;
213
216
  if (site) {
@@ -224,7 +227,23 @@ var Text = function Text(_ref) {
224
227
  value = formatter.format(children);
225
228
  break;
226
229
  }
227
- return children ? value : '';
230
+ switch (format) {
231
+ case TEXTFORMATS.DATE:
232
+ value = new Date(children).toLocaleDateString();
233
+ break;
234
+ case TEXTFORMATS.TIME:
235
+ value = new Date(children).toLocaleTimeString();
236
+ break;
237
+ }
238
+ if (!children) return '';
239
+ switch (format) {
240
+ case TEXTFORMATS.STRING:
241
+ return value;
242
+ default:
243
+ return /*#__PURE__*/React.createElement("span", {
244
+ className: className
245
+ }, value);
246
+ }
228
247
  };
229
248
 
230
249
  /**
@@ -412,7 +431,7 @@ var Button = function Button(_ref) {
412
431
  size: "small",
413
432
  clickable: true,
414
433
  action: click
415
- }) : null, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Text, null, label)));
434
+ }) : null, /*#__PURE__*/React.createElement(Text, null, label));
416
435
  };
417
436
 
418
437
  /**
@@ -1264,7 +1283,7 @@ var Content = /*#__PURE__*/function () {
1264
1283
  * Text Field
1265
1284
  */
1266
1285
  var TextField = function TextField(props) {
1267
- useContext(SiteContext);
1286
+ var site = useContext(SiteContext);
1268
1287
  var id = props.id,
1269
1288
  _props$type = props.type,
1270
1289
  type = _props$type === void 0 ? 'text' : _props$type,
@@ -1309,7 +1328,7 @@ var TextField = function TextField(props) {
1309
1328
  var labelPositionStyle = labelPosition == 'left' ? "label-left" : "label-top";
1310
1329
  var style = labelStyle + " " + labelPositionStyle + " " + borderStyle + " textfield-" + type;
1311
1330
  var labelTxt = /*#__PURE__*/React.createElement(Text, null, label);
1312
- var placeholderTxt = placeholder ? /*#__PURE__*/React.createElement(Text, null, placeholder) : null;
1331
+ var placeholderTxt = site.translate ? site.translate(placeholder) : placeholder;
1313
1332
  return /*#__PURE__*/React.createElement("div", {
1314
1333
  className: style + " " + id,
1315
1334
  onClick: onClick
@@ -1380,7 +1399,7 @@ var TextArea = function TextArea(props) {
1380
1399
  var labelStyle = label ? "" : "no-label";
1381
1400
  var style = "textarea " + labelStyle + " textarea-" + type;
1382
1401
  var labelTxt = /*#__PURE__*/React.createElement(Text, null, label);
1383
- var placeholderTxt = /*#__PURE__*/React.createElement(Text, null, placeholder);
1402
+ var placeholderTxt = site.translate ? site.translate(placeholder) : placeholder;
1384
1403
  return /*#__PURE__*/React.createElement("div", {
1385
1404
  className: "" + style,
1386
1405
  onClick: onClick
@@ -3769,6 +3788,12 @@ var SiteProvider = function SiteProvider(_ref) {
3769
3788
  setLang: setLang,
3770
3789
  dictionary: dictionary,
3771
3790
  setDictionary: setDictionary,
3791
+ translate: function translate(key) {
3792
+ if (!key) return key;
3793
+ if (dictionary === undefined) return key;
3794
+ var term = dictionary[key];
3795
+ return term ? term[lang] : key;
3796
+ },
3772
3797
  sideNav: sideNav,
3773
3798
  setSideNav: setSideNav,
3774
3799
  showNav: showNav,