5htp-core 0.4.9-98 → 0.4.9-99

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.9-98",
4
+ "version": "0.4.9-99",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -128,7 +128,7 @@ export default function useForm<TFormData extends {}>(
128
128
  return validated;
129
129
  }
130
130
 
131
- const submit = async (additionnalData: Partial<TFormData> = {}) => {
131
+ const submit = (additionnalData: Partial<TFormData> = {}) => {
132
132
 
133
133
  const allData = { ...data, ...additionnalData }
134
134
 
@@ -138,22 +138,28 @@ export default function useForm<TFormData extends {}>(
138
138
  throw new InputErrorSchema(validated.erreurs);
139
139
  }
140
140
 
141
- // Callback
142
- let submitResult: any;
143
- if (options.submit)
144
- submitResult = await options.submit(allData as TFormData);
141
+ const afterSubmit = (responseData?: any) => {
145
142
 
146
- // Reset autosaved data
147
- if (options.autoSave)
148
- localStorage.removeItem('form.' + options.autoSave.id);
143
+ // Reset autosaved data
144
+ if (options.autoSave)
145
+ localStorage.removeItem('form.' + options.autoSave.id);
146
+
147
+ // Update state
148
+ setState( current => ({
149
+ ...current,
150
+ hasChanged: false
151
+ }));
149
152
 
150
- // Update state
151
- setState( current => ({
152
- ...current,
153
- hasChanged: false
154
- }));
153
+ return responseData;
154
+ }
155
155
 
156
- return submitResult;
156
+ // Callback
157
+ if (options.submit)
158
+ return options.submit(allData as TFormData).then(afterSubmit);
159
+ else {
160
+ afterSubmit();
161
+ return undefined;
162
+ }
157
163
  }
158
164
 
159
165
  const rebuildFieldsAttrs = (newState: Partial<FormState> = {}) => {
@@ -46,15 +46,25 @@ export default ({ choice, currentList, onChange, multiple, required, includeCurr
46
46
  );
47
47
  }
48
48
 
49
+ const btnProps = {
50
+ selected: isCurrent,
51
+ onClick,
52
+ icon: choice.color ? (
53
+ <span class="pastille" style={{ background: '#' + choice.color }} />
54
+ ) : choice.icon ? (
55
+ <i src={choice.icon} />
56
+ ) : undefined
57
+ }
58
+
49
59
  return format === 'list' ? (
50
60
  <li>
51
- <Button selected={isCurrent} onClick={onClick}>
61
+ <Button {...btnProps}>
52
62
  {choice.label}
53
63
  </Button>
54
64
  </li>
55
65
  ) : (
56
66
  <li>
57
- <Button type="secondary" selected={isCurrent} onClick={onClick}>
67
+ <Button type="secondary" {...btnProps}>
58
68
 
59
69
  {choice.label}
60
70
 
@@ -16,7 +16,12 @@ import type { TDialogControls } from '@client/components/dropdown';
16
16
  - TYPES
17
17
  ----------------------------------*/
18
18
 
19
- export type Choice = { label: ComponentChild, value: string }
19
+ export type Choice = {
20
+ label: ComponentChild,
21
+ value: string,
22
+ color?: string,
23
+ icon?: string,
24
+ }
20
25
 
21
26
  type ChoicesFunc = (search: string) => Promise<Choice[]>
22
27
 
@@ -149,6 +149,8 @@ export default class Email extends Service<Config, Hooks, Application, Services>
149
149
  ([ emails, options ] = args as TCompleteEmailSendArgs);
150
150
  if (!Array.isArray( emails ))
151
151
  emails = [emails];
152
+ else if (emails.length === 0)
153
+ return console.warn(LogPrefix, `No email to send.`);
152
154
  }
153
155
 
154
156
  options = options || {}