ywana-core8 0.0.910 → 0.0.912

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.
@@ -3206,14 +3206,70 @@ var WaitScreen = function WaitScreen() {
3206
3206
 
3207
3207
  moment$1.locale('es');
3208
3208
  var moment = extendMoment(moment$1);
3209
+
3210
+ /**
3211
+ * Calendar
3212
+ */
3209
3213
  var Calendar = function Calendar(props) {
3210
3214
  var _props$events = props.events,
3211
3215
  events = _props$events === void 0 ? [] : _props$events,
3212
3216
  children = props.children,
3213
3217
  onChange = props.onChange;
3214
- var _useState = useState(),
3215
- position = _useState[0],
3216
- setPosition = _useState[1];
3218
+ var _useState = useState(props.range || "year"),
3219
+ range = _useState[0],
3220
+ setRange = _useState[1];
3221
+ function onChangeRange(range) {
3222
+ setRange(range);
3223
+ }
3224
+ return /*#__PURE__*/React.createElement("div", {
3225
+ className: "calendar"
3226
+ }, /*#__PURE__*/React.createElement(CalendarRangeControl, {
3227
+ range: range,
3228
+ onChange: onChangeRange
3229
+ }), range === "year" && /*#__PURE__*/React.createElement(YearCalendar, {
3230
+ events: events,
3231
+ onChange: onChange
3232
+ }, children), range === "month" && /*#__PURE__*/React.createElement(MonthCalendar, {
3233
+ events: events,
3234
+ onChange: onChange,
3235
+ onRange: onChangeRange
3236
+ }, children));
3237
+ };
3238
+
3239
+ /**
3240
+ * CalendarRangeControl
3241
+ */
3242
+ var CalendarRangeControl = function CalendarRangeControl(props) {
3243
+ var range = props.range,
3244
+ onChange = props.onChange;
3245
+ return /*#__PURE__*/React.createElement("div", {
3246
+ className: "calendar-range-control"
3247
+ }, /*#__PURE__*/React.createElement(Button, {
3248
+ label: "Year",
3249
+ outlined: range == "year",
3250
+ action: function action() {
3251
+ return onChange("year");
3252
+ }
3253
+ }), /*#__PURE__*/React.createElement(Button, {
3254
+ label: "Month",
3255
+ outlined: range == "month",
3256
+ action: function action() {
3257
+ return onChange("month");
3258
+ }
3259
+ }));
3260
+ };
3261
+
3262
+ /**
3263
+ * MonthCalendar
3264
+ */
3265
+ var MonthCalendar = function MonthCalendar(props) {
3266
+ var _props$events2 = props.events,
3267
+ events = _props$events2 === void 0 ? [] : _props$events2,
3268
+ children = props.children,
3269
+ onChange = props.onChange;
3270
+ var _useState2 = useState(),
3271
+ position = _useState2[0],
3272
+ setPosition = _useState2[1];
3217
3273
  useEffect(function () {
3218
3274
  var today = moment();
3219
3275
  setPosition(today);
@@ -3251,17 +3307,18 @@ var Calendar = function Calendar(props) {
3251
3307
  var days = Array.from(range.by('days'));
3252
3308
  var cells = days.map(function (day) {
3253
3309
  var eventsOfDay = events.filter(function (event) {
3254
- console.log(event.date, day.format("YYYY-MM-DD"));
3255
3310
  var eventDay = moment(event.date);
3256
3311
  return eventDay.isSame(day, 'day');
3257
3312
  });
3313
+ var sameMonthStyle = day.isSame(moment(position), 'month') ? '' : 'other-month';
3258
3314
  return {
3259
3315
  day: day,
3260
- events: eventsOfDay
3316
+ events: eventsOfDay,
3317
+ sameMonthStyle: sameMonthStyle
3261
3318
  };
3262
3319
  });
3263
3320
  return /*#__PURE__*/React.createElement("div", {
3264
- className: "calendar"
3321
+ className: "month-calendar"
3265
3322
  }, /*#__PURE__*/React.createElement("nav", null, /*#__PURE__*/React.createElement("label", null, " ", /*#__PURE__*/React.createElement(Text, null, monthName), " ", year), /*#__PURE__*/React.createElement(Button, {
3266
3323
  icon: "chevron_left",
3267
3324
  action: prev
@@ -3298,9 +3355,9 @@ var DayCell = function DayCell(props) {
3298
3355
  cell = _props$cell === void 0 ? [] : _props$cell,
3299
3356
  children = props.children;
3300
3357
  var day = cell.day,
3301
- events = cell.events;
3358
+ events = cell.events,
3359
+ sameMonthStyle = cell.sameMonthStyle;
3302
3360
  var todayStyle = day.isSame(moment(), 'day') ? 'today' : '';
3303
- var sameMonthStyle = day.isSame(moment(), 'month') ? '' : 'other-month';
3304
3361
  return /*#__PURE__*/React.createElement("div", {
3305
3362
  className: "day-cell " + todayStyle + " " + sameMonthStyle
3306
3363
  }, /*#__PURE__*/React.createElement("header", null, day.format("DD")), /*#__PURE__*/React.createElement("main", null, events.map(function (event) {
@@ -3310,6 +3367,10 @@ var DayCell = function DayCell(props) {
3310
3367
  }, children);
3311
3368
  })));
3312
3369
  };
3370
+
3371
+ /**
3372
+ * Event
3373
+ */
3313
3374
  var Event = function Event(props) {
3314
3375
  var event = props.event,
3315
3376
  children = props.children;
@@ -3327,6 +3388,129 @@ var Event = function Event(props) {
3327
3388
  }
3328
3389
  };
3329
3390
 
3391
+ /**
3392
+ * YearCalendar
3393
+ */
3394
+ var YearCalendar = function YearCalendar(props) {
3395
+ var _props$events3 = props.events,
3396
+ events = _props$events3 === void 0 ? [] : _props$events3,
3397
+ children = props.children,
3398
+ onChange = props.onChange;
3399
+ var _useState3 = useState(),
3400
+ position = _useState3[0],
3401
+ setPosition = _useState3[1];
3402
+ useEffect(function () {
3403
+ var today = moment();
3404
+ setPosition(today);
3405
+ }, []);
3406
+ useEffect(function () {
3407
+ if (position && onChange) {
3408
+ var _firstDayOfYear = position.clone().startOf('year');
3409
+ var firstDayOfRange = _firstDayOfYear.clone().startOf('isoweek');
3410
+ var _lastDayOfYear = position.clone().endOf('year');
3411
+ var lastDayOfRange = _lastDayOfYear.clone().endOf('isoweek');
3412
+ var range = moment.range(firstDayOfRange, lastDayOfRange);
3413
+ onChange(position, range);
3414
+ }
3415
+ }, [position]);
3416
+ function next() {
3417
+ var next = position.clone().add(1, 'year');
3418
+ setPosition(next);
3419
+ }
3420
+ function prev() {
3421
+ var prev = position.clone().subtract(1, 'year');
3422
+ setPosition(prev);
3423
+ }
3424
+ function today() {
3425
+ var today = moment();
3426
+ setPosition(today);
3427
+ }
3428
+ if (!position) return "...";
3429
+ var year = position.format("YYYY");
3430
+ var firstDayOfYear = moment(position).startOf('year');
3431
+ var lastDayOfYear = moment(position).endOf('year');
3432
+ var months = [];
3433
+ for (var currentMonth = moment(firstDayOfYear); currentMonth.isBefore(lastDayOfYear); currentMonth.add(1, 'month')) {
3434
+ months.push(moment(currentMonth));
3435
+ }
3436
+ var cells = months.map(function (month) {
3437
+ var firstDayOfMonth = month.clone().startOf('month');
3438
+ var firstDayOfRange = firstDayOfMonth.clone().startOf('isoweek');
3439
+ var lastDayOfMonth = month.clone().endOf('month');
3440
+ var lastDayOfRange = lastDayOfMonth.clone().endOf('isoweek');
3441
+ var range = moment.range(firstDayOfRange, lastDayOfRange);
3442
+ var days = Array.from(range.by('days'));
3443
+ var cells = days.map(function (day) {
3444
+ var eventsOfDay = events.filter(function (event) {
3445
+ var eventDay = moment(event.date);
3446
+ return eventDay.isSame(day, 'day');
3447
+ });
3448
+ var sameMonthStyle = day.isSame(moment(month), 'month') ? '' : 'other-month';
3449
+ return {
3450
+ day: day,
3451
+ events: eventsOfDay,
3452
+ sameMonthStyle: sameMonthStyle
3453
+ };
3454
+ });
3455
+ return {
3456
+ month: month,
3457
+ cells: cells
3458
+ };
3459
+ });
3460
+ return /*#__PURE__*/React.createElement("div", {
3461
+ className: "year-calendar"
3462
+ }, /*#__PURE__*/React.createElement("nav", null, /*#__PURE__*/React.createElement("label", null, " ", /*#__PURE__*/React.createElement(Text, null, year)), /*#__PURE__*/React.createElement(Button, {
3463
+ icon: "chevron_left",
3464
+ action: prev
3465
+ }), /*#__PURE__*/React.createElement(Button, {
3466
+ label: "Today",
3467
+ outlined: true,
3468
+ action: today
3469
+ }), /*#__PURE__*/React.createElement(Button, {
3470
+ icon: "chevron_right",
3471
+ action: next
3472
+ })), /*#__PURE__*/React.createElement("main", null, cells.map(function (cell) {
3473
+ return /*#__PURE__*/React.createElement(MonthCell, {
3474
+ key: cell.month,
3475
+ cell: cell
3476
+ }, children);
3477
+ })));
3478
+ };
3479
+
3480
+ /**
3481
+ * MonthCell
3482
+ */
3483
+ var MonthCell = function MonthCell(props) {
3484
+ var _props$cell2 = props.cell,
3485
+ cell = _props$cell2 === void 0 ? [] : _props$cell2,
3486
+ children = props.children;
3487
+ var month = cell.month,
3488
+ cells = cell.cells;
3489
+ var monthName = month.format("MMMM");
3490
+ return /*#__PURE__*/React.createElement("div", {
3491
+ className: "month-cell"
3492
+ }, /*#__PURE__*/React.createElement("nav", null, monthName), /*#__PURE__*/React.createElement("header", null, /*#__PURE__*/React.createElement("div", {
3493
+ className: "week-day-cell"
3494
+ }, /*#__PURE__*/React.createElement(Text, null, "Mon")), /*#__PURE__*/React.createElement("div", {
3495
+ className: "week-day-cell"
3496
+ }, /*#__PURE__*/React.createElement(Text, null, "Tue")), /*#__PURE__*/React.createElement("div", {
3497
+ className: "week-day-cell"
3498
+ }, /*#__PURE__*/React.createElement(Text, null, "Wed")), /*#__PURE__*/React.createElement("div", {
3499
+ className: "week-day-cell"
3500
+ }, /*#__PURE__*/React.createElement(Text, null, "Thu")), /*#__PURE__*/React.createElement("div", {
3501
+ className: "week-day-cell"
3502
+ }, /*#__PURE__*/React.createElement(Text, null, "Fri")), /*#__PURE__*/React.createElement("div", {
3503
+ className: "week-day-cell"
3504
+ }, /*#__PURE__*/React.createElement(Text, null, "Sat")), /*#__PURE__*/React.createElement("div", {
3505
+ className: "week-day-cell"
3506
+ }, /*#__PURE__*/React.createElement(Text, null, "Sun"))), /*#__PURE__*/React.createElement("main", null, cells.map(function (cell) {
3507
+ return /*#__PURE__*/React.createElement(DayCell, {
3508
+ key: cell.day,
3509
+ cell: cell
3510
+ }, children);
3511
+ })));
3512
+ };
3513
+
3330
3514
  var ranges = extendMoment(moment$1);
3331
3515
  var DATE_RANGE = [{
3332
3516
  label: "Week",
@@ -6812,7 +6996,7 @@ var EditContentDialog = function EditContentDialog(_ref) {
6812
6996
  /**
6813
6997
  * Collection API
6814
6998
  */
6815
- var CollectionAPI$1 = function CollectionAPI(url, host) {
6999
+ var CollectionAPI$1 = function CollectionAPI(url, host, params) {
6816
7000
  var http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
6817
7001
 
6818
7002
  /**
@@ -6837,8 +7021,8 @@ var CollectionAPI$1 = function CollectionAPI(url, host) {
6837
7021
  }).join("&");
6838
7022
  return "" + query + values + "&";
6839
7023
  } else if (typeof value === "object") {
6840
- var params = objectToQueryParamString(value, likes);
6841
- params.split("&").forEach(function (param) {
7024
+ var _params = objectToQueryParamString(value, likes);
7025
+ _params.split("&").forEach(function (param) {
6842
7026
  query = query.concat(key + "." + param + "&");
6843
7027
  });
6844
7028
  return query;
@@ -6853,9 +7037,17 @@ var CollectionAPI$1 = function CollectionAPI(url, host) {
6853
7037
  if (likes === void 0) {
6854
7038
  likes = [];
6855
7039
  }
7040
+ // build query params
6856
7041
  var queryParams = page ? "?page=" + page + "&" : "?";
7042
+
7043
+ // concat optional params to queryparams
7044
+ queryParams = "" + queryParams + params;
7045
+
7046
+ // concat filters to queryparams
6857
7047
  var filterQuery = objectToQueryParamString(filters, likes);
6858
7048
  queryParams = "" + queryParams + filterQuery;
7049
+
7050
+ // remove last &
6859
7051
  queryParams = queryParams.substring(0, queryParams.length - 1);
6860
7052
  return http.GET("" + url + queryParams);
6861
7053
  },
@@ -6935,6 +7127,7 @@ var CollectionPage$1 = function CollectionPage(props) {
6935
7127
  page = props.page,
6936
7128
  _props$fetching = props.fetching,
6937
7129
  fetching = _props$fetching === void 0 ? false : _props$fetching,
7130
+ params = props.params,
6938
7131
  _props$actions = props.actions,
6939
7132
  actions = _props$actions === void 0 ? [] : _props$actions,
6940
7133
  onSelect = props.onSelect,
@@ -6969,7 +7162,7 @@ var CollectionPage$1 = function CollectionPage(props) {
6969
7162
  filters = props.filters,
6970
7163
  footer = props.footer,
6971
7164
  children = props.children;
6972
- var context = CollectionContext$1(url, field, host, page, fetching, versioning);
7165
+ var context = CollectionContext$1(url, field, host, page, fetching, versioning, params);
6973
7166
  var _useContext = useContext(PageContext),
6974
7167
  pageContext = _useContext[0],
6975
7168
  setPageContext = _useContext[1];
@@ -7522,11 +7715,11 @@ var CollectionEditor$1 = function CollectionEditor(props) {
7522
7715
  /**
7523
7716
  * Collection Context
7524
7717
  */
7525
- var CollectionContext$1 = function CollectionContext(url, field, host, page, fetching, versioning) {
7718
+ var CollectionContext$1 = function CollectionContext(url, field, host, page, fetching, versioning, params) {
7526
7719
  if (versioning === void 0) {
7527
7720
  versioning = false;
7528
7721
  }
7529
- var API = CollectionAPI$1(url, host);
7722
+ var API = CollectionAPI$1(url, host, params);
7530
7723
  return {
7531
7724
  all: [],
7532
7725
  filters: {},
@@ -11306,5 +11499,5 @@ var isFunction = function isFunction(value) {
11306
11499
  return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
11307
11500
  };
11308
11501
 
11309
- export { Accordion, ActionButton, Avatar, Button, Calendar, CheckBox, Chip, Chips, CircularProgress, CollectionAPI$1 as CollectionAPI, CollectionAPI as CollectionAPI2, CollectionContext$1 as CollectionContext, CollectionContext as CollectionContext2, CollectionEditor$2 as CollectionEditor, CollectionFilters$1 as CollectionFilters, CollectionPage$1 as CollectionPage, CollectionPage as CollectionPage2, CollectionTree, ColorField, Content, ContentEditor, ContentForm, ContentViewer, CreateContentDialog, DataTable, DateRange, Dialog, DropDown, DynamicForm, EditContentDialog, EmptyMessage, FORMATS$1 as FORMATS, FieldEditor, FileExplorer, FileExplorerView, FileGridItem, FilesGridView, FilesSearchBox, FilesTableView, FoldersTreeView, Form, HTTPClient, Header, Icon, ImageViewer, Kanban, KanbanCard, KanbanColumn, KanbanHeader, KanbanSwimlane, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, MultiSelector, Page, PageContext, PageProvider, PasswordEditor, PasswordField, Planner, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, Switch2, TASK_STATES, TEXTFORMATS, TYPES$1 as TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$2 as TableEditor, TablePage, TablePage2, Tabs, TaskContext, TaskContextProvider, TaskMonitor, TaskProgress, Text, TextArea, TextField, Thumbnail, ToggleButton, TokenField, Tooltip, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadDialog, UploadFile$1 as UploadFile, UploadForm, UploadIcon, Uploader, View, Viewer, WaitScreen, Wizard, WizardContext, isEmpty, isFunction };
11502
+ export { Accordion, ActionButton, Avatar, Button, Calendar, CheckBox, Chip, Chips, CircularProgress, CollectionAPI$1 as CollectionAPI, CollectionAPI as CollectionAPI2, CollectionContext$1 as CollectionContext, CollectionContext as CollectionContext2, CollectionEditor$2 as CollectionEditor, CollectionFilters$1 as CollectionFilters, CollectionPage$1 as CollectionPage, CollectionPage as CollectionPage2, CollectionTree, ColorField, Content, ContentEditor, ContentForm, ContentViewer, CreateContentDialog, DataTable, DateRange, Dialog, DropDown, DynamicForm, EditContentDialog, EmptyMessage, FORMATS$1 as FORMATS, FieldEditor, FileExplorer, FileExplorerView, FileGridItem, FilesGridView, FilesSearchBox, FilesTableView, FoldersTreeView, Form, HTTPClient, Header, Icon, ImageViewer, Kanban, KanbanCard, KanbanColumn, KanbanHeader, KanbanSwimlane, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, MonthCalendar, MultiSelector, Page, PageContext, PageProvider, PasswordEditor, PasswordField, Planner, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, Switch2, TASK_STATES, TEXTFORMATS, TYPES$1 as TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$2 as TableEditor, TablePage, TablePage2, Tabs, TaskContext, TaskContextProvider, TaskMonitor, TaskProgress, Text, TextArea, TextField, Thumbnail, ToggleButton, TokenField, Tooltip, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadDialog, UploadFile$1 as UploadFile, UploadForm, UploadIcon, Uploader, View, Viewer, WaitScreen, Wizard, WizardContext, isEmpty, isFunction };
11310
11503
  //# sourceMappingURL=index.modern.js.map