react-input-material 0.0.352 → 0.0.356

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 (45) hide show
  1. package/components/Dummy.d.ts +9 -5
  2. package/components/Dummy.tsx +11 -6
  3. package/components/FileInput.d.ts +3 -2
  4. package/components/FileInput.js +1 -1
  5. package/components/FileInput.module.css +12 -24
  6. package/components/FileInput.styles.css +3 -3
  7. package/components/FileInput.tsx +239 -203
  8. package/components/GenericAnimate.d.ts +3 -0
  9. package/components/GenericAnimate.module.css +0 -1
  10. package/components/GenericAnimate.tsx +17 -10
  11. package/components/GenericInput.d.ts +26 -2
  12. package/components/GenericInput.js +1 -1
  13. package/components/GenericInput.module.css +32 -45
  14. package/components/GenericInput.styles.css +1 -1
  15. package/components/GenericInput.tsx +471 -348
  16. package/components/Inputs.d.ts +3 -3
  17. package/components/Inputs.js +1 -1
  18. package/components/Inputs.module.css +10 -9
  19. package/components/Inputs.styles.css +2 -2
  20. package/components/Inputs.tsx +20 -21
  21. package/components/Interval.d.ts +4 -6
  22. package/components/Interval.js +1 -1
  23. package/components/Interval.module.css +16 -15
  24. package/components/Interval.styles.css +2 -2
  25. package/components/Interval.tsx +7 -13
  26. package/components/RequireableCheckbox.d.ts +10 -3
  27. package/components/RequireableCheckbox.js +1 -1
  28. package/components/RequireableCheckbox.module.css +4 -4
  29. package/components/RequireableCheckbox.styles.css +1 -1
  30. package/components/RequireableCheckbox.tsx +66 -51
  31. package/components/WrapConfigurations.d.ts +13 -0
  32. package/components/WrapConfigurations.tsx +17 -5
  33. package/components/WrapStrict.d.ts +6 -0
  34. package/components/WrapStrict.tsx +7 -0
  35. package/components/WrapThemeProvider.d.ts +7 -5
  36. package/components/WrapThemeProvider.tsx +8 -5
  37. package/components/WrapTooltip.d.ts +4 -2
  38. package/components/WrapTooltip.tsx +14 -6
  39. package/helper.d.ts +39 -9
  40. package/helper.js +1 -1
  41. package/index.js +1 -1
  42. package/index.styles.css +10 -10
  43. package/package.json +36 -28
  44. package/readme.md +38 -2
  45. package/type.d.ts +42 -42
@@ -19,7 +19,7 @@
19
19
  // region imports
20
20
  import {Ace as CodeEditorNamespace} from 'ace-builds'
21
21
  import Tools, {optionalRequire} from 'clientnode'
22
- import {EvaluationResult, FirstParameter, Mapping} from 'clientnode/type'
22
+ import {EvaluationResult} from 'clientnode/type'
23
23
  import {
24
24
  ComponentType,
25
25
  FocusEvent as ReactFocusEvent,
@@ -31,7 +31,6 @@ import {
31
31
  MouseEvent as ReactMouseEvent,
32
32
  MutableRefObject,
33
33
  ReactElement,
34
- RefCallback,
35
34
  Suspense,
36
35
  useEffect,
37
36
  useImperativeHandle,
@@ -124,8 +123,8 @@ import {
124
123
  InputValueState as ValueState
125
124
  } from '../type'
126
125
 
127
- declare var TARGET_TECHNOLOGY:string
128
- const isBrowser:boolean =
126
+ declare const TARGET_TECHNOLOGY:string
127
+ const isBrowser =
129
128
  !(TARGET_TECHNOLOGY === 'node' || typeof window === undefined)
130
129
  const UseAnimations:any|null =
131
130
  isBrowser ? optionalRequire('react-useanimations') : null
@@ -154,14 +153,12 @@ export type TinyMCEOptions = RawTinyMCEEditorSettings & {
154
153
  selector?:undefined
155
154
  target?:undefined
156
155
  }
157
- declare var UTC_BUILD_TIMESTAMP:number
156
+ declare const UTC_BUILD_TIMESTAMP:number|undefined
158
157
  // NOTE: Could be set via module bundler environment variables.
159
- if (typeof UTC_BUILD_TIMESTAMP === 'undefined')
160
- /* eslint-disable no-var */
161
- var UTC_BUILD_TIMESTAMP:number = 1
162
- /* eslint-enable no-var */
163
- let richTextEditorLoadedOnce:boolean = false
164
- const tinymceBasePath:string = '/node_modules/tinymce/'
158
+ const CURRENT_UTC_BUILD_TIMESTAMP =
159
+ typeof UTC_BUILD_TIMESTAMP === 'undefined' ? 1 : UTC_BUILD_TIMESTAMP
160
+ let richTextEditorLoadedOnce = false
161
+ const tinymceBasePath = '/node_modules/tinymce/'
165
162
  export const TINYMCE_DEFAULT_OPTIONS:TinyMCEOptions = {
166
163
  /* eslint-disable camelcase */
167
164
  // region paths
@@ -173,7 +170,7 @@ export const TINYMCE_DEFAULT_OPTIONS:TinyMCEOptions = {
173
170
  allow_script_urls: false,
174
171
  body_class: 'mdc-text-field__input',
175
172
  branding: false,
176
- cache_suffix: `?version=${UTC_BUILD_TIMESTAMP}`,
173
+ cache_suffix: `?version=${CURRENT_UTC_BUILD_TIMESTAMP}`,
177
174
  contextmenu: false,
178
175
  convert_fonts_to_spans: true,
179
176
  document_base_url: '/',
@@ -193,15 +190,28 @@ export const TINYMCE_DEFAULT_OPTIONS:TinyMCEOptions = {
193
190
  remove_script_host: false,
194
191
  remove_trailing_brs: true,
195
192
  schema: 'html5',
196
- /* eslint-disable max-len */
197
- toolbar1: 'cut copy paste | undo redo removeformat | styleselect formatselect fontselect fontsizeselect | searchreplace visualblocks fullscreen code',
198
- toolbar2: 'alignleft aligncenter alignright alignjustify outdent indent | link hr nonbreaking bullist numlist bold italic underline strikethrough',
199
- /* eslint-enable max-len */
193
+ toolbar1: `
194
+ cut copy paste |
195
+ undo redo removeformat |
196
+ styleselect formatselect fontselect fontsizeselect |
197
+ searchreplace visualblocks fullscreen code
198
+ `.trim(),
199
+ toolbar2: `
200
+ alignleft aligncenter alignright alignjustify outdent indent |
201
+ link hr nonbreaking bullist numlist bold italic underline strikethrough
202
+ `.trim(),
200
203
  trim: true
201
204
  /* eslint-enable camelcase */
202
205
  }
203
206
  // endregion
204
207
  // region static helper
208
+ /**
209
+ * Derives validation state from provided properties and state.
210
+ * @param properties - Current component properties.
211
+ * @param currentState - Current component state.
212
+ *
213
+ * @returns Whether component is in an aggregated valid or invalid state.
214
+ */
205
215
  export function determineValidationState<T>(
206
216
  properties:DefaultProperties<T>, currentState:Partial<ModelState>
207
217
  ):boolean {
@@ -270,19 +280,37 @@ export function determineValidationState<T>(
270
280
  }
271
281
  )
272
282
  }
283
+ /**
284
+ * Avoid propagating the enter key event since this usually sends a form which
285
+ * is not intended when working in a text field.
286
+ * @param event - Keyboard event.
287
+ *
288
+ * @returns Nothing.
289
+ */
273
290
  export function preventEnterKeyPropagation(event:ReactKeyboardEvent):void {
274
291
  if (Tools.keyCode.ENTER === event.keyCode)
275
292
  event.stopPropagation()
276
293
  }
294
+ /**
295
+ * Indicates whether a provided query is matching currently provided
296
+ * suggestion.
297
+ * @param suggestion - Candidate to match again.
298
+ * @param query - Search query to check for matching.
299
+ *
300
+ * @returns Boolean result whether provided suggestion matches given query or
301
+ * not.
302
+ */
277
303
  export function suggestionMatches(
278
304
  suggestion:string, query?:null|string
279
305
  ):boolean {
280
306
  if (query) {
281
307
  suggestion = suggestion.toLowerCase()
282
308
 
283
- return query.replace(/ +/g, ' ').toLowerCase().split(' ').every(
284
- (part:string):boolean => suggestion.includes(part)
285
- )
309
+ return query
310
+ .replace(/ +/g, ' ')
311
+ .toLowerCase()
312
+ .split(' ')
313
+ .every((part:string):boolean => suggestion.includes(part))
286
314
  }
287
315
 
288
316
  return false
@@ -304,12 +332,12 @@ export function suggestionMatches(
304
332
  * 4. All state changes except selection changes trigger an "onChange" event
305
333
  * which delivers the consolidated properties object (with latest
306
334
  * modifications included).
307
- *
308
335
  * @property static:displayName - Descriptive name for component to show in web
309
336
  * developer tools.
310
337
  *
311
338
  * @param props - Given components properties.
312
339
  * @param reference - Reference object to forward internal state.
340
+ *
313
341
  * @returns React elements.
314
342
  */
315
343
  export const GenericInputInner = function<Type = unknown>(
@@ -350,6 +378,7 @@ export const GenericInputInner = function<Type = unknown>(
350
378
  )
351
379
  }
352
380
  } else if (inputReference.current) {
381
+ // eslint-disable-next-line @typescript-eslint/no-extra-semi
353
382
  ;(
354
383
  inputReference.current as
355
384
  HTMLInputElement|HTMLTextAreaElement
@@ -370,7 +399,8 @@ export const GenericInputInner = function<Type = unknown>(
370
399
  /**
371
400
  * Applies icon preset configurations.
372
401
  * @param options - Icon options to extend of known preset identified.
373
- * @return Given potential extended icon configuration.
402
+ *
403
+ * @returns Given potential extended icon configuration.
374
404
  */
375
405
  const applyIconPreset = (
376
406
  options?:Properties['icon']
@@ -438,6 +468,7 @@ export const GenericInputInner = function<Type = unknown>(
438
468
  * Derives native input type from given input property configuration.
439
469
  * @param properties - Input configuration to derive native input type
440
470
  * from.
471
+ *
441
472
  * @returns Determined input type.
442
473
  */
443
474
  const determineNativeType = (
@@ -448,20 +479,22 @@ export const GenericInputInner = function<Type = unknown>(
448
479
  properties.hidden ?
449
480
  'password' :
450
481
  'text' :
451
- transformer[
452
- properties.type as keyof InputDataTransformation
453
- ]?.type ?? properties.type
482
+ transformer[
483
+ properties.type as keyof InputDataTransformation
484
+ ]?.type ?? properties.type
454
485
  ) as NativeInputType
455
486
  /**
456
487
  * Render help or error texts with current validation state color.
457
- * @return Determined renderable markup specification.
488
+ * @returns Determined renderable markup specification.
458
489
  */
459
490
  const renderHelpText = ():ReactElement => <>
460
- <GenericAnimate in={
461
- properties.selectableEditor &&
462
- properties.type === 'string' &&
463
- properties.editor !== 'plain'
464
- }>
491
+ <GenericAnimate
492
+ in={
493
+ properties.selectableEditor &&
494
+ properties.type === 'string' &&
495
+ properties.editor !== 'plain'
496
+ }
497
+ >
465
498
  <IconButton
466
499
  icon={{
467
500
  icon: properties.editorIsActive ?
@@ -521,21 +554,22 @@ export const GenericInputInner = function<Type = unknown>(
521
554
  * Renders given template string against all properties in current
522
555
  * instance.
523
556
  * @param template - Template to render.
557
+ *
524
558
  * @returns Evaluated template or an empty string if something goes wrong.
525
559
  */
526
560
  const renderMessage = (template?:any):string => {
527
561
  if (typeof template === 'string') {
528
562
  const evaluated:EvaluationResult = Tools.stringEvaluate(
529
563
  `\`${template}\``,
530
- {
531
- formatValue: (value:Type):string =>
532
- formatValue<Type>(properties, value, transformer),
533
- ...properties
564
+ {
565
+ formatValue: (value:Type):string =>
566
+ formatValue<Type>(properties, value, transformer),
567
+ ...properties
534
568
  }
535
569
  )
536
570
  if (evaluated.error) {
537
571
  console.warn(
538
- 'Given message template could not be proceed: ' +
572
+ 'Given message template could not be proceed:',
539
573
  evaluated.error
540
574
  )
541
575
  return ''
@@ -549,13 +583,16 @@ export const GenericInputInner = function<Type = unknown>(
549
583
  * @param content - Component or string to wrap.
550
584
  * @param propertiesOrInCondition - Animation properties or in condition
551
585
  * only.
586
+ * @param condition - Show condition.
587
+ *
552
588
  * @returns Wrapped component.
553
589
  */
554
590
  const wrapAnimationConditionally = (
555
591
  content:Renderable,
556
- propertiesOrInCondition:boolean|Partial<TransitionProps<HTMLElement|undefined>> =
557
- {},
558
- condition:boolean = true
592
+ propertiesOrInCondition:(
593
+ boolean|Partial<TransitionProps<HTMLElement|undefined>>
594
+ ) = {},
595
+ condition = true
559
596
  ):Renderable => {
560
597
  if (typeof propertiesOrInCondition === 'boolean')
561
598
  return condition ?
@@ -563,6 +600,7 @@ export const GenericInputInner = function<Type = unknown>(
563
600
  {content}
564
601
  </GenericAnimate> :
565
602
  propertiesOrInCondition ? content : ''
603
+
566
604
  return condition ?
567
605
  <GenericAnimate {...propertiesOrInCondition}>
568
606
  {content}
@@ -575,6 +613,7 @@ export const GenericInputInner = function<Type = unknown>(
575
613
  * tooltip configuration.
576
614
  * @param options - Icon configuration potential extended a tooltip
577
615
  * configuration.
616
+ *
578
617
  * @returns Resolved icon configuration.
579
618
  */
580
619
  const wrapIconWithTooltip = (
@@ -601,6 +640,7 @@ export const GenericInputInner = function<Type = unknown>(
601
640
  * contained.
602
641
  * @param domNode - Dom node which contains given position.
603
642
  * @param offset - Relative position within given node.
643
+ *
604
644
  * @returns Determine absolute offset.
605
645
  */
606
646
  const determineAbsoluteSymbolOffsetFromHTML = (
@@ -609,9 +649,9 @@ export const GenericInputInner = function<Type = unknown>(
609
649
  if (!properties.value)
610
650
  return 0
611
651
 
612
- const indicatorKey:string = 'generic-input-selection-indicator'
613
- const indicatorValue:string = '###'
614
- const indicator:string = ` ${indicatorKey}="${indicatorValue}"`
652
+ const indicatorKey = 'generic-input-selection-indicator'
653
+ const indicatorValue = '###'
654
+ const indicator = ` ${indicatorKey}="${indicatorValue}"`
615
655
 
616
656
  domNode.setAttribute(indicatorKey, indicatorValue)
617
657
  // NOTE: TinyMCE seems to add a newline after each paragraph.
@@ -636,6 +676,7 @@ export const GenericInputInner = function<Type = unknown>(
636
676
  * Determines absolute range from table oriented position.
637
677
  * @param column - Symbol offset in given row.
638
678
  * @param row - Offset row.
679
+ *
639
680
  * @returns Determined offset.
640
681
  */
641
682
  const determineAbsoluteSymbolOffsetFromTable = (
@@ -655,6 +696,7 @@ export const GenericInputInner = function<Type = unknown>(
655
696
  /**
656
697
  * Converts absolute range into table oriented position.
657
698
  * @param offset - Absolute position.
699
+ *
658
700
  * @returns Position.
659
701
  */
660
702
  const determineTablePosition = (offset:number):TablePosition => {
@@ -677,6 +719,7 @@ export const GenericInputInner = function<Type = unknown>(
677
719
  /**
678
720
  * Sets current cursor selection range in given code editor instance.
679
721
  * @param instance - Code editor instance.
722
+ *
680
723
  * @returns Nothing.
681
724
  */
682
725
  const setCodeEditorSelectionState = (instance:CodeEditorType):void => {
@@ -693,6 +736,7 @@ export const GenericInputInner = function<Type = unknown>(
693
736
  /**
694
737
  * Sets current cursor selection range in given rich text editor instance.
695
738
  * @param instance - Code editor instance.
739
+ *
696
740
  * @returns Nothing.
697
741
  */
698
742
  const setRichTextEditorSelectionState = (instance:RichTextEditor):void => {
@@ -713,9 +757,9 @@ export const GenericInputInner = function<Type = unknown>(
713
757
  let value:string = properties.representation
714
758
  for (const type of keysSorted)
715
759
  value = (
716
- value.substring(0, cursor[type as keyof typeof indicator]) +
760
+ value.substring(0, cursor[type]) +
717
761
  indicator[type] +
718
- value.substring(cursor[type as keyof typeof indicator])
762
+ value.substring(cursor[type])
719
763
  )
720
764
  instance.getBody().innerHTML = value
721
765
 
@@ -728,9 +772,10 @@ export const GenericInputInner = function<Type = unknown>(
728
772
  end?:[Node, number]
729
773
  start?:[Node, number]
730
774
  } = {}
731
- let node
775
+
776
+ let node:Node|null
732
777
  while (node = walker.nextNode())
733
- for (const type of keysSorted) {
778
+ for (const type of keysSorted)
734
779
  if (node.nodeValue) {
735
780
  const index:number =
736
781
  node.nodeValue.indexOf(indicator[type])
@@ -738,16 +783,17 @@ export const GenericInputInner = function<Type = unknown>(
738
783
  node.nodeValue = node.nodeValue.replace(
739
784
  indicator[type], ''
740
785
  )
786
+
741
787
  result[type] = [node, index]
742
788
  }
743
789
  }
744
- }
745
790
 
746
791
  for (const type of keysSorted)
747
792
  if (result[type])
748
793
  range[
749
794
  `set${Tools.stringCapitalize(type)}` as 'setEnd'|'setStart'
750
795
  ](...(result[type] as [Node, number]))
796
+
751
797
  if (result.end && result.start)
752
798
  instance.selection.setRng(range)
753
799
  }
@@ -755,6 +801,7 @@ export const GenericInputInner = function<Type = unknown>(
755
801
  /**
756
802
  * Saves current selection/cursor state in components state.
757
803
  * @param event - Event which triggered selection change.
804
+ *
758
805
  * @returns Nothing.
759
806
  */
760
807
  const saveSelectionState = (event:GenericEvent):void => {
@@ -810,11 +857,11 @@ export const GenericInputInner = function<Type = unknown>(
810
857
  ) {
811
858
  const add:0|1|-1 =
812
859
  (event as unknown as KeyboardEvent)?.key?.length === 1 ?
813
- 1 :
814
- (event as unknown as KeyboardEvent)?.key === 'Backspace' &&
815
- properties.representation.length > selectionStart ?
816
- -1 :
817
- 0
860
+ 1 :
861
+ (event as unknown as KeyboardEvent)?.key === 'Backspace' &&
862
+ properties.representation.length > selectionStart ?
863
+ -1 :
864
+ 0
818
865
  setCursor({end: selectionEnd + add, start: selectionStart + add})
819
866
  }
820
867
  }
@@ -872,6 +919,7 @@ export const GenericInputInner = function<Type = unknown>(
872
919
  * Properties overwrites default properties which overwrites default model
873
920
  * properties.
874
921
  * @param properties - Properties to merge.
922
+ *
875
923
  * @returns Nothing.
876
924
  */
877
925
  const mapPropertiesAndValidationStateIntoModel = (
@@ -894,6 +942,7 @@ export const GenericInputInner = function<Type = unknown>(
894
942
  /**
895
943
  * Calculate external properties (a set of all configurable properties).
896
944
  * @param properties - Properties to merge.
945
+ *
897
946
  * @returns External properties object.
898
947
  */
899
948
  const getConsolidatedProperties = (
@@ -949,12 +998,15 @@ export const GenericInputInner = function<Type = unknown>(
949
998
  /**
950
999
  * Set code editor references.
951
1000
  * @param instance - Code editor instance.
1001
+ *
952
1002
  * @returns Nothing.
953
1003
  */
954
1004
  const setCodeEditorReference = (instance:CodeEditorType|null):void => {
955
1005
  codeEditorReference.current = instance
956
1006
 
957
- if (codeEditorReference.current?.editor?.container?.querySelector('textarea'))
1007
+ if (codeEditorReference.current?.editor?.container?.querySelector(
1008
+ 'textarea'
1009
+ ))
958
1010
  codeEditorInputReference.current =
959
1011
  codeEditorReference.current.editor.container
960
1012
  .querySelector('textarea')
@@ -972,6 +1024,7 @@ export const GenericInputInner = function<Type = unknown>(
972
1024
  /**
973
1025
  * Set rich text editor references.
974
1026
  * @param instance - Editor instance.
1027
+ *
975
1028
  * @returns Nothing.
976
1029
  */
977
1030
  const setRichTextEditorReference = (
@@ -993,6 +1046,7 @@ export const GenericInputInner = function<Type = unknown>(
993
1046
  /**
994
1047
  * Triggered on blur events.
995
1048
  * @param event - Event object.
1049
+ *
996
1050
  * @returns Nothing.
997
1051
  */
998
1052
  const onBlur = (event:GenericEvent):void => setValueState((
@@ -1000,8 +1054,8 @@ export const GenericInputInner = function<Type = unknown>(
1000
1054
  ):ValueState<Type, ModelState> => {
1001
1055
  setIsSuggestionOpen(false)
1002
1056
 
1003
- let changed:boolean = false
1004
- let stateChanged:boolean = false
1057
+ let changed = false
1058
+ let stateChanged = false
1005
1059
 
1006
1060
  if (oldValueState.modelState.focused) {
1007
1061
  properties.focused = false
@@ -1024,7 +1078,7 @@ export const GenericInputInner = function<Type = unknown>(
1024
1078
  properties, properties.value as null|Type, transformer
1025
1079
  )
1026
1080
  properties.representation = formatValue<Type>(
1027
- properties, properties.value as null|Type, transformer
1081
+ properties, properties.value, transformer
1028
1082
  )
1029
1083
  } else
1030
1084
  properties.value = candidate
@@ -1075,6 +1129,7 @@ export const GenericInputInner = function<Type = unknown>(
1075
1129
  * Triggered on any change events. Consolidates properties object and
1076
1130
  * triggers given on change callbacks.
1077
1131
  * @param event - Potential event object.
1132
+ *
1078
1133
  * @returns Nothing.
1079
1134
  */
1080
1135
  const onChange = (event?:GenericEvent):void => {
@@ -1097,6 +1152,7 @@ export const GenericInputInner = function<Type = unknown>(
1097
1152
  /**
1098
1153
  * Triggered when editor is active indicator should be changed.
1099
1154
  * @param event - Mouse event object.
1155
+ *
1100
1156
  * @returns Nothing.
1101
1157
  */
1102
1158
  const onChangeEditorIsActive = (event?:ReactMouseEvent):void => {
@@ -1128,6 +1184,7 @@ export const GenericInputInner = function<Type = unknown>(
1128
1184
  /**
1129
1185
  * Triggered when show declaration indicator should be changed.
1130
1186
  * @param event - Potential event object.
1187
+ *
1131
1188
  * @returns Nothing.
1132
1189
  */
1133
1190
  const onChangeShowDeclaration = (event?:ReactMouseEvent):void => {
@@ -1158,7 +1215,6 @@ export const GenericInputInner = function<Type = unknown>(
1158
1215
  * generates new value state (internal value, representation and validation
1159
1216
  * states). Derived event handler will be triggered when internal state
1160
1217
  * has been consolidated.
1161
- *
1162
1218
  * @param eventOrValue - Event object or new value.
1163
1219
  * @param editorInstance - Potential editor instance if triggered from a
1164
1220
  * rich text or code editor.
@@ -1170,7 +1226,7 @@ export const GenericInputInner = function<Type = unknown>(
1170
1226
  const onChangeValue = (
1171
1227
  eventOrValue:GenericEvent|null|Type,
1172
1228
  editorInstance?:RichTextEditor,
1173
- selectedIndex:number = -1
1229
+ selectedIndex = -1
1174
1230
  ):void => {
1175
1231
  if (properties.disabled)
1176
1232
  return
@@ -1189,7 +1245,7 @@ export const GenericInputInner = function<Type = unknown>(
1189
1245
  else
1190
1246
  properties.value = eventOrValue as null|Type
1191
1247
  } else
1192
- properties.value = eventOrValue as null|Type
1248
+ properties.value = eventOrValue
1193
1249
 
1194
1250
  const setHelper = ():void => setValueState((
1195
1251
  oldValueState:ValueState<Type, ModelState>
@@ -1232,7 +1288,7 @@ export const GenericInputInner = function<Type = unknown>(
1232
1288
 
1233
1289
  valueState.value = properties.value as null|Type
1234
1290
 
1235
- let stateChanged:boolean = false
1291
+ let stateChanged = false
1236
1292
 
1237
1293
  if (oldValueState.modelState.pristine) {
1238
1294
  properties.dirty = true
@@ -1317,7 +1373,7 @@ export const GenericInputInner = function<Type = unknown>(
1317
1373
  )
1318
1374
  oldSelection.abort()
1319
1375
 
1320
- return results as Properties['selection']
1376
+ return results
1321
1377
  })
1322
1378
 
1323
1379
  if (selectedIndex === -1) {
@@ -1342,12 +1398,13 @@ export const GenericInputInner = function<Type = unknown>(
1342
1398
  Trigger asynchronous suggestions retrieving and delayed state
1343
1399
  consolidation.
1344
1400
  */
1345
- const result:Properties['selection']|Promise<Properties['selection']> =
1346
- properties.suggestionCreator({
1347
- abortController,
1348
- properties,
1349
- query: properties.representation
1350
- })
1401
+ const result:(
1402
+ Properties['selection']|Promise<Properties['selection']>
1403
+ ) = properties.suggestionCreator({
1404
+ abortController,
1405
+ properties,
1406
+ query: properties.representation
1407
+ })
1351
1408
 
1352
1409
  if ((result as Promise<Properties['selection']>)?.then) {
1353
1410
  setSelection((
@@ -1383,7 +1440,10 @@ export const GenericInputInner = function<Type = unknown>(
1383
1440
  onResultsRetrieved(result as Properties['selection'])
1384
1441
  } else {
1385
1442
  if (selectedIndex === -1) {
1386
- // Map value from given selections and trigger state consolidation.
1443
+ /*
1444
+ Map value from given selections and trigger state
1445
+ consolidation.
1446
+ */
1387
1447
  const result:null|Type = getValueFromSelection<Type>(
1388
1448
  properties.representation, normalizedSelection
1389
1449
  )
@@ -1404,6 +1464,7 @@ export const GenericInputInner = function<Type = unknown>(
1404
1464
  /**
1405
1465
  * Triggered on click events.
1406
1466
  * @param event - Mouse event object.
1467
+ *
1407
1468
  * @returns Nothing.
1408
1469
  */
1409
1470
  const onClick = (event:ReactMouseEvent):void => {
@@ -1418,6 +1479,7 @@ export const GenericInputInner = function<Type = unknown>(
1418
1479
  /**
1419
1480
  * Triggered on focus events and opens suggestions.
1420
1481
  * @param event - Focus event object.
1482
+ *
1421
1483
  * @returns Nothing.
1422
1484
  */
1423
1485
  const triggerOnFocusAndOpenSuggestions = (event:ReactFocusEvent):void => {
@@ -1428,6 +1490,7 @@ export const GenericInputInner = function<Type = unknown>(
1428
1490
  /**
1429
1491
  * Triggered on focus events.
1430
1492
  * @param event - Focus event object.
1493
+ *
1431
1494
  * @returns Nothing.
1432
1495
  */
1433
1496
  const onFocus = (event:ReactFocusEvent):void => {
@@ -1440,6 +1503,7 @@ export const GenericInputInner = function<Type = unknown>(
1440
1503
  /**
1441
1504
  * Triggered on down up events.
1442
1505
  * @param event - Key up event object.
1506
+ *
1443
1507
  * @returns Nothing.
1444
1508
  */
1445
1509
  const onKeyDown = (event:ReactKeyboardEvent):void => {
@@ -1460,6 +1524,7 @@ export const GenericInputInner = function<Type = unknown>(
1460
1524
  /**
1461
1525
  * Triggered on key up events.
1462
1526
  * @param event - Key up event object.
1527
+ *
1463
1528
  * @returns Nothing.
1464
1529
  */
1465
1530
  const onKeyUp = (event:ReactKeyboardEvent):void => {
@@ -1475,6 +1540,7 @@ export const GenericInputInner = function<Type = unknown>(
1475
1540
  /**
1476
1541
  * Triggered on selection change events.
1477
1542
  * @param event - Event which triggered selection change.
1543
+ *
1478
1544
  * @returns Nothing.
1479
1545
  */
1480
1546
  const onSelectionChange = (event:GenericEvent):void => {
@@ -1487,13 +1553,14 @@ export const GenericInputInner = function<Type = unknown>(
1487
1553
  /**
1488
1554
  * Triggers on start interacting with the input.
1489
1555
  * @param event - Event object which triggered interaction.
1556
+ *
1490
1557
  * @returns Nothing.
1491
1558
  */
1492
1559
  const onTouch = (event:ReactFocusEvent|ReactMouseEvent):void =>
1493
1560
  setValueState((
1494
1561
  oldValueState:ValueState<Type, ModelState>
1495
1562
  ):ValueState<Type, ModelState> => {
1496
- let changedState:boolean = false
1563
+ let changedState = false
1497
1564
 
1498
1565
  if (!oldValueState.modelState.focused) {
1499
1566
  properties.focused = true
@@ -1534,7 +1601,7 @@ export const GenericInputInner = function<Type = unknown>(
1534
1601
  // / region references
1535
1602
  const codeEditorReference:MutableRefObject<CodeEditorType|null> =
1536
1603
  useRef<CodeEditorType>(null)
1537
- let codeEditorInputReference:MutableRefObject<HTMLTextAreaElement|null> =
1604
+ const codeEditorInputReference:MutableRefObject<HTMLTextAreaElement|null> =
1538
1605
  useRef<HTMLTextAreaElement>(null)
1539
1606
  const foundationReference:MutableRefObject<
1540
1607
  MDCSelectFoundation|MDCTextFieldFoundation|null
@@ -1559,12 +1626,12 @@ export const GenericInputInner = function<Type = unknown>(
1559
1626
  const givenProps:Props<Type> = translateKnownSymbols(props)
1560
1627
 
1561
1628
  const [cursor, setCursor] = useState<CursorState>({end: 0, start: 0})
1562
- let [editorState, setEditorState] = useState<EditorState>({
1629
+ const [editorState, setEditorState] = useState<EditorState>({
1563
1630
  editorIsActive: false, selectionIsUnstable: false
1564
1631
  })
1565
- let [hidden, setHidden] = useState<boolean|undefined>()
1632
+ const [hidden, setHidden] = useState<boolean|undefined>()
1566
1633
  const [isSuggestionOpen, setIsSuggestionOpen] = useState<boolean>(false)
1567
- let [showDeclaration, setShowDeclaration] = useState<boolean>(false)
1634
+ const [showDeclaration, setShowDeclaration] = useState<boolean>(false)
1568
1635
 
1569
1636
  const initialValue:null|Type = determineInitialValue<Type>(
1570
1637
  givenProps,
@@ -1605,12 +1672,14 @@ export const GenericInputInner = function<Type = unknown>(
1605
1672
  let [selection, setSelection] =
1606
1673
  useState<AbortController|Properties['selection']>()
1607
1674
  if (givenProperties.selection || givenProperties.model?.selection)
1608
- selection = givenProperties.selection || givenProperties.model?.selection
1609
-
1610
- const normalizedSelection:SelectProps['options']|Array<{label?:string;value:unknown}>|undefined =
1611
- selection instanceof AbortController ?
1612
- [] :
1613
- normalizeSelection(selection, givenProperties.labels)
1675
+ selection =
1676
+ givenProperties.selection || givenProperties.model?.selection
1677
+
1678
+ const normalizedSelection:(
1679
+ SelectProps['options']|Array<{label?:string;value:unknown}>|undefined
1680
+ ) = selection instanceof AbortController ?
1681
+ [] :
1682
+ normalizeSelection(selection, givenProperties.labels)
1614
1683
  const [suggestionLabels, suggestionValues] =
1615
1684
  selection instanceof AbortController ?
1616
1685
  [[], []] :
@@ -1649,7 +1718,7 @@ export const GenericInputInner = function<Type = unknown>(
1649
1718
  Boolean(givenProps.onChange || givenProps.onChangeValue)
1650
1719
  const representationControlled:boolean =
1651
1720
  controlled && givenProps.representation !== undefined
1652
- let selectionIsUnstable:boolean = false
1721
+ let selectionIsUnstable = false
1653
1722
 
1654
1723
  deriveMissingPropertiesFromState()
1655
1724
 
@@ -1693,6 +1762,8 @@ export const GenericInputInner = function<Type = unknown>(
1693
1762
  setValueState, currentValueState
1694
1763
  )
1695
1764
  // endregion
1765
+ // endregion
1766
+ // region export references
1696
1767
  useImperativeHandle(
1697
1768
  reference,
1698
1769
  ():AdapterWithReferences<Type> => {
@@ -1702,7 +1773,7 @@ export const GenericInputInner = function<Type = unknown>(
1702
1773
  for (const name of [
1703
1774
  'cursor', 'editorIsActive', 'hidden', 'showDeclaration'
1704
1775
  ] as const)
1705
- if (!givenProps.hasOwnProperty(name))
1776
+ if (!Object.prototype.hasOwnProperty.call(givenProps, name))
1706
1777
  (state[name] as boolean|CursorState) = properties[name]
1707
1778
 
1708
1779
  if (!representationControlled)
@@ -1755,6 +1826,7 @@ export const GenericInputInner = function<Type = unknown>(
1755
1826
 
1756
1827
  const tinyMCEOptions:TinyMCEOptions = {
1757
1828
  ...TINYMCE_DEFAULT_OPTIONS,
1829
+ // eslint-disable-next-line camelcase
1758
1830
  content_style: properties.disabled ? 'body {opacity: .38}' : '',
1759
1831
  placeholder: properties.placeholder,
1760
1832
  readonly: Boolean(properties.disabled),
@@ -1808,7 +1880,7 @@ export const GenericInputInner = function<Type = unknown>(
1808
1880
  const currentRenderableSuggestions:Array<ReactElement> = []
1809
1881
  const currentSuggestionLabels:Array<string> = []
1810
1882
  const currentSuggestionValues:Array<unknown> = []
1811
- const useSuggestions:boolean = Boolean(
1883
+ const useSuggestions = Boolean(
1812
1884
  properties.suggestionCreator ||
1813
1885
  suggestionLabels.length &&
1814
1886
  (properties.searchSelection || properties.suggestSelection)
@@ -1817,7 +1889,7 @@ export const GenericInputInner = function<Type = unknown>(
1817
1889
  // NOTE: Create consistent property configuration.
1818
1890
  properties.suggestSelection = !properties.searchSelection
1819
1891
 
1820
- let index:number = 0
1892
+ let index = 0
1821
1893
  for (const suggestion of suggestionLabels) {
1822
1894
  if (Tools.isFunction(properties.children)) {
1823
1895
  const result:null|ReactElement = properties.children({
@@ -1857,10 +1929,13 @@ export const GenericInputInner = function<Type = unknown>(
1857
1929
  __html: Tools.stringMark(
1858
1930
  suggestion,
1859
1931
  properties.representation?.split(' ') || '',
1860
- (value:string):string =>
1861
- `${value}`.toLowerCase(),
1932
+ (value:unknown):string =>
1933
+ `${value as string}`.toLowerCase(),
1862
1934
  '<span class="' +
1863
- styles['generic-input__suggestions__suggestion__mark'] +
1935
+ (styles[
1936
+ 'generic-input__suggestions__suggestion' +
1937
+ '__mark'
1938
+ ] as string) +
1864
1939
  '">{1}</span>'
1865
1940
  ) as string
1866
1941
  }}
@@ -1883,278 +1958,328 @@ export const GenericInputInner = function<Type = unknown>(
1883
1958
  strict={GenericInput.strict}
1884
1959
  themeConfiguration={properties.themeConfiguration}
1885
1960
  tooltip={properties.tooltip}
1886
- ><div
1887
- className={[styles['generic-input']]
1888
- .concat(
1889
- isAdvancedEditor ? styles['generic-input--custom'] : [],
1890
- properties.className ?? []
1891
- )
1892
- .join(' ')
1893
- }
1894
- style={properties.styles}
1895
1961
  >
1896
- {wrapAnimationConditionally(
1897
- <Select
1898
- {...genericProperties as SelectProps}
1899
- {...materialProperties as SelectProps}
1900
- enhanced
1901
- foundationRef={foundationReference as
1902
- MutableRefObject<MDCSelectFoundation|null>
1903
- }
1904
- inputRef={inputReference as
1905
- unknown as
1906
- (reference:HTMLSelectElement|null) => void
1907
- }
1908
- onChange={onChangeValue}
1909
- options={normalizedSelection as SelectProps['options']}
1910
- rootProps={{
1911
- name: properties.name,
1912
- onClick: onClick,
1913
- ...properties.rootProps
1914
- }}
1915
- value={`${properties.value}`}
1916
- />,
1917
- useSelection
1918
- )}
1919
- {wrapAnimationConditionally(
1920
- [
1921
- <FormField
1922
- className={['mdc-text-field']
1923
- .concat(
1924
- properties.disabled ?
1925
- 'mdc-text-field--disabled' :
1926
- [],
1927
- 'mdc-text-field--textarea'
1928
- )
1929
- .join(' ')
1962
+ <div
1963
+ className={[styles['generic-input']]
1964
+ .concat(
1965
+ isAdvancedEditor ? styles['generic-input--custom'] : [],
1966
+ properties.className ?? []
1967
+ )
1968
+ .join(' ')
1969
+ }
1970
+ style={properties.styles}
1971
+ >
1972
+ {wrapAnimationConditionally(
1973
+ <Select
1974
+ {...genericProperties as SelectProps}
1975
+ {...materialProperties as SelectProps}
1976
+ enhanced
1977
+ foundationRef={foundationReference as
1978
+ MutableRefObject<MDCSelectFoundation|null>
1930
1979
  }
1931
- key="advanced-editor-form-field"
1932
- >
1933
- <label>
1934
- <span className={
1935
- [styles['generic-input__editor__label']]
1936
- .concat(
1937
- 'mdc-floating-label',
1938
- 'mdc-floating-label--float-above'
1939
- )
1940
- .join(' ')
1941
- }>
1942
- <Theme use={
1943
- properties.invalid &&
1944
- (
1945
- properties.showInitialValidationState ||
1946
- properties.visited
1947
- ) ? 'error' : undefined
1980
+ inputRef={inputReference as
1981
+ unknown as
1982
+ (_reference:HTMLSelectElement|null) => void
1983
+ }
1984
+ onChange={onChangeValue}
1985
+ options={normalizedSelection as SelectProps['options']}
1986
+ rootProps={{
1987
+ name: properties.name,
1988
+ onClick: onClick,
1989
+ ...properties.rootProps
1990
+ }}
1991
+ value={`${properties.value as unknown as string}`}
1992
+ />,
1993
+ useSelection
1994
+ )}
1995
+ {wrapAnimationConditionally(
1996
+ [
1997
+ <FormField
1998
+ className={['mdc-text-field']
1999
+ .concat(
2000
+ properties.disabled ?
2001
+ 'mdc-text-field--disabled' :
2002
+ [],
2003
+ 'mdc-text-field--textarea'
2004
+ )
2005
+ .join(' ')
2006
+ }
2007
+ key="advanced-editor-form-field"
2008
+ >
2009
+ <label>
2010
+ <span className={
2011
+ [styles['generic-input__editor__label']]
2012
+ .concat(
2013
+ 'mdc-floating-label',
2014
+ 'mdc-floating-label--float-above'
2015
+ )
2016
+ .join(' ')
1948
2017
  }>
1949
- {properties.description || properties.name}{properties.required ? '*' : ''}
1950
- </Theme>
1951
- </span>
1952
- {
1953
- properties.editor.startsWith('code') ?
1954
- <Suspense fallback={
1955
- <CircularProgress size="large" />
2018
+ <Theme use={
2019
+ properties.invalid &&
2020
+ (
2021
+ properties.showInitialValidationState ||
2022
+ properties.visited
2023
+ ) ? 'error' : undefined
1956
2024
  }>
1957
- <CodeEditor
2025
+ {
2026
+ (
2027
+ properties.description ||
2028
+ properties.name
2029
+ ) +
2030
+ (properties.required ? '*' : '')
2031
+ }
2032
+ </Theme>
2033
+ </span>
2034
+ {
2035
+ properties.editor.startsWith('code') ?
2036
+ <Suspense fallback={
2037
+ <CircularProgress size="large" />
2038
+ }>
2039
+ <CodeEditor
2040
+ {...genericProperties as
2041
+ CodeEditorProps
2042
+ }
2043
+ className="mdc-text-field__input"
2044
+ mode={(
2045
+ properties.editor.startsWith(
2046
+ 'code('
2047
+ ) &&
2048
+ properties.editor.endsWith(')')
2049
+ ) ?
2050
+ properties.editor.substring(
2051
+ 'code('.length,
2052
+ properties.editor.length -
2053
+ 1
2054
+ ) :
2055
+ 'javascript'
2056
+ }
2057
+ name={properties.name}
2058
+ onChange={onChangeValue}
2059
+ onCursorChange={onSelectionChange}
2060
+ onSelectionChange={
2061
+ onSelectionChange
2062
+ }
2063
+ ref={setCodeEditorReference}
2064
+ setOptions={{
2065
+ maxLines: properties.rows,
2066
+ minLines: properties.rows,
2067
+ readOnly: properties.disabled,
2068
+ tabSize: 4,
2069
+ useWorker: false
2070
+ }}
2071
+ theme="github"
2072
+ value={properties.representation}
2073
+ />
2074
+ </Suspense> :
2075
+ <RichTextEditorComponent
1958
2076
  {...genericProperties as
1959
- CodeEditorProps
2077
+ RichTextEditorProps
2078
+ }
2079
+ disabled={properties.disabled}
2080
+ init={tinyMCEOptions}
2081
+ onClick={onClick as
2082
+ unknown as
2083
+ RichTextEventHandler<MouseEvent>
2084
+ }
2085
+ onEditorChange={onChangeValue as
2086
+ unknown as
2087
+ RichTextEditorProps[
2088
+ 'onEditorChange'
2089
+ ]
2090
+ }
2091
+ onKeyUp={onKeyUp as
2092
+ unknown as
2093
+ RichTextEventHandler<KeyboardEvent>
1960
2094
  }
1961
- className="mdc-text-field__input"
1962
- mode={(
1963
- properties.editor.startsWith('code(') &&
1964
- properties.editor.endsWith(')')
1965
- ) ?
1966
- properties.editor.substring(
1967
- 'code('.length,
1968
- properties.editor.length - 1
1969
- ) :
1970
- 'javascript'
2095
+ ref={setRichTextEditorReference}
2096
+ textareaName={properties.name}
2097
+ tinymceScriptSrc={
2098
+ (TINYMCE_DEFAULT_OPTIONS.base_url as
2099
+ string
2100
+ ) +
2101
+ 'tinymce.min.js'
1971
2102
  }
1972
- name={properties.name}
1973
- onChange={onChangeValue}
1974
- onCursorChange={onSelectionChange}
1975
- onSelectionChange={onSelectionChange}
1976
- ref={setCodeEditorReference}
1977
- setOptions={{
1978
- maxLines: properties.rows,
1979
- minLines: properties.rows,
1980
- readOnly: properties.disabled,
1981
- tabSize: 4,
1982
- useWorker: false
1983
- }}
1984
- theme="github"
1985
2103
  value={properties.representation}
1986
2104
  />
1987
- </Suspense>
1988
- :
1989
- <RichTextEditorComponent
1990
- {...genericProperties as
1991
- RichTextEditorProps
1992
- }
1993
- disabled={properties.disabled}
1994
- init={tinyMCEOptions}
1995
- onClick={onClick as
1996
- unknown as
1997
- RichTextEventHandler<MouseEvent>
2105
+ }
2106
+ </label>
2107
+ </FormField>,
2108
+ <div
2109
+ className="mdc-text-field-helper-line"
2110
+ key="advanced-editor-helper-line"
2111
+ >
2112
+ <p className={
2113
+ 'mdc-text-field-helper-text ' +
2114
+ 'mdc-text-field-helper-text--persistent'
2115
+ }>
2116
+ {(
2117
+ materialProperties.helpText as
2118
+ {children:ReactElement}
2119
+ ).children}
2120
+ </p>
2121
+ </div>
2122
+ ],
2123
+ isAdvancedEditor,
2124
+ richTextEditorLoadedOnce ||
2125
+ properties.editor.startsWith('code')
2126
+ )}
2127
+ {wrapAnimationConditionally(
2128
+ <div>
2129
+ {useSuggestions ?
2130
+ <MenuSurfaceAnchor
2131
+ onKeyDown={preventEnterKeyPropagation}
2132
+ >
2133
+ {selection instanceof AbortController ?
2134
+ <MenuSurface
2135
+ anchorCorner="bottomLeft"
2136
+ className={
2137
+ (
2138
+ styles[
2139
+ 'generic-input__suggestions'
2140
+ ] as string
2141
+ ) +
2142
+ ' ' +
2143
+ (
2144
+ styles[
2145
+ 'generic-input__suggestions' +
2146
+ '--pending'
2147
+ ] as string
2148
+ )
1998
2149
  }
1999
- onEditorChange={onChangeValue as
2000
- unknown as
2001
- RichTextEditorProps['onEditorChange']
2150
+ open={true}
2151
+ >
2152
+ <CircularProgress size="large" />
2153
+ </MenuSurface> :
2154
+ <Menu
2155
+ anchorCorner="bottomLeft"
2156
+ apiRef={(instance:MenuApi|null):void => {
2157
+ suggestionMenuAPIReference.current =
2158
+ instance
2159
+ }}
2160
+ className={
2161
+ styles['generic-input__suggestions']
2002
2162
  }
2003
- onKeyUp={onKeyUp as
2004
- unknown as
2005
- RichTextEventHandler<KeyboardEvent>
2163
+ focusOnOpen={false}
2164
+ foundationRef={
2165
+ suggestionMenuFoundationReference
2006
2166
  }
2007
- ref={setRichTextEditorReference}
2008
- textareaName={properties.name}
2009
- tinymceScriptSrc={`${TINYMCE_DEFAULT_OPTIONS.base_url}tinymce.min.js`}
2010
- value={properties.representation}
2011
- />
2012
- }
2013
- </label>
2014
- </FormField>,
2015
- <div
2016
- className="mdc-text-field-helper-line"
2017
- key="advanced-editor-helper-line"
2018
- >
2019
- <p className={
2020
- 'mdc-text-field-helper-text' +
2021
- ' mdc-text-field-helper-text--persistent'
2022
- }>{(
2023
- materialProperties.helpText as {children:ReactElement}
2024
- ).children}</p>
2025
- </div>
2026
- ],
2027
- isAdvancedEditor,
2028
- richTextEditorLoadedOnce || properties.editor.startsWith('code')
2029
- )}
2030
- {wrapAnimationConditionally(
2031
- <div>
2032
- {useSuggestions ?
2033
- <MenuSurfaceAnchor onKeyDown={preventEnterKeyPropagation}>
2034
- {selection instanceof AbortController ?
2035
- <MenuSurface
2036
- anchorCorner="bottomLeft"
2037
- className={
2038
- styles['generic-input__suggestions'] +
2039
- ' ' +
2040
- styles['generic-input__suggestions--pending']
2041
- }
2042
- open={true}
2043
- >
2044
- <CircularProgress size="large" />
2045
- </MenuSurface> :
2046
- <Menu
2047
- anchorCorner="bottomLeft"
2048
- apiRef={(instance:MenuApi|null):void => {
2049
- suggestionMenuAPIReference.current = instance
2050
- }}
2051
- className={styles['generic-input__suggestions']}
2052
- focusOnOpen={false}
2053
- foundationRef={suggestionMenuFoundationReference}
2054
- onFocus={onFocus}
2055
- onSelect={(event:MenuOnSelectEventT):void => {
2056
- onChangeValue(
2057
- currentSuggestionValues[
2167
+ onFocus={onFocus}
2168
+ onSelect={(
2169
+ event:MenuOnSelectEventT
2170
+ ):void => {
2171
+ onChangeValue(
2172
+ currentSuggestionValues[
2173
+ event.detail.index
2174
+ ] as Type,
2175
+ undefined,
2058
2176
  event.detail.index
2059
- ] as unknown as Type,
2060
- undefined,
2061
- event.detail.index
2062
- )
2063
- setIsSuggestionOpen(false)
2064
- }}
2065
- open={
2066
- Boolean(currentSuggestionLabels.length) &&
2067
- isSuggestionOpen &&
2068
- /*
2069
- NOTE: If single possibility is already
2070
- selected avoid showing this suggestion.
2071
- */
2072
- !(
2073
- currentSuggestionLabels.length === 1 &&
2074
- currentSuggestionLabels[0] ===
2075
- properties.representation as string
2076
- )
2077
- }
2078
- >
2079
- {currentRenderableSuggestions}
2080
- </Menu>
2081
- }
2082
- </MenuSurfaceAnchor> :
2083
- ''
2084
- }
2085
- <TextField
2086
- {...genericProperties as TextFieldProps}
2087
- {...materialProperties as TextFieldProps}
2088
- {...(properties.type === 'number' ?
2089
- {
2090
- max: properties.maximum,
2091
- min: properties.minimum,
2092
- step: properties.step
2093
- } :
2094
- properties.type === 'string' ?
2177
+ )
2178
+ setIsSuggestionOpen(false)
2179
+ }}
2180
+ open={
2181
+ Boolean(
2182
+ currentSuggestionLabels.length
2183
+ ) &&
2184
+ isSuggestionOpen &&
2185
+ /*
2186
+ NOTE: If single possibility is
2187
+ already selected avoid showing this
2188
+ suggestion.
2189
+ */
2190
+ !(
2191
+ currentSuggestionLabels.length ===
2192
+ 1 &&
2193
+ currentSuggestionLabels[0] ===
2194
+ properties.representation
2195
+ )
2196
+ }
2197
+ >
2198
+ {currentRenderableSuggestions}
2199
+ </Menu>
2200
+ }
2201
+ </MenuSurfaceAnchor> :
2202
+ ''
2203
+ }
2204
+ <TextField
2205
+ {...genericProperties as TextFieldProps}
2206
+ {...materialProperties as TextFieldProps}
2207
+ {...(properties.type === 'number' ?
2095
2208
  {
2096
- maxLength: properties.maximumLength >= 0 ?
2097
- properties.maximumLength :
2098
- Infinity,
2099
- minLength: properties.minimumLength >= 0 ?
2100
- properties.minimumLength :
2101
- 0,
2102
- ...(properties.editor === 'plain' ?
2103
- {} :
2104
- {rows: properties.rows}
2105
- )
2209
+ max: properties.maximum,
2210
+ min: properties.minimum,
2211
+ step: properties.step
2106
2212
  } :
2107
- ['date', 'datetime-local', 'time'].includes(
2108
- properties.type
2109
- ) ?
2213
+ properties.type === 'string' ?
2110
2214
  {
2111
- max: formatValue<Type>(
2112
- properties,
2113
- properties.maximum as unknown as Type,
2114
- transformer
2115
- ),
2116
- min: formatValue<Type>(
2117
- properties,
2118
- properties.minimum as unknown as Type,
2119
- transformer
2120
- ),
2121
- step: properties.step
2215
+ maxLength: properties.maximumLength >= 0 ?
2216
+ properties.maximumLength :
2217
+ Infinity,
2218
+ minLength: properties.minimumLength >= 0 ?
2219
+ properties.minimumLength :
2220
+ 0,
2221
+ ...(properties.editor === 'plain' ?
2222
+ {} :
2223
+ {rows: properties.rows}
2224
+ )
2122
2225
  } :
2123
- {}
2124
- )}
2125
- align={properties.align}
2126
- characterCount
2127
- foundationRef={foundationReference as
2128
- MutableRefObject<MDCTextFieldFoundation|null>
2129
- }
2130
- fullwidth={properties.fullWidth}
2131
- inputRef={inputReference as
2132
- MutableRefObject<HTMLInputElement|null>
2133
- }
2134
- onChange={onChangeValue}
2135
- ripple={properties.ripple}
2136
- rootProps={{
2137
- name: properties.name,
2138
- onClick: onClick,
2139
- onKeyDown: onKeyDown,
2140
- onKeyUp: onKeyUp,
2141
- ...properties.rootProps
2142
- }}
2143
- textarea={
2144
- properties.type === 'string' &&
2145
- properties.editor !== 'plain'
2146
- }
2147
- trailingIcon={wrapIconWithTooltip(applyIconPreset(
2148
- properties.trailingIcon
2149
- ))}
2150
- type={determineNativeType(properties)}
2151
- value={properties.representation}
2152
- />
2153
- </div>,
2154
- !(isAdvancedEditor || useSelection),
2155
- richTextEditorLoadedOnce || properties.editor.startsWith('code')
2156
- )}
2157
- </div></WrapConfigurations>
2226
+ ['date', 'datetime-local', 'time'].includes(
2227
+ properties.type
2228
+ ) ?
2229
+ {
2230
+ max: formatValue<Type>(
2231
+ properties,
2232
+ properties.maximum as
2233
+ unknown as
2234
+ Type,
2235
+ transformer
2236
+ ),
2237
+ min: formatValue<Type>(
2238
+ properties,
2239
+ properties.minimum as
2240
+ unknown as
2241
+ Type,
2242
+ transformer
2243
+ ),
2244
+ step: properties.step
2245
+ } :
2246
+ {}
2247
+ )}
2248
+ align={properties.align}
2249
+ characterCount
2250
+ foundationRef={foundationReference as
2251
+ MutableRefObject<MDCTextFieldFoundation|null>
2252
+ }
2253
+ fullwidth={properties.fullWidth}
2254
+ inputRef={inputReference as
2255
+ MutableRefObject<HTMLInputElement|null>
2256
+ }
2257
+ onChange={onChangeValue}
2258
+ ripple={properties.ripple}
2259
+ rootProps={{
2260
+ name: properties.name,
2261
+ onClick: onClick,
2262
+ onKeyDown: onKeyDown,
2263
+ onKeyUp: onKeyUp,
2264
+ ...properties.rootProps
2265
+ }}
2266
+ textarea={
2267
+ properties.type === 'string' &&
2268
+ properties.editor !== 'plain'
2269
+ }
2270
+ trailingIcon={wrapIconWithTooltip(applyIconPreset(
2271
+ properties.trailingIcon
2272
+ ))}
2273
+ type={determineNativeType(properties)}
2274
+ value={properties.representation}
2275
+ />
2276
+ </div>,
2277
+ !(isAdvancedEditor || useSelection),
2278
+ richTextEditorLoadedOnce ||
2279
+ properties.editor.startsWith('code')
2280
+ )}
2281
+ </div>
2282
+ </WrapConfigurations>
2158
2283
  // / endregion
2159
2284
  // endregion
2160
2285
  }
@@ -2165,7 +2290,7 @@ GenericInputInner.displayName = 'GenericInput'
2165
2290
  * @property static:defaultModelState - Initial model state.
2166
2291
  * @property static:defaultProperties - Initial property configuration.
2167
2292
  * @property static:locales - Defines input formatting locales.
2168
- * @property static:propTypes - Triggers reacts runtime property value checks
2293
+ * @property static:propTypes - Triggers reacts runtime property value checks.
2169
2294
  * @property static:strict - Indicates whether we should wrap render output in
2170
2295
  * reacts strict component.
2171
2296
  * @property static:transformer - Generic input data transformation
@@ -2174,6 +2299,7 @@ GenericInputInner.displayName = 'GenericInput'
2174
2299
  *
2175
2300
  * @param props - Given components properties.
2176
2301
  * @param reference - Reference object to forward internal state.
2302
+ *
2177
2303
  * @returns React elements.
2178
2304
  */
2179
2305
  export const GenericInput:GenericInputComponent =
@@ -2272,8 +2398,7 @@ GenericInput.transformer = {
2272
2398
  return ''
2273
2399
 
2274
2400
  const formattedValue:string =
2275
- (new Date(Math.round((value as number) * 1000)))
2276
- .toISOString()
2401
+ (new Date(Math.round(value * 1000))).toISOString()
2277
2402
 
2278
2403
  return formattedValue.substring(0, formattedValue.indexOf('T'))
2279
2404
  }},
@@ -2309,8 +2434,7 @@ GenericInput.transformer = {
2309
2434
  return ''
2310
2435
 
2311
2436
  const formattedValue:string =
2312
- (new Date(Math.round((value as number) * 1000)))
2313
- .toISOString()
2437
+ (new Date(Math.round(value * 1000))).toISOString()
2314
2438
 
2315
2439
  return formattedValue.substring(0, formattedValue.length - 1)
2316
2440
  }},
@@ -2348,8 +2472,7 @@ GenericInput.transformer = {
2348
2472
  return ''
2349
2473
 
2350
2474
  const formattedValue:string =
2351
- (new Date(Math.round((value as number) * 1000)))
2352
- .toISOString()
2475
+ (new Date(Math.round(value * 1000))).toISOString()
2353
2476
 
2354
2477
  return formattedValue.substring(
2355
2478
  formattedValue.indexOf('T') + 1, formattedValue.length - 1
@@ -2397,7 +2520,7 @@ GenericInput.transformer = {
2397
2520
  if (typeof value === 'string')
2398
2521
  value = parseFloat(
2399
2522
  GenericInput.locales[0] === 'de-DE' ?
2400
- value.replace(/\./g, '').replace(/\,/g, '.') :
2523
+ value.replace(/\./g, '').replace(/,/g, '.') :
2401
2524
  value
2402
2525
  )
2403
2526