@bpmn-io/form-js-viewer 0.10.0-alpha.2 → 0.10.0

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.
Files changed (27) hide show
  1. package/README.md +1 -0
  2. package/dist/assets/flatpickr/light.css +809 -0
  3. package/dist/assets/form-js.css +148 -26
  4. package/dist/index.cjs +1442 -320
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.es.js +1424 -323
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/types/render/components/Util.d.ts +0 -2
  9. package/dist/types/render/components/form-fields/Checklist.d.ts +1 -1
  10. package/dist/types/render/components/form-fields/Datetime.d.ts +11 -0
  11. package/dist/types/render/components/form-fields/Radio.d.ts +1 -1
  12. package/dist/types/render/components/form-fields/Select.d.ts +1 -1
  13. package/dist/types/render/components/form-fields/Taglist.d.ts +1 -1
  14. package/dist/types/render/components/form-fields/parts/Datepicker.d.ts +1 -0
  15. package/dist/types/render/components/form-fields/parts/InputAdorner.d.ts +1 -0
  16. package/dist/types/render/components/form-fields/parts/Timepicker.d.ts +1 -0
  17. package/dist/types/render/components/icons/index.d.ts +16 -0
  18. package/dist/types/render/components/index.d.ts +3 -1
  19. package/dist/types/render/components/util/dateTimeUtil.d.ts +12 -0
  20. package/dist/types/render/components/util/numberFieldUtil.d.ts +1 -1
  21. package/dist/types/render/components/util/sanitizerUtil.d.ts +3 -0
  22. package/dist/types/util/constants/DatetimeConstants.d.ts +24 -0
  23. package/dist/types/util/constants/ValuesSourceConstants.d.ts +15 -0
  24. package/dist/types/util/constants/index.d.ts +2 -0
  25. package/dist/types/util/feel.d.ts +1 -0
  26. package/dist/types/util/index.d.ts +1 -0
  27. package/package.json +4 -2
package/dist/index.es.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import Ids from 'ids';
2
- import { isString, isArray, isFunction, isNumber, bind, assign, isNil, get, isUndefined, isObject, set } from 'min-dash';
2
+ import { isString, isArray, isFunction, isNumber, bind, assign, isNil, get, isUndefined, set, isObject } from 'min-dash';
3
3
  import { unaryTest, evaluate, parseUnaryTests, parseExpressions } from 'feelin';
4
4
  import Big from 'big.js';
5
5
  import snarkdown from '@bpmn-io/snarkdown';
6
6
  import classNames from 'classnames';
7
7
  import { jsx, jsxs } from 'preact/jsx-runtime';
8
- import { useContext, useState, useEffect, useRef, useMemo, useCallback } from 'preact/hooks';
8
+ import { useContext, useState, useEffect, useRef, useCallback, useMemo } from 'preact/hooks';
9
9
  import { createContext, createElement, Fragment, render } from 'preact';
10
10
  import React, { createPortal } from 'preact/compat';
11
+ import flatpickr from 'flatpickr';
11
12
  import Markup from 'preact-markup';
12
13
  import { Injector } from 'didi';
13
14
 
@@ -572,16 +573,16 @@ function countDecimals(number) {
572
573
  function isValidNumber(value) {
573
574
  return (typeof value === 'number' || typeof value === 'string') && value !== '' && !isNaN(Number(value));
574
575
  }
575
- function willKeyProduceValidNumber(key, previousValue, carretIndex, selectionWidth, decimalDigits) {
576
+ function willKeyProduceValidNumber(key, previousValue, caretIndex, selectionWidth, decimalDigits) {
576
577
  // Dot and comma are both treated as dot
577
578
  previousValue = previousValue.replace(',', '.');
578
579
  const isFirstDot = !previousValue.includes('.') && (key === '.' || key === ',');
579
- const isFirstMinus = !previousValue.includes('-') && key === '-' && carretIndex === 0;
580
+ const isFirstMinus = !previousValue.includes('-') && key === '-' && caretIndex === 0;
580
581
  const keypressIsNumeric = /^[0-9]$/i.test(key);
581
- const dotIndex = previousValue?.indexOf('.') ?? -1;
582
+ const dotIndex = previousValue === undefined ? -1 : previousValue.indexOf('.');
582
583
 
583
- // If the carret is positioned after a dot, and the current decimal digits count is equal or greater to the maximum, disallow the key press
584
- const overflowsDecimalSpace = typeof decimalDigits === 'number' && selectionWidth === 0 && dotIndex !== -1 && previousValue.includes('.') && previousValue.split('.')[1].length >= decimalDigits && carretIndex > dotIndex;
584
+ // If the caret is positioned after a dot, and the current decimal digits count is equal or greater to the maximum, disallow the key press
585
+ const overflowsDecimalSpace = typeof decimalDigits === 'number' && selectionWidth === 0 && dotIndex !== -1 && previousValue.includes('.') && previousValue.split('.')[1].length >= decimalDigits && caretIndex > dotIndex;
585
586
  const keypressIsAllowedChar = keypressIsNumeric || decimalDigits !== 0 && isFirstDot || isFirstMinus;
586
587
  return keypressIsAllowedChar && !overflowsDecimalSpace;
587
588
  }
@@ -739,6 +740,71 @@ function getExpressionVariableNames(expression) {
739
740
  } while (cursor.next());
740
741
  return Array.from(variables);
741
742
  }
743
+ function isExpression$2(value) {
744
+ return isString(value) && value.startsWith('=');
745
+ }
746
+
747
+ // config ///////////////////
748
+
749
+ const MINUTES_IN_DAY = 60 * 24;
750
+ const DATETIME_SUBTYPES = {
751
+ DATE: 'date',
752
+ TIME: 'time',
753
+ DATETIME: 'datetime'
754
+ };
755
+ const TIME_SERIALISING_FORMATS = {
756
+ UTC_OFFSET: 'utc_offset',
757
+ UTC_NORMALIZED: 'utc_normalized',
758
+ NO_TIMEZONE: 'no_timezone'
759
+ };
760
+ const DATETIME_SUBTYPES_LABELS = {
761
+ [DATETIME_SUBTYPES.DATE]: 'Date',
762
+ [DATETIME_SUBTYPES.TIME]: 'Time',
763
+ [DATETIME_SUBTYPES.DATETIME]: 'Date & Time'
764
+ };
765
+ const TIME_SERIALISINGFORMAT_LABELS = {
766
+ [TIME_SERIALISING_FORMATS.UTC_OFFSET]: 'UTC offset',
767
+ [TIME_SERIALISING_FORMATS.UTC_NORMALIZED]: 'UTC normalized',
768
+ [TIME_SERIALISING_FORMATS.NO_TIMEZONE]: 'No timezone'
769
+ };
770
+ const DATETIME_SUBTYPE_PATH = ['subtype'];
771
+ const DATE_LABEL_PATH = ['dateLabel'];
772
+ const DATE_DISALLOW_PAST_PATH = ['disallowPassedDates'];
773
+ const TIME_LABEL_PATH = ['timeLabel'];
774
+ const TIME_USE24H_PATH = ['use24h'];
775
+ const TIME_INTERVAL_PATH = ['timeInterval'];
776
+ const TIME_SERIALISING_FORMAT_PATH = ['timeSerializingFormat'];
777
+
778
+ // config ///////////////////
779
+
780
+ const VALUES_SOURCES = {
781
+ STATIC: 'static',
782
+ INPUT: 'input'
783
+ };
784
+ const VALUES_SOURCE_DEFAULT = VALUES_SOURCES.STATIC;
785
+ const VALUES_SOURCES_LABELS = {
786
+ [VALUES_SOURCES.STATIC]: 'Static',
787
+ [VALUES_SOURCES.INPUT]: 'Input data'
788
+ };
789
+ const VALUES_SOURCES_PATHS = {
790
+ [VALUES_SOURCES.STATIC]: ['values'],
791
+ [VALUES_SOURCES.INPUT]: ['valuesKey']
792
+ };
793
+ const VALUES_SOURCES_DEFAULTS = {
794
+ [VALUES_SOURCES.STATIC]: [],
795
+ [VALUES_SOURCES.INPUT]: ''
796
+ };
797
+
798
+ // helpers ///////////////////
799
+
800
+ function getValuesSource(field) {
801
+ for (const source of Object.values(VALUES_SOURCES)) {
802
+ if (get(field, VALUES_SOURCES_PATHS[source]) !== undefined) {
803
+ return source;
804
+ }
805
+ }
806
+ return VALUES_SOURCE_DEFAULT;
807
+ }
742
808
 
743
809
  function createInjector(bootstrapModules) {
744
810
  const injector = new Injector(bootstrapModules);
@@ -757,7 +823,7 @@ function createFormContainer(prefix = 'fjs') {
757
823
  return container;
758
824
  }
759
825
 
760
- const EXPRESSION_PROPERTIES = ['alt', 'source'];
826
+ const EXPRESSION_PROPERTIES = ['alt', 'source', 'text'];
761
827
  function findErrors(errors, path) {
762
828
  return errors[pathStringify(path)];
763
829
  }
@@ -822,7 +888,7 @@ function getSchemaVariables(schema) {
822
888
  type,
823
889
  conditional
824
890
  } = component;
825
- if (['text', 'button'].includes(type)) {
891
+ if (['button'].includes(type)) {
826
892
  return variables;
827
893
  }
828
894
  if (key) {
@@ -995,7 +1061,7 @@ var importModule = {
995
1061
 
996
1062
  const NODE_TYPE_TEXT = 3,
997
1063
  NODE_TYPE_ELEMENT = 1;
998
- const ALLOWED_NODES = ['h1', 'h2', 'h3', 'h4', 'h5', 'span', 'em', 'a', 'p', 'div', 'ul', 'ol', 'li', 'hr', 'blockquote', 'img', 'pre', 'code', 'br', 'strong'];
1064
+ const ALLOWED_NODES = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'em', 'a', 'p', 'div', 'ul', 'ol', 'li', 'hr', 'blockquote', 'img', 'pre', 'code', 'br', 'strong'];
999
1065
  const ALLOWED_ATTRIBUTES = ['align', 'alt', 'class', 'href', 'id', 'name', 'rel', 'target', 'src'];
1000
1066
  const ALLOWED_URI_PATTERN = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i; // eslint-disable-line no-useless-escape
1001
1067
  const ALLOWED_IMAGE_SRC_PATTERN = /^(https?|data):.*/i; // eslint-disable-line no-useless-escape
@@ -1127,7 +1193,7 @@ function prefixId(id, formId) {
1127
1193
  return `fjs-form-${id}`;
1128
1194
  }
1129
1195
  function markdownToHTML(markdown) {
1130
- const htmls = markdown.split(/(?:\r?\n){2,}/).map(line => /^((\d+.)|[><\s#-*])/.test(line) ? snarkdown(line) : `<p>${snarkdown(line)}</p>`);
1196
+ const htmls = markdown.toString().split(/(?:\r?\n){2,}/).map(line => /^((\d+.)|[><\s#-*])/.test(line) ? snarkdown(line) : `<p>${snarkdown(line)}</p>`);
1131
1197
  return htmls.join('\n\n');
1132
1198
  }
1133
1199
 
@@ -1149,46 +1215,8 @@ function safeMarkdown(markdown) {
1149
1215
  function safeImageSource(src) {
1150
1216
  return sanitizeImageSource(src);
1151
1217
  }
1152
- function sanitizeSingleSelectValue(options) {
1153
- const {
1154
- formField,
1155
- data,
1156
- value
1157
- } = options;
1158
- const {
1159
- valuesKey,
1160
- values
1161
- } = formField;
1162
- try {
1163
- const validValues = (valuesKey ? get(data, [valuesKey]) : values).map(v => v.value) || [];
1164
- return validValues.includes(value) ? value : null;
1165
- } catch (error) {
1166
- // use default value in case of formatting error
1167
- // TODO(@Skaiir): log a warning when this happens - https://github.com/bpmn-io/form-js/issues/289
1168
- return null;
1169
- }
1170
- }
1171
- function sanitizeMultiSelectValue(options) {
1172
- const {
1173
- formField,
1174
- data,
1175
- value
1176
- } = options;
1177
- const {
1178
- valuesKey,
1179
- values
1180
- } = formField;
1181
- try {
1182
- const validValues = (valuesKey ? get(data, [valuesKey]) : values).map(v => v.value) || [];
1183
- return value.filter(v => validValues.includes(v));
1184
- } catch (error) {
1185
- // use default value in case of formatting error
1186
- // TODO(@Skaiir): log a warning when this happens - https://github.com/bpmn-io/form-js/issues/289
1187
- return [];
1188
- }
1189
- }
1190
1218
 
1191
- const type$a = 'button';
1219
+ const type$b = 'button';
1192
1220
  function Button(props) {
1193
1221
  const {
1194
1222
  disabled,
@@ -1198,7 +1226,7 @@ function Button(props) {
1198
1226
  action = 'submit'
1199
1227
  } = field;
1200
1228
  return jsx("div", {
1201
- class: formFieldClasses(type$a),
1229
+ class: formFieldClasses(type$b),
1202
1230
  children: jsx("button", {
1203
1231
  class: "fjs-button",
1204
1232
  type: action,
@@ -1213,7 +1241,7 @@ Button.create = function (options = {}) {
1213
1241
  ...options
1214
1242
  };
1215
1243
  };
1216
- Button.type = type$a;
1244
+ Button.type = type$b;
1217
1245
  Button.label = 'Button';
1218
1246
  Button.keyed = true;
1219
1247
 
@@ -1277,11 +1305,14 @@ function Label(props) {
1277
1305
  const {
1278
1306
  id,
1279
1307
  label,
1308
+ collapseOnEmpty = true,
1280
1309
  required = false
1281
1310
  } = props;
1282
1311
  return jsxs("label", {
1283
1312
  for: id,
1284
- class: classNames('fjs-form-field-label', props['class']),
1313
+ class: classNames('fjs-form-field-label', {
1314
+ 'fjs-incollapsible-label': !collapseOnEmpty
1315
+ }, props['class']),
1285
1316
  children: [props.children, label || '', required && jsx("span", {
1286
1317
  class: "fjs-asterix",
1287
1318
  children: "*"
@@ -1289,7 +1320,7 @@ function Label(props) {
1289
1320
  });
1290
1321
  }
1291
1322
 
1292
- const type$9 = 'checkbox';
1323
+ const type$a = 'checkbox';
1293
1324
  function Checkbox(props) {
1294
1325
  const {
1295
1326
  disabled,
@@ -1314,7 +1345,7 @@ function Checkbox(props) {
1314
1345
  formId
1315
1346
  } = useContext(FormContext);
1316
1347
  return jsxs("div", {
1317
- class: classNames(formFieldClasses(type$9, {
1348
+ class: classNames(formFieldClasses(type$a, {
1318
1349
  errors,
1319
1350
  disabled
1320
1351
  }), {
@@ -1344,7 +1375,7 @@ Checkbox.create = function (options = {}) {
1344
1375
  ...options
1345
1376
  };
1346
1377
  };
1347
- Checkbox.type = type$9;
1378
+ Checkbox.type = type$a;
1348
1379
  Checkbox.label = 'Checkbox';
1349
1380
  Checkbox.keyed = true;
1350
1381
  Checkbox.emptyValue = false;
@@ -1419,7 +1450,222 @@ const buildLoadedState = values => ({
1419
1450
  state: LOAD_STATES.LOADED
1420
1451
  });
1421
1452
 
1422
- const type$8 = 'checklist';
1453
+ const ENTER_KEYDOWN_EVENT = new KeyboardEvent('keydown', {
1454
+ code: 'Enter',
1455
+ key: 'Enter',
1456
+ charCode: 13,
1457
+ keyCode: 13,
1458
+ view: window,
1459
+ bubbles: true
1460
+ });
1461
+ function focusRelevantFlatpickerDay(flatpickrInstance) {
1462
+ if (!flatpickrInstance) return;
1463
+ !flatpickrInstance.isOpen && flatpickrInstance.open();
1464
+ const container = flatpickrInstance.calendarContainer;
1465
+ const dayToFocus = container.querySelector('.flatpickr-day.selected') || container.querySelector('.flatpickr-day.today') || container.querySelector('.flatpickr-day');
1466
+ dayToFocus && dayToFocus.focus();
1467
+ }
1468
+ function formatTime(use24h, minutes) {
1469
+ if (minutes === null) return null;
1470
+ const wrappedMinutes = minutes % (24 * 60);
1471
+ const minute = minutes % 60;
1472
+ let hour = Math.floor(wrappedMinutes / 60);
1473
+ if (use24h) {
1474
+ return _getZeroPaddedString(hour) + ':' + _getZeroPaddedString(minute);
1475
+ }
1476
+ hour = hour % 12 || 12;
1477
+ const isPM = wrappedMinutes >= 12 * 60;
1478
+ return _getZeroPaddedString(hour) + ':' + _getZeroPaddedString(minute) + ' ' + (isPM ? 'PM' : 'AM');
1479
+ }
1480
+ function parseInputTime(stringTime) {
1481
+ let workingString = stringTime.toLowerCase();
1482
+ const is12h = workingString.includes('am') || workingString.includes('pm');
1483
+ if (is12h) {
1484
+ const isPM = workingString.includes('pm');
1485
+ const digits = workingString.match(/\d+/g);
1486
+ const displayHour = parseInt(digits?.[0]);
1487
+ const minute = parseInt(digits?.[1]) || 0;
1488
+ const isValidDisplayHour = isNumber(displayHour) && displayHour >= 1 && displayHour <= 12;
1489
+ const isValidMinute = minute >= 0 && minute <= 59;
1490
+ if (!isValidDisplayHour || !isValidMinute) return null;
1491
+ const hour = displayHour % 12 + (isPM ? 12 : 0);
1492
+ return hour * 60 + minute;
1493
+ } else {
1494
+ const digits = workingString.match(/\d+/g);
1495
+ const hour = parseInt(digits?.[0]);
1496
+ const minute = parseInt(digits?.[1]);
1497
+ const isValidHour = isNumber(hour) && hour >= 0 && hour <= 23;
1498
+ const isValidMinute = isNumber(minute) && minute >= 0 && minute <= 59;
1499
+ if (!isValidHour || !isValidMinute) return null;
1500
+ return hour * 60 + minute;
1501
+ }
1502
+ }
1503
+ function serializeTime(minutes, offset, timeSerializingFormat) {
1504
+ if (timeSerializingFormat === TIME_SERIALISING_FORMATS.UTC_NORMALIZED) {
1505
+ const normalizedMinutes = (minutes + offset + MINUTES_IN_DAY) % MINUTES_IN_DAY;
1506
+ return _getZeroPaddedString(Math.floor(normalizedMinutes / 60)) + ':' + _getZeroPaddedString(normalizedMinutes % 60) + 'Z';
1507
+ }
1508
+ const baseTime = _getZeroPaddedString(Math.floor(minutes / 60)) + ':' + _getZeroPaddedString(minutes % 60);
1509
+ const addUTCOffset = timeSerializingFormat === TIME_SERIALISING_FORMATS.UTC_OFFSET;
1510
+ return baseTime + (addUTCOffset ? formatTimezoneOffset(offset) : '');
1511
+ }
1512
+ function parseIsoTime(isoTimeString) {
1513
+ if (!isoTimeString) return null;
1514
+ const parseBasicMinutes = timeString => {
1515
+ const timeSegments = timeString.split(':');
1516
+ const hour = parseInt(timeSegments[0]);
1517
+ const minute = timeSegments.length > 1 ? parseInt(timeSegments[1]) : 0;
1518
+ if (isNaN(hour) || hour < 0 || hour > 24 || isNaN(minute) || minute < 0 || minute > 60) return null;
1519
+ return hour * 60 + minute;
1520
+ };
1521
+ const localOffset = new Date().getTimezoneOffset();
1522
+
1523
+ // Parse normalized time
1524
+ if (isoTimeString.includes('Z')) {
1525
+ isoTimeString = isoTimeString.replace('Z', '');
1526
+ const minutes = parseBasicMinutes(isoTimeString);
1527
+ if (minutes === null) return null;
1528
+ return (minutes - localOffset + MINUTES_IN_DAY) % MINUTES_IN_DAY;
1529
+ }
1530
+
1531
+ // Parse offset positive time
1532
+ else if (isoTimeString.includes('+')) {
1533
+ const [timeString, offsetString] = isoTimeString.split('+');
1534
+ const minutes = parseBasicMinutes(timeString);
1535
+ let inboundOffset = parseBasicMinutes(offsetString);
1536
+ if (minutes === null || inboundOffset === null) return null;
1537
+
1538
+ // The offset is flipped for consistency with javascript
1539
+ inboundOffset = -inboundOffset;
1540
+ return (minutes + inboundOffset - localOffset + MINUTES_IN_DAY) % MINUTES_IN_DAY;
1541
+ }
1542
+
1543
+ // Parse offset negative time
1544
+ else if (isoTimeString.includes('-')) {
1545
+ const [timeString, offsetString] = isoTimeString.split('-');
1546
+ const minutes = parseBasicMinutes(timeString);
1547
+ let inboundOffset = parseBasicMinutes(offsetString);
1548
+ if (minutes === null || inboundOffset === null) return null;
1549
+ return (minutes + inboundOffset - localOffset + MINUTES_IN_DAY) % MINUTES_IN_DAY;
1550
+ }
1551
+
1552
+ // Default to local parsing
1553
+ else {
1554
+ return parseBasicMinutes(isoTimeString);
1555
+ }
1556
+ }
1557
+ function serializeDate(date) {
1558
+ var d = new Date(date),
1559
+ month = '' + (d.getMonth() + 1),
1560
+ day = '' + d.getDate(),
1561
+ year = d.getFullYear();
1562
+ if (month.length < 2) month = '0' + month;
1563
+ if (day.length < 2) day = '0' + day;
1564
+ return [year, month, day].join('-');
1565
+ }
1566
+
1567
+ // this method is used to make the `new Date(value)` parsing behavior stricter
1568
+ function isDateTimeInputInformationSufficient(value) {
1569
+ if (!value || typeof value !== 'string') return false;
1570
+ const segments = value.split('T');
1571
+ if (segments.length != 2) return false;
1572
+ const dateNumbers = segments[0].split('-');
1573
+ if (dateNumbers.length != 3) return false;
1574
+ return true;
1575
+ }
1576
+
1577
+ // this method checks if the date isn't a datetime, or a partial date
1578
+ function isDateInputInformationMatching(value) {
1579
+ if (!value || typeof value !== 'string') return false;
1580
+ if (value.includes('T')) return false;
1581
+ const dateNumbers = value.split('-');
1582
+ if (dateNumbers.length != 3) return false;
1583
+ return true;
1584
+ }
1585
+ function serializeDateTime(date, time, timeSerializingFormat) {
1586
+ const workingDate = new Date();
1587
+ workingDate.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
1588
+ workingDate.setHours(Math.floor(time / 60), time % 60, 0, 0);
1589
+ if (timeSerializingFormat === TIME_SERIALISING_FORMATS.UTC_NORMALIZED) {
1590
+ const timezoneOffsetMinutes = workingDate.getTimezoneOffset();
1591
+ const dayOffset = time + timezoneOffsetMinutes < 0 ? -1 : time + timezoneOffsetMinutes > MINUTES_IN_DAY ? 1 : 0;
1592
+
1593
+ // Apply the date rollover pre-emptively
1594
+ workingDate.setHours(workingDate.getHours() + dayOffset * 24);
1595
+ }
1596
+ return serializeDate(workingDate) + 'T' + serializeTime(time, workingDate.getTimezoneOffset(), timeSerializingFormat);
1597
+ }
1598
+ function formatTimezoneOffset(minutes) {
1599
+ return _getSignedPaddedHours(minutes) + ':' + _getZeroPaddedString(Math.abs(minutes % 60));
1600
+ }
1601
+ function isInvalidDateString(value) {
1602
+ return isNaN(new Date(Date.parse(value)).getTime());
1603
+ }
1604
+ function _getSignedPaddedHours(minutes) {
1605
+ if (minutes > 0) {
1606
+ return '-' + _getZeroPaddedString(Math.floor(minutes / 60));
1607
+ } else {
1608
+ return '+' + _getZeroPaddedString(Math.floor((0 - minutes) / 60));
1609
+ }
1610
+ }
1611
+ function _getZeroPaddedString(time) {
1612
+ return time.toString().padStart(2, '0');
1613
+ }
1614
+
1615
+ function sanitizeDateTimePickerValue(options) {
1616
+ const {
1617
+ formField,
1618
+ value
1619
+ } = options;
1620
+ const {
1621
+ subtype
1622
+ } = formField;
1623
+ if (typeof value !== 'string') return null;
1624
+ if (subtype === DATETIME_SUBTYPES.DATE && (isInvalidDateString(value) || !isDateInputInformationMatching(value))) return null;
1625
+ if (subtype === DATETIME_SUBTYPES.TIME && parseIsoTime(value) === null) return null;
1626
+ if (subtype === DATETIME_SUBTYPES.DATETIME && (isInvalidDateString(value) || !isDateTimeInputInformationSufficient(value))) return null;
1627
+ return value;
1628
+ }
1629
+ function sanitizeSingleSelectValue(options) {
1630
+ const {
1631
+ formField,
1632
+ data,
1633
+ value
1634
+ } = options;
1635
+ const {
1636
+ valuesKey,
1637
+ values
1638
+ } = formField;
1639
+ try {
1640
+ const validValues = (valuesKey ? get(data, [valuesKey]) : values).map(v => v.value) || [];
1641
+ return validValues.includes(value) ? value : null;
1642
+ } catch (error) {
1643
+ // use default value in case of formatting error
1644
+ // TODO(@Skaiir): log a warning when this happens - https://github.com/bpmn-io/form-js/issues/289
1645
+ return null;
1646
+ }
1647
+ }
1648
+ function sanitizeMultiSelectValue(options) {
1649
+ const {
1650
+ formField,
1651
+ data,
1652
+ value
1653
+ } = options;
1654
+ const {
1655
+ valuesKey,
1656
+ values
1657
+ } = formField;
1658
+ try {
1659
+ const validValues = (valuesKey ? get(data, [valuesKey]) : values).map(v => v.value) || [];
1660
+ return value.filter(v => validValues.includes(v));
1661
+ } catch (error) {
1662
+ // use default value in case of formatting error
1663
+ // TODO(@Skaiir): log a warning when this happens - https://github.com/bpmn-io/form-js/issues/289
1664
+ return [];
1665
+ }
1666
+ }
1667
+
1668
+ const type$9 = 'checklist';
1423
1669
  function Checklist(props) {
1424
1670
  const {
1425
1671
  disabled,
@@ -1452,7 +1698,7 @@ function Checklist(props) {
1452
1698
  formId
1453
1699
  } = useContext(FormContext);
1454
1700
  return jsxs("div", {
1455
- class: classNames(formFieldClasses(type$8, {
1701
+ class: classNames(formFieldClasses(type$9, {
1456
1702
  errors,
1457
1703
  disabled
1458
1704
  })),
@@ -1492,7 +1738,7 @@ Checklist.create = function (options = {}) {
1492
1738
  ...options
1493
1739
  };
1494
1740
  };
1495
- Checklist.type = type$8;
1741
+ Checklist.type = type$9;
1496
1742
  Checklist.label = 'Checklist';
1497
1743
  Checklist.keyed = true;
1498
1744
  Checklist.emptyValue = [];
@@ -1507,11 +1753,18 @@ Checklist.sanitizeValue = sanitizeMultiSelectValue;
1507
1753
  * @returns {boolean} true if condition is met or no condition or condition checker exists
1508
1754
  */
1509
1755
  function useCondition(condition, data) {
1756
+ const initialData = useService('form')._getState().initialData;
1510
1757
  const conditionChecker = useService('conditionChecker', false);
1511
1758
  if (!conditionChecker) {
1512
1759
  return null;
1513
1760
  }
1514
- return conditionChecker.check(condition, data);
1761
+
1762
+ // make sure we do not use data from hidden fields
1763
+ const filteredData = {
1764
+ ...initialData,
1765
+ ...conditionChecker.applyConditions(data, data)
1766
+ };
1767
+ return conditionChecker.check(condition, filteredData);
1515
1768
  }
1516
1769
 
1517
1770
  const noop$1 = () => false;
@@ -1593,115 +1846,771 @@ Default.create = function (options = {}) {
1593
1846
  Default.type = 'default';
1594
1847
  Default.keyed = false;
1595
1848
 
1596
- /**
1597
- * This file must not be changed or exchanged.
1598
- *
1599
- * @see http://bpmn.io/license for more information.
1600
- */
1601
- function Logo() {
1602
- return jsxs("svg", {
1603
- xmlns: "http://www.w3.org/2000/svg",
1604
- viewBox: "0 0 14.02 5.57",
1605
- width: "53",
1606
- height: "21",
1607
- style: "vertical-align:middle",
1608
- children: [jsx("path", {
1609
- fill: "currentColor",
1610
- d: "M1.88.92v.14c0 .41-.13.68-.4.8.33.14.46.44.46.86v.33c0 .61-.33.95-.95.95H0V0h.95c.65 0 .93.3.93.92zM.63.57v1.06h.24c.24 0 .38-.1.38-.43V.98c0-.28-.1-.4-.32-.4zm0 1.63v1.22h.36c.2 0 .32-.1.32-.39v-.35c0-.37-.12-.48-.4-.48H.63zM4.18.99v.52c0 .64-.31.98-.94.98h-.3V4h-.62V0h.92c.63 0 .94.35.94.99zM2.94.57v1.35h.3c.2 0 .3-.09.3-.37v-.6c0-.29-.1-.38-.3-.38h-.3zm2.89 2.27L6.25 0h.88v4h-.6V1.12L6.1 3.99h-.6l-.46-2.82v2.82h-.55V0h.87zM8.14 1.1V4h-.56V0h.79L9 2.4V0h.56v4h-.64zm2.49 2.29v.6h-.6v-.6zM12.12 1c0-.63.33-1 .95-1 .61 0 .95.37.95 1v2.04c0 .64-.34 1-.95 1-.62 0-.95-.37-.95-1zm.62 2.08c0 .28.13.39.33.39s.32-.1.32-.4V.98c0-.29-.12-.4-.32-.4s-.33.11-.33.4z"
1611
- }), jsx("path", {
1612
- fill: "currentColor",
1613
- d: "M0 4.53h14.02v1.04H0zM11.08 0h.63v.62h-.63zm.63 4V1h-.63v2.98z"
1614
- })]
1615
- });
1616
- }
1617
- function Lightbox(props) {
1849
+ function _extends$h() { _extends$h = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$h.apply(this, arguments); }
1850
+ var CalendarIcon = (({
1851
+ styles = {},
1852
+ ...props
1853
+ }) => /*#__PURE__*/React.createElement("svg", _extends$h({
1854
+ width: "14",
1855
+ height: "15",
1856
+ viewBox: "0 0 28 30",
1857
+ fill: "none",
1858
+ xmlns: "http://www.w3.org/2000/svg"
1859
+ }, props), /*#__PURE__*/React.createElement("path", {
1860
+ fillRule: "evenodd",
1861
+ clipRule: "evenodd",
1862
+ d: "M19 2H9V0H7v2H2a2 2 0 00-2 2v24a2 2 0 002 2h24a2 2 0 002-2V4a2 2 0 00-2-2h-5V0h-2v2zM7 7V4H2v5h24V4h-5v3h-2V4H9v3H7zm-5 4v17h24V11H2z",
1863
+ fill: "#000"
1864
+ })));
1865
+
1866
+ function InputAdorner(props) {
1618
1867
  const {
1619
- open
1868
+ pre = null,
1869
+ post = null,
1870
+ rootRef,
1871
+ inputRef,
1872
+ children,
1873
+ disabled,
1874
+ hasErrors
1620
1875
  } = props;
1621
- if (!open) {
1622
- return null;
1623
- }
1876
+ const onAdornmentClick = () => inputRef?.current?.focus();
1624
1877
  return jsxs("div", {
1625
- class: "fjs-powered-by-lightbox",
1626
- style: "z-index: 100; position: fixed; top: 0; left: 0;right: 0; bottom: 0",
1627
- children: [jsx("div", {
1628
- class: "backdrop",
1629
- style: "width: 100%; height: 100%; background: rgba(40 40 40 / 20%)",
1630
- onClick: props.onBackdropClick
1631
- }), jsxs("div", {
1632
- class: "notice",
1633
- style: "position: absolute; left: 50%; top: 40%; transform: translate(-50%); width: 260px; padding: 10px; background: white; box-shadow: 0 1px 4px rgba(0 0 0 / 30%); font-family: Helvetica, Arial, sans-serif; font-size: 14px; display: flex; line-height: 1.3",
1634
- children: [jsx("a", {
1635
- href: "https://bpmn.io",
1636
- target: "_blank",
1637
- rel: "noopener",
1638
- style: "margin: 15px 20px 15px 10px; align-self: center; color: #404040",
1639
- children: jsx(Logo, {})
1640
- }), jsxs("span", {
1641
- children: ["Web-based tooling for BPMN, DMN, and forms powered by ", jsx("a", {
1642
- href: "https://bpmn.io",
1643
- target: "_blank",
1644
- rel: "noopener",
1645
- children: "bpmn.io"
1646
- }), "."]
1647
- })]
1648
- })]
1649
- });
1650
- }
1651
- function Link(props) {
1652
- return jsx("div", {
1653
- class: "fjs-powered-by fjs-form-field",
1654
- style: "text-align: right",
1655
- children: jsx("a", {
1656
- href: "https://bpmn.io",
1657
- target: "_blank",
1658
- rel: "noopener",
1659
- class: "fjs-powered-by-link",
1660
- title: "Powered by bpmn.io",
1661
- style: "color: #404040",
1662
- onClick: props.onClick,
1663
- children: jsx(Logo, {})
1664
- })
1665
- });
1666
- }
1667
- function PoweredBy(props) {
1668
- const [open, setOpen] = useState(false);
1669
- function toggleOpen(open) {
1670
- return event => {
1671
- event.preventDefault();
1672
- setOpen(open);
1673
- };
1674
- }
1675
- return jsxs(Fragment, {
1676
- children: [createPortal(jsx(Lightbox, {
1677
- open: open,
1678
- onBackdropClick: toggleOpen(false)
1679
- }), document.body), jsx(Link, {
1680
- onClick: toggleOpen(true)
1878
+ class: classNames('fjs-input-group', {
1879
+ 'disabled': disabled
1880
+ }, {
1881
+ 'hasErrors': hasErrors
1882
+ }),
1883
+ ref: rootRef,
1884
+ children: [pre !== null && jsxs("span", {
1885
+ class: "fjs-input-adornment border-right border-radius-left",
1886
+ onClick: onAdornmentClick,
1887
+ children: [" ", pre, " "]
1888
+ }), children, post !== null && jsxs("span", {
1889
+ class: "fjs-input-adornment border-left border-radius-right",
1890
+ onClick: onAdornmentClick,
1891
+ children: [" ", post, " "]
1681
1892
  })]
1682
1893
  });
1683
1894
  }
1684
1895
 
1685
- const noop = () => {};
1686
- function FormComponent(props) {
1687
- const form = useService('form');
1688
- const {
1689
- schema
1690
- } = form._getState();
1896
+ function Datepicker(props) {
1691
1897
  const {
1692
- onSubmit = noop,
1693
- onReset = noop,
1694
- onChange = noop
1898
+ id,
1899
+ label,
1900
+ collapseLabelOnEmpty,
1901
+ formId,
1902
+ required,
1903
+ disabled,
1904
+ disallowPassedDates,
1905
+ date,
1906
+ setDate
1695
1907
  } = props;
1696
- const handleSubmit = event => {
1697
- event.preventDefault();
1698
- onSubmit();
1699
- };
1700
- const handleReset = event => {
1701
- event.preventDefault();
1702
- onReset();
1703
- };
1704
- return jsxs("form", {
1908
+ const dateInputRef = useRef();
1909
+ const focusScopeRef = useRef();
1910
+ const [flatpickrInstance, setFlatpickrInstance] = useState(null);
1911
+ const [isInputDirty, setIsInputDirty] = useState(false);
1912
+ const [forceFocusCalendar, setForceFocusCalendar] = useState(false);
1913
+
1914
+ // shorts the date value back to the source
1915
+ useEffect(() => {
1916
+ if (!flatpickrInstance || !flatpickrInstance.config) return;
1917
+ flatpickrInstance.setDate(date, true);
1918
+ setIsInputDirty(false);
1919
+ }, [flatpickrInstance, date.toString()]);
1920
+ useEffect(() => {
1921
+ if (!forceFocusCalendar) return;
1922
+ focusRelevantFlatpickerDay(flatpickrInstance);
1923
+ setForceFocusCalendar(false);
1924
+ }, [flatpickrInstance, forceFocusCalendar]);
1925
+
1926
+ // setup flatpickr instance
1927
+ useEffect(() => {
1928
+ if (disabled) {
1929
+ setFlatpickrInstance(null);
1930
+ return;
1931
+ }
1932
+ let config = {
1933
+ allowInput: true,
1934
+ dateFormat: 'm/d/Y',
1935
+ static: true,
1936
+ clickOpens: false,
1937
+ errorHandler: () => {/* do nothing, we expect the values to sometimes be erronous and we don't want warnings polluting the console */}
1938
+ };
1939
+ if (disallowPassedDates) {
1940
+ config = {
1941
+ ...config,
1942
+ minDate: 'today'
1943
+ };
1944
+ }
1945
+ const instance = flatpickr(dateInputRef.current, config);
1946
+ setFlatpickrInstance(instance);
1947
+ const onCalendarFocusOut = e => {
1948
+ if (!instance.calendarContainer.contains(e.relatedTarget) && e.relatedTarget != dateInputRef.current) {
1949
+ instance.close();
1950
+ }
1951
+ };
1952
+
1953
+ // remove dirty tag to have mouse day selection prioritize input blur
1954
+ const onCalendarMouseDown = e => {
1955
+ if (e.target.classList.contains('flatpickr-day')) {
1956
+ setIsInputDirty(false);
1957
+ }
1958
+ };
1959
+
1960
+ // when the dropdown of the datepickr opens, we register a few event handlers to re-implement some of the
1961
+ // flatpicker logic that was lost when setting allowInput to true
1962
+ instance.config.onOpen = [() => instance.calendarContainer.addEventListener('focusout', onCalendarFocusOut), () => instance.calendarContainer.addEventListener('mousedown', onCalendarMouseDown)];
1963
+ instance.config.onClose = [() => instance.calendarContainer.removeEventListener('focusout', onCalendarFocusOut), () => instance.calendarContainer.removeEventListener('mousedown', onCalendarMouseDown)];
1964
+ }, [disabled, disallowPassedDates]);
1965
+
1966
+ // onChange is updated dynamically, so not to re-render the flatpicker every time it changes
1967
+ useEffect(() => {
1968
+ if (!flatpickrInstance || !flatpickrInstance.config) return;
1969
+ flatpickrInstance.config.onChange = [date => setDate(new Date(date)), () => setIsInputDirty(false)];
1970
+ }, [flatpickrInstance, setDate]);
1971
+ const onInputKeyDown = useCallback(e => {
1972
+ if (!flatpickrInstance) return;
1973
+ if (e.code === 'Escape') {
1974
+ flatpickrInstance.close();
1975
+ }
1976
+ if (e.code === 'ArrowDown') {
1977
+ if (isInputDirty) {
1978
+ // trigger an enter keypress to submit the new input, then focus calendar day on the next render cycle
1979
+ dateInputRef.current.dispatchEvent(ENTER_KEYDOWN_EVENT);
1980
+ setIsInputDirty(false);
1981
+ setForceFocusCalendar(true);
1982
+ } else {
1983
+ // focus calendar day immediately
1984
+ focusRelevantFlatpickerDay(flatpickrInstance);
1985
+ }
1986
+ e.preventDefault();
1987
+ }
1988
+ if (e.code === 'Enter') {
1989
+ setIsInputDirty(false);
1990
+ }
1991
+ }, [flatpickrInstance, isInputDirty]);
1992
+ const onInputFocus = useCallback(e => {
1993
+ if (!flatpickrInstance || focusScopeRef.current.contains(e.relatedTarget)) return;
1994
+ flatpickrInstance.open();
1995
+ }, [flatpickrInstance]);
1996
+
1997
+ // simulate an enter press on blur to make sure the date value is submitted in all scenarios
1998
+ const onInputBlur = useCallback(e => {
1999
+ if (!isInputDirty || e.relatedTarget && e.relatedTarget.classList.contains('flatpickr-day')) return;
2000
+ dateInputRef.current.dispatchEvent(ENTER_KEYDOWN_EVENT);
2001
+ setIsInputDirty(false);
2002
+ }, [isInputDirty]);
2003
+ const fullId = `${prefixId(id, formId)}--date`;
2004
+ return jsxs("div", {
2005
+ class: "fjs-datetime-subsection",
2006
+ children: [jsx(Label, {
2007
+ id: fullId,
2008
+ label: label,
2009
+ collapseOnEmpty: collapseLabelOnEmpty,
2010
+ required: required
2011
+ }), jsx(InputAdorner, {
2012
+ pre: jsx(CalendarIcon, {}),
2013
+ disabled: disabled,
2014
+ rootRef: focusScopeRef,
2015
+ inputRef: dateInputRef,
2016
+ children: jsx("div", {
2017
+ class: "fjs-datepicker",
2018
+ style: {
2019
+ width: '100%'
2020
+ },
2021
+ children: jsx("input", {
2022
+ ref: dateInputRef,
2023
+ type: "text",
2024
+ id: fullId,
2025
+ class: 'fjs-input',
2026
+ disabled: disabled,
2027
+ placeholder: "mm/dd/yyyy",
2028
+ autoComplete: "false",
2029
+ onFocus: onInputFocus,
2030
+ onKeyDown: onInputKeyDown,
2031
+ onMouseDown: e => !flatpickrInstance.isOpen && flatpickrInstance.open(),
2032
+ onBlur: onInputBlur,
2033
+ onInput: e => setIsInputDirty(true),
2034
+ "data-input": true
2035
+ })
2036
+ })
2037
+ })]
2038
+ });
2039
+ }
2040
+
2041
+ function _extends$g() { _extends$g = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$g.apply(this, arguments); }
2042
+ var ClockIcon = (({
2043
+ styles = {},
2044
+ ...props
2045
+ }) => /*#__PURE__*/React.createElement("svg", _extends$g({
2046
+ width: "16",
2047
+ height: "16",
2048
+ viewBox: "0 0 28 29",
2049
+ fill: "none",
2050
+ xmlns: "http://www.w3.org/2000/svg"
2051
+ }, props), /*#__PURE__*/React.createElement("path", {
2052
+ d: "M13 14.41L18.59 20 20 18.59l-5-5.01V5h-2v9.41z",
2053
+ fill: "#000"
2054
+ }), /*#__PURE__*/React.createElement("path", {
2055
+ fillRule: "evenodd",
2056
+ clipRule: "evenodd",
2057
+ d: "M6.222 25.64A14 14 0 1021.778 2.36 14 14 0 006.222 25.64zM7.333 4.023a12 12 0 1113.334 19.955A12 12 0 017.333 4.022z",
2058
+ fill: "#000"
2059
+ })));
2060
+
2061
+ function useKeyDownAction(targetKey, action, listenerElement = window) {
2062
+ function downHandler({
2063
+ key
2064
+ }) {
2065
+ if (key === targetKey) {
2066
+ action();
2067
+ }
2068
+ }
2069
+ useEffect(() => {
2070
+ listenerElement.addEventListener('keydown', downHandler);
2071
+ return () => {
2072
+ listenerElement.removeEventListener('keydown', downHandler);
2073
+ };
2074
+ });
2075
+ }
2076
+
2077
+ const DEFAULT_LABEL_GETTER = value => value;
2078
+ const NOOP = () => {};
2079
+ function DropdownList(props) {
2080
+ const {
2081
+ keyEventsListener = window,
2082
+ values = [],
2083
+ getLabel = DEFAULT_LABEL_GETTER,
2084
+ onValueSelected = NOOP,
2085
+ height = 235,
2086
+ emptyListMessage = 'No results',
2087
+ initialFocusIndex = 0
2088
+ } = props;
2089
+ const [mouseControl, setMouseControl] = useState(false);
2090
+ const [focusedValueIndex, setFocusedValueIndex] = useState(initialFocusIndex);
2091
+ const [smoothScrolling, setSmoothScrolling] = useState(false);
2092
+ const dropdownContainer = useRef();
2093
+ const mouseScreenPos = useRef();
2094
+ const focusedItem = useMemo(() => values.length ? values[focusedValueIndex] : null, [focusedValueIndex, values]);
2095
+ const changeFocusedValueIndex = useCallback(delta => {
2096
+ setFocusedValueIndex(x => Math.min(Math.max(0, x + delta), values.length - 1));
2097
+ }, [values.length]);
2098
+ useEffect(() => {
2099
+ if (focusedValueIndex === 0) return;
2100
+ if (!focusedValueIndex || !values.length) {
2101
+ setFocusedValueIndex(0);
2102
+ } else if (focusedValueIndex >= values.length) {
2103
+ setFocusedValueIndex(values.length - 1);
2104
+ }
2105
+ }, [focusedValueIndex, values.length]);
2106
+ useKeyDownAction('ArrowUp', () => {
2107
+ if (values.length) {
2108
+ changeFocusedValueIndex(-1);
2109
+ setMouseControl(false);
2110
+ }
2111
+ }, keyEventsListener);
2112
+ useKeyDownAction('ArrowDown', () => {
2113
+ if (values.length) {
2114
+ changeFocusedValueIndex(1);
2115
+ setMouseControl(false);
2116
+ }
2117
+ }, keyEventsListener);
2118
+ useKeyDownAction('Enter', () => {
2119
+ if (focusedItem) {
2120
+ onValueSelected(focusedItem);
2121
+ }
2122
+ }, keyEventsListener);
2123
+ useEffect(() => {
2124
+ const individualEntries = dropdownContainer.current.children;
2125
+ if (individualEntries.length && !mouseControl) {
2126
+ individualEntries[focusedValueIndex].scrollIntoView({
2127
+ block: 'nearest',
2128
+ inline: 'nearest'
2129
+ });
2130
+ }
2131
+ }, [focusedValueIndex, mouseControl]);
2132
+ useEffect(() => {
2133
+ setSmoothScrolling(true);
2134
+ }, []);
2135
+ const onMouseMovedInKeyboardMode = (event, valueIndex) => {
2136
+ const userMovedCursor = !mouseScreenPos.current || mouseScreenPos.current.x !== event.screenX && mouseScreenPos.current.y !== event.screenY;
2137
+ if (userMovedCursor) {
2138
+ mouseScreenPos.current = {
2139
+ x: event.screenX,
2140
+ y: event.screenY
2141
+ };
2142
+ setMouseControl(true);
2143
+ setFocusedValueIndex(valueIndex);
2144
+ }
2145
+ };
2146
+ return jsxs("div", {
2147
+ ref: dropdownContainer,
2148
+ tabIndex: -1,
2149
+ class: "fjs-dropdownlist",
2150
+ style: {
2151
+ maxHeight: height,
2152
+ scrollBehavior: smoothScrolling ? 'smooth' : 'auto'
2153
+ },
2154
+ children: [values.length > 0 && values.map((v, i) => {
2155
+ return jsx("div", {
2156
+ class: classNames('fjs-dropdownlist-item', {
2157
+ 'focused': focusedValueIndex === i
2158
+ }),
2159
+ onMouseMove: mouseControl ? undefined : e => onMouseMovedInKeyboardMode(e, i),
2160
+ onMouseEnter: mouseControl ? () => setFocusedValueIndex(i) : undefined,
2161
+ onMouseDown: e => {
2162
+ e.preventDefault();
2163
+ onValueSelected(v);
2164
+ },
2165
+ children: getLabel(v)
2166
+ });
2167
+ }), !values.length && jsx("div", {
2168
+ class: "fjs-dropdownlist-empty",
2169
+ children: emptyListMessage
2170
+ })]
2171
+ });
2172
+ }
2173
+
2174
+ function Timepicker(props) {
2175
+ const {
2176
+ id,
2177
+ label,
2178
+ collapseLabelOnEmpty,
2179
+ formId,
2180
+ required,
2181
+ disabled,
2182
+ use24h = false,
2183
+ timeInterval,
2184
+ time,
2185
+ setTime
2186
+ } = props;
2187
+ const timeInputRef = useRef();
2188
+ const [dropdownIsOpen, setDropdownIsOpen] = useState(false);
2189
+ const useDropdown = useMemo(() => timeInterval !== 1, [timeInterval]);
2190
+ const [rawValue, setRawValue] = useState('');
2191
+
2192
+ // populates values from source
2193
+ useEffect(() => {
2194
+ if (time === null) {
2195
+ setRawValue('');
2196
+ return;
2197
+ }
2198
+ const intervalAdjustedTime = time - time % timeInterval;
2199
+ setRawValue(formatTime(use24h, intervalAdjustedTime));
2200
+ if (intervalAdjustedTime != time) {
2201
+ setTime(intervalAdjustedTime);
2202
+ }
2203
+ }, [time, setTime, use24h, timeInterval]);
2204
+ const propagateRawToMinute = useCallback(newRawValue => {
2205
+ const localRawValue = newRawValue || rawValue;
2206
+
2207
+ // If no raw value exists, set the minute to null
2208
+ if (!localRawValue) {
2209
+ setTime(null);
2210
+ return;
2211
+ }
2212
+ const minutes = parseInputTime(localRawValue);
2213
+
2214
+ // If raw string couldn't be parsed, clean everything up
2215
+ if (!isNumber(minutes)) {
2216
+ setRawValue('');
2217
+ setTime(null);
2218
+ return;
2219
+ }
2220
+
2221
+ // Enforce the minutes to match the timeInterval
2222
+ const correctedMinutes = minutes - minutes % timeInterval;
2223
+
2224
+ // Enforce the raw text to be formatted properly
2225
+ setRawValue(formatTime(use24h, correctedMinutes));
2226
+ setTime(correctedMinutes);
2227
+ }, [rawValue, timeInterval, use24h, setTime]);
2228
+ const timeOptions = useMemo(() => {
2229
+ const minutesInDay = 24 * 60;
2230
+ const intervalCount = Math.floor(minutesInDay / timeInterval);
2231
+ return [...Array(intervalCount).keys()].map(intervalIndex => formatTime(use24h, intervalIndex * timeInterval));
2232
+ }, [timeInterval, use24h]);
2233
+ const initialFocusIndex = useMemo(() => {
2234
+ // if there are no options, there will not be any focusing
2235
+ if (!timeOptions || !timeInterval) return null;
2236
+
2237
+ // if there is a set minute value, we focus it in the dropdown
2238
+ if (time) return time / timeInterval;
2239
+ const cacheTime = parseInputTime(rawValue);
2240
+
2241
+ // if there is a valid value in the input cache, we try and focus close to it
2242
+ if (cacheTime) {
2243
+ const flooredCacheTime = cacheTime - cacheTime % timeInterval;
2244
+ return flooredCacheTime / timeInterval;
2245
+ }
2246
+
2247
+ // If there is no set value, simply focus the middle of the dropdown (12:00)
2248
+ return Math.floor(timeOptions.length / 2);
2249
+ }, [rawValue, time, timeInterval, timeOptions]);
2250
+ const onInputKeyDown = e => {
2251
+ switch (e.key) {
2252
+ case 'ArrowUp':
2253
+ e.preventDefault();
2254
+ break;
2255
+ case 'ArrowDown':
2256
+ useDropdown && setDropdownIsOpen(true);
2257
+ e.preventDefault();
2258
+ break;
2259
+ case 'Escape':
2260
+ useDropdown && setDropdownIsOpen(false);
2261
+ break;
2262
+ case 'Enter':
2263
+ !dropdownIsOpen && propagateRawToMinute();
2264
+ break;
2265
+ }
2266
+ };
2267
+ const onInputBlur = e => {
2268
+ setDropdownIsOpen(false);
2269
+ propagateRawToMinute();
2270
+ };
2271
+ const onDropdownValueSelected = value => {
2272
+ setDropdownIsOpen(false);
2273
+ propagateRawToMinute(value);
2274
+ };
2275
+ const fullId = `${prefixId(id, formId)}--time`;
2276
+ return jsxs("div", {
2277
+ class: "fjs-datetime-subsection",
2278
+ children: [jsx(Label, {
2279
+ id: fullId,
2280
+ label: label,
2281
+ collapseOnEmpty: collapseLabelOnEmpty,
2282
+ required: required
2283
+ }), jsx(InputAdorner, {
2284
+ pre: jsx(ClockIcon, {}),
2285
+ inputRef: timeInputRef,
2286
+ disabled: disabled,
2287
+ children: jsxs("div", {
2288
+ class: "fjs-timepicker fjs-timepicker-anchor",
2289
+ children: [jsx("input", {
2290
+ ref: timeInputRef,
2291
+ type: "text",
2292
+ id: fullId,
2293
+ class: "fjs-input",
2294
+ value: rawValue,
2295
+ disabled: disabled,
2296
+ placeholder: use24h ? 'hh:mm' : 'hh:mm ?m',
2297
+ autoComplete: "false",
2298
+ onFocus: () => useDropdown && setDropdownIsOpen(true),
2299
+ onClick: () => useDropdown && setDropdownIsOpen(true)
2300
+
2301
+ // @ts-ignore
2302
+ ,
2303
+ onInput: e => {
2304
+ setRawValue(e.target.value);
2305
+ useDropdown && setDropdownIsOpen(false);
2306
+ },
2307
+ onBlur: onInputBlur,
2308
+ onKeyDown: onInputKeyDown,
2309
+ "data-input": true
2310
+ }), dropdownIsOpen && jsx(DropdownList, {
2311
+ values: timeOptions,
2312
+ height: 150,
2313
+ onValueSelected: onDropdownValueSelected,
2314
+ listenerElement: timeInputRef.current,
2315
+ initialFocusIndex: initialFocusIndex
2316
+ })]
2317
+ })
2318
+ })]
2319
+ });
2320
+ }
2321
+
2322
+ const type$8 = 'datetime';
2323
+ function Datetime(props) {
2324
+ const {
2325
+ disabled,
2326
+ errors = [],
2327
+ field,
2328
+ onChange,
2329
+ value = ''
2330
+ } = props;
2331
+ const {
2332
+ description,
2333
+ id,
2334
+ dateLabel,
2335
+ timeLabel,
2336
+ validate = {},
2337
+ subtype,
2338
+ use24h,
2339
+ disallowPassedDates,
2340
+ timeInterval,
2341
+ timeSerializingFormat
2342
+ } = field;
2343
+ const {
2344
+ required
2345
+ } = validate;
2346
+ const {
2347
+ formId
2348
+ } = useContext(FormContext);
2349
+ const getNullDateTime = () => ({
2350
+ date: new Date(Date.parse(null)),
2351
+ time: null
2352
+ });
2353
+ const [dateTime, setDateTime] = useState(getNullDateTime());
2354
+ const [dateTimeUpdateRequest, setDateTimeUpdateRequest] = useState(null);
2355
+ const isValidDate = date => date && !isNaN(date.getTime());
2356
+ const isValidTime = time => !isNaN(parseInt(time));
2357
+ const useDatePicker = useMemo(() => subtype === DATETIME_SUBTYPES.DATE || subtype === DATETIME_SUBTYPES.DATETIME, [subtype]);
2358
+ const useTimePicker = useMemo(() => subtype === DATETIME_SUBTYPES.TIME || subtype === DATETIME_SUBTYPES.DATETIME, [subtype]);
2359
+ useEffect(() => {
2360
+ let {
2361
+ date,
2362
+ time
2363
+ } = getNullDateTime();
2364
+ if (!disabled) {
2365
+ switch (subtype) {
2366
+ case DATETIME_SUBTYPES.DATE:
2367
+ {
2368
+ date = new Date(Date.parse(value));
2369
+ break;
2370
+ }
2371
+ case DATETIME_SUBTYPES.TIME:
2372
+ {
2373
+ time = parseIsoTime(value);
2374
+ break;
2375
+ }
2376
+ case DATETIME_SUBTYPES.DATETIME:
2377
+ {
2378
+ date = new Date(Date.parse(value));
2379
+ time = isValidDate(date) ? 60 * date.getHours() + date.getMinutes() : null;
2380
+ break;
2381
+ }
2382
+ }
2383
+ }
2384
+ setDateTime({
2385
+ date,
2386
+ time
2387
+ });
2388
+ }, [subtype, value, disabled]);
2389
+ const computeAndSetState = useCallback(({
2390
+ date,
2391
+ time
2392
+ }) => {
2393
+ let newDateTimeValue = null;
2394
+ if (subtype === DATETIME_SUBTYPES.DATE && isValidDate(date)) {
2395
+ newDateTimeValue = serializeDate(date);
2396
+ } else if (subtype === DATETIME_SUBTYPES.TIME && isValidTime(time)) {
2397
+ newDateTimeValue = serializeTime(time, new Date().getTimezoneOffset(), timeSerializingFormat);
2398
+ } else if (subtype === DATETIME_SUBTYPES.DATETIME && isValidDate(date) && isValidTime(time)) {
2399
+ newDateTimeValue = serializeDateTime(date, time, timeSerializingFormat);
2400
+ }
2401
+ onChange({
2402
+ value: newDateTimeValue,
2403
+ field
2404
+ });
2405
+ }, [field, onChange, subtype, timeSerializingFormat]);
2406
+ useEffect(() => {
2407
+ if (dateTimeUpdateRequest) {
2408
+ if (dateTimeUpdateRequest.refreshOnly) {
2409
+ computeAndSetState(dateTime);
2410
+ } else {
2411
+ const newDateTime = {
2412
+ ...dateTime,
2413
+ ...dateTimeUpdateRequest
2414
+ };
2415
+ setDateTime(newDateTime);
2416
+ computeAndSetState(newDateTime);
2417
+ }
2418
+ setDateTimeUpdateRequest(null);
2419
+ }
2420
+ }, [computeAndSetState, dateTime, dateTimeUpdateRequest]);
2421
+ useEffect(() => {
2422
+ setDateTimeUpdateRequest({
2423
+ refreshOnly: true
2424
+ });
2425
+ }, [timeSerializingFormat]);
2426
+ const allErrors = useMemo(() => {
2427
+ if (required || subtype !== DATETIME_SUBTYPES.DATETIME) return errors;
2428
+ const isOnlyOneFieldSet = isValidDate(dateTime.date) && !isValidTime(dateTime.time) || !isValidDate(dateTime.date) && isValidTime(dateTime.time);
2429
+ return isOnlyOneFieldSet ? ['Date and time must both be entered.', ...errors] : errors;
2430
+ }, [required, subtype, dateTime, errors]);
2431
+ const setDate = useCallback(date => {
2432
+ setDateTimeUpdateRequest(prev => prev ? {
2433
+ ...prev,
2434
+ date
2435
+ } : {
2436
+ date
2437
+ });
2438
+ }, []);
2439
+ const setTime = useCallback(time => {
2440
+ setDateTimeUpdateRequest(prev => prev ? {
2441
+ ...prev,
2442
+ time
2443
+ } : {
2444
+ time
2445
+ });
2446
+ }, []);
2447
+ const datePickerProps = {
2448
+ id,
2449
+ label: dateLabel,
2450
+ collapseLabelOnEmpty: !timeLabel,
2451
+ formId,
2452
+ required,
2453
+ disabled,
2454
+ disallowPassedDates,
2455
+ date: dateTime.date,
2456
+ setDate
2457
+ };
2458
+ const timePickerProps = {
2459
+ id,
2460
+ label: timeLabel,
2461
+ collapseLabelOnEmpty: !dateLabel,
2462
+ formId,
2463
+ required,
2464
+ disabled,
2465
+ use24h,
2466
+ timeInterval,
2467
+ time: dateTime.time,
2468
+ setTime
2469
+ };
2470
+ return jsxs("div", {
2471
+ class: formFieldClasses(type$8, {
2472
+ errors: allErrors,
2473
+ disabled
2474
+ }),
2475
+ children: [jsxs("div", {
2476
+ class: classNames('fjs-vertical-group'),
2477
+ children: [useDatePicker && jsx(Datepicker, {
2478
+ ...datePickerProps
2479
+ }), useTimePicker && useDatePicker && jsx("div", {
2480
+ class: "fjs-datetime-separator"
2481
+ }), useTimePicker && jsx(Timepicker, {
2482
+ ...timePickerProps
2483
+ })]
2484
+ }), jsx(Description, {
2485
+ description: description
2486
+ }), jsx(Errors, {
2487
+ errors: allErrors
2488
+ })]
2489
+ });
2490
+ }
2491
+ Datetime.create = function (options = {}) {
2492
+ const newOptions = {};
2493
+ set(newOptions, DATETIME_SUBTYPE_PATH, DATETIME_SUBTYPES.DATE);
2494
+ set(newOptions, DATE_LABEL_PATH, 'Date');
2495
+ return {
2496
+ ...newOptions,
2497
+ ...options
2498
+ };
2499
+ };
2500
+ Datetime.type = type$8;
2501
+ Datetime.keyed = true;
2502
+ Datetime.emptyValue = null;
2503
+ Datetime.sanitizeValue = sanitizeDateTimePickerValue;
2504
+
2505
+ /**
2506
+ * This file must not be changed or exchanged.
2507
+ *
2508
+ * @see http://bpmn.io/license for more information.
2509
+ */
2510
+ function Logo() {
2511
+ return jsxs("svg", {
2512
+ xmlns: "http://www.w3.org/2000/svg",
2513
+ viewBox: "0 0 14.02 5.57",
2514
+ width: "53",
2515
+ height: "21",
2516
+ style: "vertical-align:middle",
2517
+ children: [jsx("path", {
2518
+ fill: "currentColor",
2519
+ d: "M1.88.92v.14c0 .41-.13.68-.4.8.33.14.46.44.46.86v.33c0 .61-.33.95-.95.95H0V0h.95c.65 0 .93.3.93.92zM.63.57v1.06h.24c.24 0 .38-.1.38-.43V.98c0-.28-.1-.4-.32-.4zm0 1.63v1.22h.36c.2 0 .32-.1.32-.39v-.35c0-.37-.12-.48-.4-.48H.63zM4.18.99v.52c0 .64-.31.98-.94.98h-.3V4h-.62V0h.92c.63 0 .94.35.94.99zM2.94.57v1.35h.3c.2 0 .3-.09.3-.37v-.6c0-.29-.1-.38-.3-.38h-.3zm2.89 2.27L6.25 0h.88v4h-.6V1.12L6.1 3.99h-.6l-.46-2.82v2.82h-.55V0h.87zM8.14 1.1V4h-.56V0h.79L9 2.4V0h.56v4h-.64zm2.49 2.29v.6h-.6v-.6zM12.12 1c0-.63.33-1 .95-1 .61 0 .95.37.95 1v2.04c0 .64-.34 1-.95 1-.62 0-.95-.37-.95-1zm.62 2.08c0 .28.13.39.33.39s.32-.1.32-.4V.98c0-.29-.12-.4-.32-.4s-.33.11-.33.4z"
2520
+ }), jsx("path", {
2521
+ fill: "currentColor",
2522
+ d: "M0 4.53h14.02v1.04H0zM11.08 0h.63v.62h-.63zm.63 4V1h-.63v2.98z"
2523
+ })]
2524
+ });
2525
+ }
2526
+ function Lightbox(props) {
2527
+ const {
2528
+ open
2529
+ } = props;
2530
+ if (!open) {
2531
+ return null;
2532
+ }
2533
+ return jsxs("div", {
2534
+ class: "fjs-powered-by-lightbox",
2535
+ style: "z-index: 100; position: fixed; top: 0; left: 0;right: 0; bottom: 0",
2536
+ children: [jsx("div", {
2537
+ class: "backdrop",
2538
+ style: "width: 100%; height: 100%; background: rgba(40 40 40 / 20%)",
2539
+ onClick: props.onBackdropClick
2540
+ }), jsxs("div", {
2541
+ class: "notice",
2542
+ style: "position: absolute; left: 50%; top: 40%; transform: translate(-50%); width: 260px; padding: 10px; background: white; box-shadow: 0 1px 4px rgba(0 0 0 / 30%); font-family: Helvetica, Arial, sans-serif; font-size: 14px; display: flex; line-height: 1.3",
2543
+ children: [jsx("a", {
2544
+ href: "https://bpmn.io",
2545
+ target: "_blank",
2546
+ rel: "noopener",
2547
+ style: "margin: 15px 20px 15px 10px; align-self: center; color: #404040",
2548
+ children: jsx(Logo, {})
2549
+ }), jsxs("span", {
2550
+ children: ["Web-based tooling for BPMN, DMN, and forms powered by ", jsx("a", {
2551
+ href: "https://bpmn.io",
2552
+ target: "_blank",
2553
+ rel: "noopener",
2554
+ children: "bpmn.io"
2555
+ }), "."]
2556
+ })]
2557
+ })]
2558
+ });
2559
+ }
2560
+ function Link(props) {
2561
+ return jsx("div", {
2562
+ class: "fjs-powered-by fjs-form-field",
2563
+ style: "text-align: right",
2564
+ children: jsx("a", {
2565
+ href: "https://bpmn.io",
2566
+ target: "_blank",
2567
+ rel: "noopener",
2568
+ class: "fjs-powered-by-link",
2569
+ title: "Powered by bpmn.io",
2570
+ style: "color: #404040",
2571
+ onClick: props.onClick,
2572
+ children: jsx(Logo, {})
2573
+ })
2574
+ });
2575
+ }
2576
+ function PoweredBy(props) {
2577
+ const [open, setOpen] = useState(false);
2578
+ function toggleOpen(open) {
2579
+ return event => {
2580
+ event.preventDefault();
2581
+ setOpen(open);
2582
+ };
2583
+ }
2584
+ return jsxs(Fragment, {
2585
+ children: [createPortal(jsx(Lightbox, {
2586
+ open: open,
2587
+ onBackdropClick: toggleOpen(false)
2588
+ }), document.body), jsx(Link, {
2589
+ onClick: toggleOpen(true)
2590
+ })]
2591
+ });
2592
+ }
2593
+
2594
+ const noop = () => {};
2595
+ function FormComponent(props) {
2596
+ const form = useService('form');
2597
+ const {
2598
+ schema
2599
+ } = form._getState();
2600
+ const {
2601
+ onSubmit = noop,
2602
+ onReset = noop,
2603
+ onChange = noop
2604
+ } = props;
2605
+ const handleSubmit = event => {
2606
+ event.preventDefault();
2607
+ onSubmit();
2608
+ };
2609
+ const handleReset = event => {
2610
+ event.preventDefault();
2611
+ onReset();
2612
+ };
2613
+ return jsxs("form", {
1705
2614
  class: "fjs-form",
1706
2615
  onSubmit: handleSubmit,
1707
2616
  onReset: handleReset,
@@ -1719,11 +2628,18 @@ function FormComponent(props) {
1719
2628
  * @param {import('../../types').Data} data
1720
2629
  */
1721
2630
  function useEvaluation(expression, data) {
2631
+ const initialData = useService('form')._getState().initialData;
1722
2632
  const conditionChecker = useService('conditionChecker', false);
1723
2633
  if (!conditionChecker) {
1724
2634
  return null;
1725
2635
  }
1726
- return conditionChecker.evaluate(expression, data);
2636
+
2637
+ // make sure we do not use data from hidden fields
2638
+ const filteredData = {
2639
+ ...initialData,
2640
+ ...conditionChecker.applyConditions(data, data)
2641
+ };
2642
+ return conditionChecker.evaluate(expression, filteredData);
1727
2643
  }
1728
2644
 
1729
2645
  /**
@@ -1748,11 +2664,11 @@ function isExpression(value) {
1748
2664
  return isString(value) && value.startsWith('=');
1749
2665
  }
1750
2666
 
1751
- function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
2667
+ function _extends$f() { _extends$f = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$f.apply(this, arguments); }
1752
2668
  var ImagePlaceholder = (({
1753
2669
  styles = {},
1754
2670
  ...props
1755
- }) => /*#__PURE__*/React.createElement("svg", _extends$1({
2671
+ }) => /*#__PURE__*/React.createElement("svg", _extends$f({
1756
2672
  width: "64",
1757
2673
  height: "64",
1758
2674
  viewBox: "0 0 1280 1280",
@@ -1832,11 +2748,16 @@ function Numberfield(props) {
1832
2748
  description,
1833
2749
  id,
1834
2750
  label,
2751
+ appearance = {},
1835
2752
  validate = {},
1836
2753
  decimalDigits,
1837
2754
  serializeToString = false,
1838
2755
  increment: incrementValue
1839
2756
  } = field;
2757
+ const {
2758
+ prefixAdorner,
2759
+ suffixAdorner
2760
+ } = appearance;
1840
2761
  const {
1841
2762
  required
1842
2763
  } = validate;
@@ -1927,10 +2848,10 @@ function Numberfield(props) {
1927
2848
 
1928
2849
  // intercept key presses which would lead to an invalid number
1929
2850
  const onKeyPress = e => {
1930
- const carretIndex = inputRef.current.selectionStart;
2851
+ const caretIndex = inputRef.current.selectionStart;
1931
2852
  const selectionWidth = inputRef.current.selectionStart - inputRef.current.selectionEnd;
1932
2853
  const previousValue = inputRef.current.value;
1933
- if (!willKeyProduceValidNumber(e.key, previousValue, carretIndex, selectionWidth, decimalDigits)) {
2854
+ if (!willKeyProduceValidNumber(e.key, previousValue, caretIndex, selectionWidth, decimalDigits)) {
1934
2855
  e.preventDefault();
1935
2856
  }
1936
2857
  };
@@ -1946,45 +2867,50 @@ function Numberfield(props) {
1946
2867
  id: prefixId(id, formId),
1947
2868
  label: label,
1948
2869
  required: required
1949
- }), jsxs("div", {
1950
- class: classNames('fjs-input-group', {
1951
- 'disabled': disabled
1952
- }, {
1953
- 'hasErrors': errors.length
1954
- }),
1955
- children: [jsx("input", {
1956
- ref: inputRef,
1957
- class: "fjs-input",
1958
- disabled: disabled,
1959
- id: prefixId(id, formId),
1960
- onKeyDown: onKeyDown,
1961
- onKeyPress: onKeyPress
1962
-
1963
- // @ts-ignore
1964
- ,
1965
- onInput: e => setValue(e.target.value),
1966
- type: "text",
1967
- autoComplete: "off",
1968
- step: arrowIncrementValue,
1969
- value: displayValue
1970
- }), jsxs("div", {
1971
- class: classNames('fjs-number-arrow-container', {
2870
+ }), jsx(InputAdorner, {
2871
+ disabled: disabled,
2872
+ pre: prefixAdorner,
2873
+ post: suffixAdorner,
2874
+ children: jsxs("div", {
2875
+ class: classNames('fjs-vertical-group', {
1972
2876
  'disabled': disabled
2877
+ }, {
2878
+ 'hasErrors': errors.length
1973
2879
  }),
1974
- children: [jsx("button", {
1975
- class: "fjs-number-arrow-up",
1976
- onClick: () => increment(),
1977
- tabIndex: -1,
1978
- children: "\u02C4"
1979
- }), jsx("div", {
1980
- class: "fjs-number-arrow-separator"
1981
- }), jsx("button", {
1982
- class: "fjs-number-arrow-down",
1983
- onClick: () => decrement(),
1984
- tabIndex: -1,
1985
- children: "\u02C5"
2880
+ children: [jsx("input", {
2881
+ ref: inputRef,
2882
+ class: "fjs-input",
2883
+ disabled: disabled,
2884
+ id: prefixId(id, formId),
2885
+ onKeyDown: onKeyDown,
2886
+ onKeyPress: onKeyPress
2887
+
2888
+ // @ts-ignore
2889
+ ,
2890
+ onInput: e => setValue(e.target.value),
2891
+ type: "text",
2892
+ autoComplete: "off",
2893
+ step: arrowIncrementValue,
2894
+ value: displayValue
2895
+ }), jsxs("div", {
2896
+ class: classNames('fjs-number-arrow-container', {
2897
+ 'disabled': disabled
2898
+ }),
2899
+ children: [jsx("button", {
2900
+ class: "fjs-number-arrow-up",
2901
+ onClick: () => increment(),
2902
+ tabIndex: -1,
2903
+ children: "\u02C4"
2904
+ }), jsx("div", {
2905
+ class: "fjs-number-arrow-separator"
2906
+ }), jsx("button", {
2907
+ class: "fjs-number-arrow-down",
2908
+ onClick: () => decrement(),
2909
+ tabIndex: -1,
2910
+ children: "\u02C5"
2911
+ })]
1986
2912
  })]
1987
- })]
2913
+ })
1988
2914
  }), jsx(Description, {
1989
2915
  description: description
1990
2916
  }), jsx(Errors, {
@@ -2167,11 +3093,11 @@ Select.keyed = true;
2167
3093
  Select.emptyValue = null;
2168
3094
  Select.sanitizeValue = sanitizeSingleSelectValue;
2169
3095
 
2170
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3096
+ function _extends$e() { _extends$e = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$e.apply(this, arguments); }
2171
3097
  var CloseIcon = (({
2172
3098
  styles = {},
2173
3099
  ...props
2174
- }) => /*#__PURE__*/React.createElement("svg", _extends({
3100
+ }) => /*#__PURE__*/React.createElement("svg", _extends$e({
2175
3101
  width: "16",
2176
3102
  height: "16",
2177
3103
  fill: "none",
@@ -2183,113 +3109,6 @@ var CloseIcon = (({
2183
3109
  fill: "currentColor"
2184
3110
  })));
2185
3111
 
2186
- function useKeyDownAction(targetKey, action, listenerElement = window) {
2187
- function downHandler({
2188
- key
2189
- }) {
2190
- if (key === targetKey) {
2191
- action();
2192
- }
2193
- }
2194
- useEffect(() => {
2195
- listenerElement.addEventListener('keydown', downHandler);
2196
- return () => {
2197
- listenerElement.removeEventListener('keydown', downHandler);
2198
- };
2199
- });
2200
- }
2201
-
2202
- const DEFAULT_LABEL_GETTER = value => value;
2203
- const NOOP = () => {};
2204
- function DropdownList(props) {
2205
- const {
2206
- keyEventsListener = window,
2207
- values = [],
2208
- getLabel = DEFAULT_LABEL_GETTER,
2209
- onValueSelected = NOOP,
2210
- height = 235,
2211
- emptyListMessage = 'No results'
2212
- } = props;
2213
- const [mouseControl, setMouseControl] = useState(true);
2214
- const [focusedValueIndex, setFocusedValueIndex] = useState(0);
2215
- const dropdownContainer = useRef();
2216
- const mouseScreenPos = useRef();
2217
- const focusedItem = useMemo(() => values.length ? values[focusedValueIndex] : null, [focusedValueIndex, values]);
2218
- const changeFocusedValueIndex = useCallback(delta => {
2219
- setFocusedValueIndex(x => Math.min(Math.max(0, x + delta), values.length - 1));
2220
- }, [values.length]);
2221
- useEffect(() => {
2222
- if (focusedValueIndex === 0) return;
2223
- if (!focusedValueIndex || !values.length) {
2224
- setFocusedValueIndex(0);
2225
- } else if (focusedValueIndex >= values.length) {
2226
- setFocusedValueIndex(values.length - 1);
2227
- }
2228
- }, [focusedValueIndex, values.length]);
2229
- useKeyDownAction('ArrowUp', () => {
2230
- if (values.length) {
2231
- changeFocusedValueIndex(-1);
2232
- setMouseControl(false);
2233
- }
2234
- }, keyEventsListener);
2235
- useKeyDownAction('ArrowDown', () => {
2236
- if (values.length) {
2237
- changeFocusedValueIndex(1);
2238
- setMouseControl(false);
2239
- }
2240
- }, keyEventsListener);
2241
- useKeyDownAction('Enter', () => {
2242
- if (focusedItem) {
2243
- onValueSelected(focusedItem);
2244
- }
2245
- }, keyEventsListener);
2246
- useEffect(() => {
2247
- const individualEntries = dropdownContainer.current.children;
2248
- if (individualEntries.length && !mouseControl) {
2249
- individualEntries[focusedValueIndex].scrollIntoView({
2250
- block: 'nearest',
2251
- inline: 'nearest'
2252
- });
2253
- }
2254
- }, [focusedValueIndex, mouseControl]);
2255
- const mouseMove = (e, i) => {
2256
- const userMoved = !mouseScreenPos.current || mouseScreenPos.current.x !== e.screenX && mouseScreenPos.current.y !== e.screenY;
2257
- if (userMoved) {
2258
- mouseScreenPos.current = {
2259
- x: e.screenX,
2260
- y: e.screenY
2261
- };
2262
- if (!mouseControl) {
2263
- setMouseControl(true);
2264
- setFocusedValueIndex(i);
2265
- }
2266
- }
2267
- };
2268
- return jsxs("div", {
2269
- ref: dropdownContainer,
2270
- tabIndex: -1,
2271
- class: "fjs-dropdownlist",
2272
- style: {
2273
- maxHeight: height
2274
- },
2275
- children: [!!values.length && values.map((v, i) => {
2276
- return jsx("div", {
2277
- class: 'fjs-dropdownlist-item' + (focusedValueIndex === i ? ' focused' : ''),
2278
- onMouseMove: e => mouseMove(e, i),
2279
- onMouseEnter: mouseControl ? () => setFocusedValueIndex(i) : undefined,
2280
- onMouseDown: e => {
2281
- e.preventDefault();
2282
- onValueSelected(v);
2283
- },
2284
- children: getLabel(v)
2285
- });
2286
- }), !values.length && jsx("div", {
2287
- class: "fjs-dropdownlist-empty",
2288
- children: emptyListMessage
2289
- })]
2290
- });
2291
- }
2292
-
2293
3112
  const type$3 = 'taglist';
2294
3113
  function Taglist(props) {
2295
3114
  const {
@@ -2473,20 +3292,261 @@ Taglist.keyed = true;
2473
3292
  Taglist.emptyValue = [];
2474
3293
  Taglist.sanitizeValue = sanitizeMultiSelectValue;
2475
3294
 
3295
+ function _extends$d() { _extends$d = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$d.apply(this, arguments); }
3296
+ var ButtonIcon = (({
3297
+ styles = {},
3298
+ ...props
3299
+ }) => /*#__PURE__*/React.createElement("svg", _extends$d({
3300
+ xmlns: "http://www.w3.org/2000/svg",
3301
+ width: "54",
3302
+ height: "54"
3303
+ }, props), /*#__PURE__*/React.createElement("path", {
3304
+ fillRule: "evenodd",
3305
+ d: "M45 17a3 3 0 013 3v14a3 3 0 01-3 3H9a3 3 0 01-3-3V20a3 3 0 013-3h36zm-9 8.889H18v2.222h18V25.89z"
3306
+ })));
3307
+
3308
+ function _extends$c() { _extends$c = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$c.apply(this, arguments); }
3309
+ var CheckboxIcon = (({
3310
+ styles = {},
3311
+ ...props
3312
+ }) => /*#__PURE__*/React.createElement("svg", _extends$c({
3313
+ xmlns: "http://www.w3.org/2000/svg",
3314
+ width: "54",
3315
+ height: "54"
3316
+ }, props), /*#__PURE__*/React.createElement("path", {
3317
+ d: "M34 18H20a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2V20a2 2 0 00-2-2zm-9 14l-5-5 1.41-1.41L25 29.17l7.59-7.59L34 23l-9 9z"
3318
+ })));
3319
+
3320
+ function _extends$b() { _extends$b = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$b.apply(this, arguments); }
3321
+ var ChecklistIcon = (({
3322
+ styles = {},
3323
+ ...props
3324
+ }) => /*#__PURE__*/React.createElement("svg", _extends$b({
3325
+ width: "54",
3326
+ height: "54",
3327
+ fill: "none",
3328
+ xmlns: "http://www.w3.org/2000/svg"
3329
+ }, props), /*#__PURE__*/React.createElement("path", {
3330
+ fillRule: "evenodd",
3331
+ clipRule: "evenodd",
3332
+ d: "M19 24h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6zm6 18h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6zm6-30h-6v6h6V8zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2V8a2 2 0 00-2-2h-6z",
3333
+ fill: "#22242A"
3334
+ }), /*#__PURE__*/React.createElement("path", {
3335
+ d: "M26 26a1 1 0 011-1h15a1 1 0 011 1v2a1 1 0 01-1 1H27a1 1 0 01-1-1v-2zm0 16a1 1 0 011-1h15a1 1 0 011 1v2a1 1 0 01-1 1H27a1 1 0 01-1-1v-2zm0-32a1 1 0 011-1h15a1 1 0 011 1v2a1 1 0 01-1 1H27a1 1 0 01-1-1v-2z",
3336
+ fill: "#22242A"
3337
+ })));
3338
+
3339
+ function _extends$a() { _extends$a = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$a.apply(this, arguments); }
3340
+ var DatetimeIcon = (({
3341
+ styles = {},
3342
+ ...props
3343
+ }) => /*#__PURE__*/React.createElement("svg", _extends$a({
3344
+ xmlns: "http://www.w3.org/2000/svg",
3345
+ width: "54",
3346
+ height: "54",
3347
+ fill: "none"
3348
+ }, props), /*#__PURE__*/React.createElement("path", {
3349
+ fill: "#000",
3350
+ fillRule: "evenodd",
3351
+ d: "M37.908 13.418h-5.004v-2.354h-1.766v2.354H21.13v-2.354h-1.766v2.354H14.36c-1.132 0-2.06.928-2.06 2.06v23.549c0 1.132.928 2.06 2.06 2.06h6.77v-1.766h-6.358a.707.707 0 01-.706-.706V15.89c0-.39.316-.707.706-.707h4.592v2.355h1.766v-2.355h10.008v2.355h1.766v-2.355h4.592c.39 0 .707.317.707.707v6.358h1.765v-6.77c0-1.133-.927-2.06-2.06-2.06z",
3352
+ clipRule: "evenodd"
3353
+ }), /*#__PURE__*/React.createElement("path", {
3354
+ fill: "#000",
3355
+ d: "M35.13 37.603l1.237-1.237-3.468-3.475v-5.926h-1.754v6.654l3.984 3.984z"
3356
+ }), /*#__PURE__*/React.createElement("path", {
3357
+ fill: "#000",
3358
+ fillRule: "evenodd",
3359
+ d: "M23.08 36.962a9.678 9.678 0 1017.883-7.408 9.678 9.678 0 00-17.882 7.408zm4.54-10.292a7.924 7.924 0 118.805 13.177A7.924 7.924 0 0127.62 26.67z",
3360
+ clipRule: "evenodd"
3361
+ })));
3362
+
3363
+ function _extends$9() { _extends$9 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$9.apply(this, arguments); }
3364
+ var TaglistIcon = (({
3365
+ styles = {},
3366
+ ...props
3367
+ }) => /*#__PURE__*/React.createElement("svg", _extends$9({
3368
+ width: "54",
3369
+ height: "54",
3370
+ fill: "none",
3371
+ xmlns: "http://www.w3.org/2000/svg"
3372
+ }, props), /*#__PURE__*/React.createElement("path", {
3373
+ fillRule: "evenodd",
3374
+ clipRule: "evenodd",
3375
+ d: "M45 16a3 3 0 013 3v16a3 3 0 01-3 3H9a3 3 0 01-3-3V19a3 3 0 013-3h36zm0 2H9a1 1 0 00-1 1v16a1 1 0 001 1h36a1 1 0 001-1V19a1 1 0 00-1-1z",
3376
+ fill: "#000"
3377
+ }), /*#__PURE__*/React.createElement("path", {
3378
+ d: "M11 22a1 1 0 011-1h19a1 1 0 011 1v10a1 1 0 01-1 1H12a1 1 0 01-1-1V22z",
3379
+ fill: "#505562"
3380
+ })));
3381
+
3382
+ function _extends$8() { _extends$8 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$8.apply(this, arguments); }
3383
+ var FormIcon = (({
3384
+ styles = {},
3385
+ ...props
3386
+ }) => /*#__PURE__*/React.createElement("svg", _extends$8({
3387
+ xmlns: "http://www.w3.org/2000/svg",
3388
+ width: "54",
3389
+ height: "54"
3390
+ }, props), /*#__PURE__*/React.createElement("rect", {
3391
+ x: "15",
3392
+ y: "17",
3393
+ width: "24",
3394
+ height: "4",
3395
+ rx: "1"
3396
+ }), /*#__PURE__*/React.createElement("rect", {
3397
+ x: "15",
3398
+ y: "25",
3399
+ width: "24",
3400
+ height: "4",
3401
+ rx: "1"
3402
+ }), /*#__PURE__*/React.createElement("rect", {
3403
+ x: "15",
3404
+ y: "33",
3405
+ width: "13",
3406
+ height: "4",
3407
+ rx: "1"
3408
+ })));
3409
+
3410
+ function _extends$7() { _extends$7 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$7.apply(this, arguments); }
3411
+ var ColumnsIcon = (({
3412
+ styles = {},
3413
+ ...props
3414
+ }) => /*#__PURE__*/React.createElement("svg", _extends$7({
3415
+ xmlns: "http://www.w3.org/2000/svg",
3416
+ width: "54",
3417
+ height: "54"
3418
+ }, props), /*#__PURE__*/React.createElement("path", {
3419
+ fillRule: "evenodd",
3420
+ d: "M8 33v5a1 1 0 001 1h4v2H9a3 3 0 01-3-3v-5h2zm18 6v2H15v-2h11zm13 0v2H28v-2h11zm9-6v5a3 3 0 01-3 3h-4v-2h4a1 1 0 00.993-.883L46 38v-5h2zM8 22v9H6v-9h2zm40 0v9h-2v-9h2zm-35-9v2H9a1 1 0 00-.993.883L8 16v4H6v-4a3 3 0 013-3h4zm32 0a3 3 0 013 3v4h-2v-4a1 1 0 00-.883-.993L45 15h-4v-2h4zm-6 0v2H28v-2h11zm-13 0v2H15v-2h11z"
3421
+ })));
3422
+
3423
+ function _extends$6() { _extends$6 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$6.apply(this, arguments); }
3424
+ var NumberIcon = (({
3425
+ styles = {},
3426
+ ...props
3427
+ }) => /*#__PURE__*/React.createElement("svg", _extends$6({
3428
+ xmlns: "http://www.w3.org/2000/svg",
3429
+ width: "54",
3430
+ height: "54"
3431
+ }, props), /*#__PURE__*/React.createElement("path", {
3432
+ fillRule: "evenodd",
3433
+ d: "M45 16a3 3 0 013 3v16a3 3 0 01-3 3H9a3 3 0 01-3-3V19a3 3 0 013-3h36zm0 2H9a1 1 0 00-1 1v16a1 1 0 001 1h36a1 1 0 001-1V19a1 1 0 00-1-1zM35 28.444h7l-3.5 4-3.5-4zM35 26h7l-3.5-4-3.5 4z"
3434
+ })));
3435
+
3436
+ function _extends$5() { _extends$5 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$5.apply(this, arguments); }
3437
+ var RadioIcon = (({
3438
+ styles = {},
3439
+ ...props
3440
+ }) => /*#__PURE__*/React.createElement("svg", _extends$5({
3441
+ xmlns: "http://www.w3.org/2000/svg",
3442
+ width: "54",
3443
+ height: "54"
3444
+ }, props), /*#__PURE__*/React.createElement("path", {
3445
+ d: "M27 22c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5c-5.52 0-10 4.48-10 10s4.48 10 10 10 10-4.48 10-10-4.48-10-10-10zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
3446
+ })));
3447
+
3448
+ function _extends$4() { _extends$4 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$4.apply(this, arguments); }
3449
+ var SelectIcon = (({
3450
+ styles = {},
3451
+ ...props
3452
+ }) => /*#__PURE__*/React.createElement("svg", _extends$4({
3453
+ xmlns: "http://www.w3.org/2000/svg",
3454
+ width: "54",
3455
+ height: "54"
3456
+ }, props), /*#__PURE__*/React.createElement("path", {
3457
+ fillRule: "evenodd",
3458
+ d: "M45 16a3 3 0 013 3v16a3 3 0 01-3 3H9a3 3 0 01-3-3V19a3 3 0 013-3h36zm0 2H9a1 1 0 00-1 1v16a1 1 0 001 1h36a1 1 0 001-1V19a1 1 0 00-1-1zm-12 7h9l-4.5 6-4.5-6z"
3459
+ })));
3460
+
3461
+ function _extends$3() { _extends$3 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
3462
+ var TextIcon = (({
3463
+ styles = {},
3464
+ ...props
3465
+ }) => /*#__PURE__*/React.createElement("svg", _extends$3({
3466
+ xmlns: "http://www.w3.org/2000/svg",
3467
+ width: "54",
3468
+ height: "54"
3469
+ }, props), /*#__PURE__*/React.createElement("path", {
3470
+ d: "M20.58 33.77h-3l-1.18-3.08H11l-1.1 3.08H7l5.27-13.54h2.89zm-5-5.36l-1.86-5-1.83 5zM22 20.23h5.41a15.47 15.47 0 012.4.14 3.42 3.42 0 011.41.55 3.47 3.47 0 011 1.14 3 3 0 01.42 1.58 3.26 3.26 0 01-1.91 2.94 3.63 3.63 0 011.91 1.22 3.28 3.28 0 01.66 2 4 4 0 01-.43 1.8 3.63 3.63 0 01-1.09 1.4 3.89 3.89 0 01-1.83.65q-.69.07-3.3.09H22zm2.73 2.25v3.13h3.8a1.79 1.79 0 001.1-.49 1.41 1.41 0 00.41-1 1.49 1.49 0 00-.35-1 1.54 1.54 0 00-1-.48c-.27 0-1.05-.05-2.34-.05zm0 5.39v3.62h2.57a11.52 11.52 0 001.88-.09 1.65 1.65 0 001-.54 1.6 1.6 0 00.38-1.14 1.75 1.75 0 00-.29-1 1.69 1.69 0 00-.86-.62 9.28 9.28 0 00-2.41-.23zM44.35 28.79l2.65.84a5.94 5.94 0 01-2 3.29A5.74 5.74 0 0141.38 34a5.87 5.87 0 01-4.44-1.84 7.09 7.09 0 01-1.73-5A7.43 7.43 0 0137 21.87 6 6 0 0141.54 20a5.64 5.64 0 014 1.47A5.33 5.33 0 0147 24l-2.7.65a2.8 2.8 0 00-2.86-2.27A3.09 3.09 0 0039 23.42a5.31 5.31 0 00-.93 3.5 5.62 5.62 0 00.93 3.65 3 3 0 002.4 1.09 2.72 2.72 0 001.82-.66 4 4 0 001.13-2.21z"
3471
+ })));
3472
+
3473
+ function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
3474
+ var TextfieldIcon = (({
3475
+ styles = {},
3476
+ ...props
3477
+ }) => /*#__PURE__*/React.createElement("svg", _extends$2({
3478
+ xmlns: "http://www.w3.org/2000/svg",
3479
+ width: "54",
3480
+ height: "54"
3481
+ }, props), /*#__PURE__*/React.createElement("path", {
3482
+ fillRule: "evenodd",
3483
+ d: "M45 16a3 3 0 013 3v16a3 3 0 01-3 3H9a3 3 0 01-3-3V19a3 3 0 013-3h36zm0 2H9a1 1 0 00-1 1v16a1 1 0 001 1h36a1 1 0 001-1V19a1 1 0 00-1-1zm-32 4v10h-2V22h2z"
3484
+ })));
3485
+
3486
+ function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
3487
+ var TextareaIcon = (({
3488
+ styles = {},
3489
+ ...props
3490
+ }) => /*#__PURE__*/React.createElement("svg", _extends$1({
3491
+ xmlns: "http://www.w3.org/2000/svg",
3492
+ width: "54",
3493
+ height: "54"
3494
+ }, props), /*#__PURE__*/React.createElement("path", {
3495
+ fillRule: "evenodd",
3496
+ d: "M45 13a3 3 0 013 3v22a3 3 0 01-3 3H9a3 3 0 01-3-3V16a3 3 0 013-3h36zm0 2H9a1 1 0 00-1 1v22a1 1 0 001 1h36a1 1 0 001-1V16a1 1 0 00-1-1zm-1.136 15.5l.848.849-6.363 6.363-.849-.848 6.364-6.364zm.264 3.5l.849.849-2.828 2.828-.849-.849L44.128 34zM13 19v10h-2V19h2z"
3497
+ })));
3498
+
3499
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3500
+ var ImageIcon = (({
3501
+ styles = {},
3502
+ ...props
3503
+ }) => /*#__PURE__*/React.createElement("svg", _extends({
3504
+ width: "54",
3505
+ height: "54",
3506
+ fill: "none",
3507
+ xmlns: "http://www.w3.org/2000/svg"
3508
+ }, props), /*#__PURE__*/React.createElement("path", {
3509
+ fillRule: "evenodd",
3510
+ clipRule: "evenodd",
3511
+ d: "M34.636 21.91A3.818 3.818 0 1127 21.908a3.818 3.818 0 017.636 0zm-2 0A1.818 1.818 0 1129 21.908a1.818 1.818 0 013.636 0z",
3512
+ fill: "#000"
3513
+ }), /*#__PURE__*/React.createElement("path", {
3514
+ fillRule: "evenodd",
3515
+ clipRule: "evenodd",
3516
+ d: "M15 13a2 2 0 00-2 2v24a2 2 0 002 2h24a2 2 0 002-2V15a2 2 0 00-2-2H15zm24 2H15v12.45l4.71-4.709a1.91 1.91 0 012.702 0l6.695 6.695 2.656-1.77a1.91 1.91 0 012.411.239L39 32.73V15zM15 39v-8.754c.06-.038.116-.083.168-.135l5.893-5.893 6.684 6.685a1.911 1.911 0 002.41.238l2.657-1.77 6.02 6.02c.052.051.108.097.168.135V39H15z",
3517
+ fill: "#000"
3518
+ })));
3519
+
3520
+ const iconsByType = {
3521
+ button: ButtonIcon,
3522
+ checkbox: CheckboxIcon,
3523
+ checklist: ChecklistIcon,
3524
+ columns: ColumnsIcon,
3525
+ datetime: DatetimeIcon,
3526
+ image: ImageIcon,
3527
+ number: NumberIcon,
3528
+ radio: RadioIcon,
3529
+ select: SelectIcon,
3530
+ taglist: TaglistIcon,
3531
+ text: TextIcon,
3532
+ textfield: TextfieldIcon,
3533
+ textarea: TextareaIcon,
3534
+ default: FormIcon
3535
+ };
3536
+
2476
3537
  const type$2 = 'text';
2477
3538
  function Text(props) {
2478
3539
  const {
2479
- field
3540
+ field,
3541
+ disabled
2480
3542
  } = props;
2481
3543
  const {
2482
3544
  text = ''
2483
3545
  } = field;
3546
+ const textValue = useExpressionValue(text) || '';
2484
3547
  return jsx("div", {
2485
3548
  class: formFieldClasses(type$2),
2486
- children: jsx(Markup, {
2487
- markup: safeMarkdown(text),
2488
- trim: false
2489
- })
3549
+ children: renderText(field, textValue, disabled)
2490
3550
  });
2491
3551
  }
2492
3552
  Text.create = function (options = {}) {
@@ -2498,6 +3558,37 @@ Text.create = function (options = {}) {
2498
3558
  Text.type = type$2;
2499
3559
  Text.keyed = false;
2500
3560
 
3561
+ // helper //////////////
3562
+
3563
+ function renderText(field, content, disabled) {
3564
+ const {
3565
+ text
3566
+ } = field;
3567
+ const Icon = iconsByType['text'];
3568
+ if (disabled) {
3569
+ if (!text) {
3570
+ return jsxs("div", {
3571
+ class: "fjs-form-field-placeholder",
3572
+ children: [jsx(Icon, {
3573
+ viewBox: "0 0 54 54"
3574
+ }), "Text view is empty"]
3575
+ });
3576
+ }
3577
+ if (isExpression$2(text)) {
3578
+ return jsxs("div", {
3579
+ class: "fjs-form-field-placeholder",
3580
+ children: [jsx(Icon, {
3581
+ viewBox: "0 0 54 54"
3582
+ }), "Text view is populated by an expression"]
3583
+ });
3584
+ }
3585
+ }
3586
+ return jsx(Markup, {
3587
+ markup: safeMarkdown(content),
3588
+ trim: false
3589
+ });
3590
+ }
3591
+
2501
3592
  const type$1 = 'textfield';
2502
3593
  function Textfield(props) {
2503
3594
  const {
@@ -2510,8 +3601,13 @@ function Textfield(props) {
2510
3601
  description,
2511
3602
  id,
2512
3603
  label,
3604
+ appearance = {},
2513
3605
  validate = {}
2514
3606
  } = field;
3607
+ const {
3608
+ prefixAdorner,
3609
+ suffixAdorner
3610
+ } = appearance;
2515
3611
  const {
2516
3612
  required
2517
3613
  } = validate;
@@ -2535,13 +3631,18 @@ function Textfield(props) {
2535
3631
  id: prefixId(id, formId),
2536
3632
  label: label,
2537
3633
  required: required
2538
- }), jsx("input", {
2539
- class: "fjs-input",
3634
+ }), jsx(InputAdorner, {
2540
3635
  disabled: disabled,
2541
- id: prefixId(id, formId),
2542
- onInput: onChange,
2543
- type: "text",
2544
- value: value
3636
+ pre: prefixAdorner,
3637
+ post: suffixAdorner,
3638
+ children: jsx("input", {
3639
+ class: "fjs-input",
3640
+ disabled: disabled,
3641
+ id: prefixId(id, formId),
3642
+ onInput: onChange,
3643
+ type: "text",
3644
+ value: value
3645
+ })
2545
3646
  }), jsx(Description, {
2546
3647
  description: description
2547
3648
  }), jsx(Errors, {
@@ -2643,7 +3744,7 @@ Textarea.sanitizeValue = ({
2643
3744
  value
2644
3745
  }) => isArray(value) || isObject(value) ? '' : String(value);
2645
3746
 
2646
- const formFields = [Button, Checkbox, Checklist, Default, Image, Numberfield, Radio, Select, Taglist, Text, Textfield, Textarea];
3747
+ const formFields = [Button, Checkbox, Checklist, Default, Image, Numberfield, Datetime, Radio, Select, Taglist, Text, Textfield, Textarea];
2647
3748
 
2648
3749
  class FormFields {
2649
3750
  constructor() {
@@ -3120,5 +4221,5 @@ function createForm(options) {
3120
4221
  });
3121
4222
  }
3122
4223
 
3123
- export { Button, Checkbox, Checklist, Default, Form, FormComponent, FormContext, FormFieldRegistry, FormFields, FormRenderContext, Image, Numberfield, Radio, Select, Taglist, Text, Textarea, Textfield, clone, createForm, createFormContainer, createInjector, findErrors, formFields, generateIdForType, generateIndexForType, getSchemaVariables, isRequired, pathParse, pathStringify, pathsEqual, schemaVersion };
4224
+ export { Button, Checkbox, Checklist, DATETIME_SUBTYPES, DATETIME_SUBTYPES_LABELS, DATETIME_SUBTYPE_PATH, DATE_DISALLOW_PAST_PATH, DATE_LABEL_PATH, Datetime, Default, Form, FormComponent, FormContext, FormFieldRegistry, FormFields, FormRenderContext, Image, MINUTES_IN_DAY, Numberfield, Radio, Select, TIME_INTERVAL_PATH, TIME_LABEL_PATH, TIME_SERIALISINGFORMAT_LABELS, TIME_SERIALISING_FORMATS, TIME_SERIALISING_FORMAT_PATH, TIME_USE24H_PATH, Taglist, Text, Textarea, Textfield, VALUES_SOURCES, VALUES_SOURCES_DEFAULTS, VALUES_SOURCES_LABELS, VALUES_SOURCES_PATHS, VALUES_SOURCE_DEFAULT, clone, createForm, createFormContainer, createInjector, findErrors, formFields, generateIdForType, generateIndexForType, getSchemaVariables, getValuesSource, iconsByType, isRequired, pathParse, pathStringify, pathsEqual, schemaVersion };
3124
4225
  //# sourceMappingURL=index.es.js.map