5htp-core 0.4.6-7 → 0.4.7-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.4.6-7",
4
+ "version": "0.4.7-1",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -18,9 +18,7 @@ import type { TDialogControls } from '@client/components/dropdown';
18
18
 
19
19
  export type Choice = { label: ComponentChild, value: string }
20
20
 
21
- export type Choices = Choice[]
22
-
23
- type ChoicesFunc = (search: string) => Promise<Choices>
21
+ type ChoicesFunc = (search: string) => Promise<Choice[]>
24
22
 
25
23
  export type Props = (
26
24
  {
@@ -37,10 +35,13 @@ export type Props = (
37
35
  validator?: StringValidator
38
36
  }
39
37
  ) & {
40
- choices: Choices | ChoicesFunc,
38
+ choices: Choice[] | ChoicesFunc | string[],
41
39
  enableSearch?: boolean,
42
40
  required?: boolean,
43
41
  noneSelection?: false | string,
42
+ }
43
+
44
+ type SelectorProps = Props & {
44
45
  currentList: Choice[],
45
46
  refDropdown?: RefObject<TDialogControls>
46
47
  }
@@ -67,7 +68,7 @@ export default React.forwardRef<HTMLDivElement, Props>(({
67
68
  currentList,
68
69
  refDropdown,
69
70
  ...otherProps
70
- }: Props, ref) => {
71
+ }: SelectorProps, ref) => {
71
72
 
72
73
 
73
74
 
@@ -22,7 +22,7 @@ import ChoiceElement from './ChoiceElement';
22
22
  ----------------------------------*/
23
23
 
24
24
  export type Props = SelectorProps & {
25
- dropdown: boolean | DropdownProps,
25
+ dropdown?: boolean | DropdownProps,
26
26
  title: string,
27
27
  errors?: string[],
28
28
  }
@@ -77,8 +77,10 @@ export default ({
77
77
  const popoverState = React.useState(false);
78
78
 
79
79
  const choicesViaFunc = typeof initChoices === 'function';
80
- if (choicesViaFunc && enableSearch === undefined)
80
+ if (choicesViaFunc)
81
81
  enableSearch = true;
82
+ else if (typeof initChoices[0] === 'string')
83
+ initChoices = initChoices.map( c => ({ label: c, value: c }));
82
84
 
83
85
  const refInputSearch = React.useRef<HTMLInputElement | null>(null);
84
86
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  // Npm
6
6
  import React from 'react';
7
+ import type { ComponentChild } from 'preact';
7
8
  import type { StateUpdater } from 'preact/hooks';
8
9
 
9
10
  // Core libs
@@ -16,6 +17,7 @@ import { useState } from '@client/hooks';
16
17
  export type InputBaseProps<TValue> = {
17
18
 
18
19
  title: string, // Now mandatory
20
+ hint?: ComponentChild,
19
21
  required?: boolean,
20
22
  errors?: string[],
21
23
  size?: TComponentSize,
@@ -64,7 +66,7 @@ export function useInput<TValue>(
64
66
  if (state.changed === false)
65
67
  return;
66
68
 
67
- console.log(`[input] Commit value:`, state.value, externalValue);
69
+ //console.log(`[input] Commit value:`, state.value, externalValue);
68
70
  if (onChange !== undefined)
69
71
  onChange(state.value);
70
72
  }
@@ -128,7 +128,7 @@ export default ({
128
128
 
129
129
  } else if (type === 'longtext') {
130
130
 
131
- prefix = prefix || <i src="text" />;
131
+ // No icon because not good looking ane we want as much space as possible
132
132
  Tag = 'textarea';
133
133
  className += ' multiline';
134
134
 
@@ -139,7 +139,7 @@ export default class SchemaValidators {
139
139
  return undefined;
140
140
 
141
141
  // Normalize for verifications
142
- const choicesValues = choices?.map(v => v.value)
142
+ const choicesValues = choices?.map(v => typeof v === 'object' ? v.value : v)
143
143
 
144
144
  const checkChoice = ( choice: any ) => {
145
145