5htp-core 0.5.9-53 → 0.5.9-54

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.
@@ -1,5 +1,5 @@
1
1
  .table {
2
-
2
+
3
3
  overflow: auto;
4
4
 
5
5
  &.scrollable {
@@ -40,7 +40,8 @@ table {
40
40
 
41
41
  td, th {
42
42
 
43
- padding: 1em 1em;
43
+ padding: 0.6em 1em;
44
+ font-size: 1rem;
44
45
  text-align: left;
45
46
 
46
47
  &:not(:last-child) {
@@ -129,14 +130,6 @@ table {
129
130
  }
130
131
  }
131
132
 
132
- // Size
133
- &.s, .table.s & {
134
- td, th {
135
- padding: 0.7em 1em;
136
- font-size: 1rem;
137
- }
138
- }
139
-
140
133
  // Tableua responsive
141
134
  // Utilisation déconseillée (lauvaise utilisation de l'espace, ergonomie horrible
142
135
  /*@media (max-width: @responsive2) {
@@ -26,7 +26,10 @@ export default (initProps: Props) => {
26
26
  - INIT
27
27
  ----------------------------------*/
28
28
 
29
- const [{ title }, { errors, required, ...props }] = useMantineInput<Props>(initProps);
29
+ const [{ title, onChange }, { errors, required, ...props }] = useMantineInput<Props>(initProps);
30
+
31
+ console.log("initProps", initProps);
32
+
30
33
 
31
34
  /*----------------------------------
32
35
  - RENDER
@@ -37,6 +40,7 @@ export default (initProps: Props) => {
37
40
  error={errors?.join(', ')}
38
41
  required={required}
39
42
  {...props}
43
+ onChange={e => onChange?.(e.target.checked)}
40
44
  />
41
45
  )
42
46
  }
@@ -5,8 +5,8 @@
5
5
  // Npm
6
6
  import React from 'react';
7
7
  import { JSX, ComponentChild } from 'preact';
8
- import { Menu, MenuProps } from '@mantine/core';
9
- import Button, { Props as ButtonProps } from './Button';
8
+ import { Button, Menu, MenuProps } from '@mantine/core';
9
+ import { Props as ButtonProps } from './Button';
10
10
 
11
11
  // Core libs
12
12
  import { useMantineInput, InputBaseProps } from './utils';
@@ -24,12 +24,18 @@ export type Props = ButtonProps & {
24
24
  ----------------------------------*/
25
25
  export default ({
26
26
  label, children,
27
- menuProps = {}, ...btnProps
27
+ menuProps = {}, size, icon, ...btnProps
28
28
  }: Props) => {
29
29
  return (
30
- <Menu {...menuProps}>
30
+ <Menu {...menuProps} size={size}>
31
31
  <Menu.Target>
32
- <Button {...btnProps}>{label}</Button>
32
+ <Button {...btnProps}
33
+ rightSection={<i src="angle-down" />}
34
+ variant="subtle"
35
+ >
36
+ {icon && <i src={icon} />}
37
+ {label}
38
+ </Button>
33
39
  </Menu.Target>
34
40
  <Menu.Dropdown>
35
41
  {children}
@@ -85,8 +85,10 @@ export default function ElementFormatDropdown({
85
85
  const formatOption = FormatOptions.find((option) => option.value === currentValue) || FormatOptions[0];
86
86
 
87
87
  return (
88
- <DropDown disabled={disabled} icon={isRTL ? formatOption.iconRTL : formatOption.icon} size="s"
89
- label={formatOption.label}
88
+ <DropDown disabled={disabled}
89
+ icon={isRTL ? formatOption.iconRTL : formatOption.icon}
90
+ size="s"
91
+ hint={formatOption.label}
90
92
  popover={{ tag: 'li' }}
91
93
  >
92
94
  {FormatOptions.map((option) => (
@@ -510,7 +510,7 @@ export default function ToolbarPlugin({
510
510
  )}
511
511
 
512
512
  {blockType === 'code' ? (
513
- <DropDown label={getLanguageFriendlyName(codeLanguage)}
513
+ <DropDown size="s" label={getLanguageFriendlyName(codeLanguage)}
514
514
  disabled={!isEditable}
515
515
  icon="code"
516
516
  >
@@ -591,7 +591,7 @@ export default function ToolbarPlugin({
591
591
 
592
592
  <DropDown popover={{ tag: 'li' }} icon="font" size="s"
593
593
  disabled={!isEditable}
594
- label="Formatting options for additional text styles"
594
+ hint="Formatting options for additional text styles"
595
595
  >
596
596
 
597
597
  <Button icon="strikethrough" size="s"
@@ -640,8 +640,8 @@ export default function ToolbarPlugin({
640
640
  <DropDown popover={{ tag: 'li' }}
641
641
  disabled={!isEditable}
642
642
  size="s"
643
- label="Insert"
644
- title="Insert specialized editor node"
643
+ icon="plus-circle"
644
+ hint="Insert specialized editor node"
645
645
  >
646
646
 
647
647
  <Button icon="horizontal-rule" size="s" onClick={() => {
@@ -5,7 +5,6 @@
5
5
  // Npm
6
6
  import React from 'react';
7
7
  import {
8
- Select as MantineSelect,
9
8
  SelectProps,
10
9
  MultiSelect as MantineMultiSelect,
11
10
  ComboboxItem,
@@ -31,23 +30,16 @@ export type Choice = ComboboxItem;
31
30
  const ensureChoice = (
32
31
  choice: ComboboxItem | string,
33
32
  choices: ComboboxItem[],
34
- current: ComboboxItem | ComboboxItem[] | null
33
+ current: ComboboxItem[]
35
34
  ): ComboboxItem => {
36
35
 
37
36
  // Allready a choice
38
- if (typeof choice === 'object' && choice.label) {
37
+ if (typeof choice === 'object')
39
38
  return choice;
40
- }
41
-
42
- // Complete list of the choices
43
- const allChoices = [...choices];
44
- if (Array.isArray(current))
45
- allChoices.push(...current);
46
39
 
47
40
  // Find the choice
48
- const found = allChoices.find( c => c.value === choice);
49
- if (found)
50
- return found;
41
+ const found = [...choices, ...current].find( c => c.value === choice );
42
+ if (found) return found;
51
43
 
52
44
  // Create a new choice
53
45
  return {
@@ -72,24 +64,16 @@ export default (initProps: Props) => {
72
64
  ...props
73
65
  }] = useMantineInput<Props, string|number>(initProps);
74
66
 
75
- const initRef = React.useRef<boolean>();
67
+ const currentArray = Array.isArray(current) ? current : current ? [current] : [];
76
68
 
77
69
  const choicesViaFunc = typeof initChoices === 'function';
78
70
  if (choicesViaFunc)
79
71
  enableSearch = true;
80
72
  else
81
- initChoices = initChoices?.map( c => ensureChoice(c, [], current) ) || [];
82
-
83
- if (enableSearch)
84
- props.searchable = true;
73
+ initChoices = initChoices?.map( c => ensureChoice(c, [], currentArray) ) || [];
85
74
 
86
75
  let [choices, setChoices] = React.useState<ComboboxItem[]>( choicesViaFunc
87
- ? (Array.isArray(current)
88
- ? current.map( c => ensureChoice(c, [], current) )
89
- : current
90
- ? [ensureChoice(current, [], [])]
91
- : []
92
- ) || []
76
+ ? currentArray.map( c => ensureChoice(c, [], currentArray) )
93
77
  : initChoices
94
78
  );
95
79
 
@@ -106,8 +90,6 @@ export default (initProps: Props) => {
106
90
  - ACTIONS
107
91
  ----------------------------------*/
108
92
 
109
- const valueToChoice = (value: string) => choices.find(c => c.value === value);
110
-
111
93
  React.useEffect(() => {
112
94
 
113
95
  if (choicesViaFunc && opened) {
@@ -123,8 +105,6 @@ export default (initProps: Props) => {
123
105
  })
124
106
  }
125
107
 
126
- initRef.current = true;
127
-
128
108
  }, [
129
109
  opened,
130
110
  search.keywords,
@@ -133,26 +113,37 @@ export default (initProps: Props) => {
133
113
  typeof initChoices === 'function' ? true : initChoices
134
114
  ]);
135
115
 
136
- let Component: typeof MantineSelect | typeof MantineMultiSelect;
116
+ /*----------------------------------
117
+ - RENDER
118
+ ----------------------------------*/
119
+
137
120
  if (multiple) {
138
- Component = MantineMultiSelect;
139
- props.value = current ? current.map( c => ensureChoice(c, choices, current).value ) : [];
121
+
122
+ props.value = current
123
+ ? current.map( c => ensureChoice(c, choices, currentArray).value )
124
+ : [];
125
+
140
126
  props.onChange = (value: string[]) => {
141
- onChange( value.map(valueToChoice) )
127
+ onChange( value.map(value => ensureChoice(value, choices, currentArray)) )
142
128
  };
129
+
143
130
  } else {
144
- Component = MantineSelect;
145
- props.value = current ? ensureChoice(current, choices, current).value : '';
146
- props.onChange = (value: string) => onChange( valueToChoice(value) );
147
- }
148
131
 
149
- if (props.placeholder === 'Languages') {
150
- console.log("CHOICES", current, props.value);
151
- }
132
+ props.value = current
133
+ ? [ensureChoice(current, choices, currentArray).value]
134
+ : [];
135
+
136
+ props.onChange = (value: string[]) => {
137
+
138
+ setOpened(false);
139
+
140
+ onChange( value.length > 0
141
+ ? ensureChoice(value[value.length - 1], choices, currentArray)
142
+ : undefined
143
+ )
144
+ };
145
+ }
152
146
 
153
- /*----------------------------------
154
- - RENDER
155
- ----------------------------------*/
156
147
  if (minimal) {
157
148
  return (
158
149
  <Menu width={300} opened={opened} onChange={setOpened}
@@ -213,19 +204,32 @@ export default (initProps: Props) => {
213
204
 
214
205
  } else {
215
206
  return (
216
- <Component
207
+ <MantineMultiSelect
217
208
  {...props}
218
209
 
219
- data={choices}
210
+ data={[
211
+ {
212
+ group: 'Search results',
213
+ // Exclude the choices that are already selected
214
+ items: choices.filter(c => !props.value.includes(c.value))
215
+ },
216
+ {
217
+ group: 'Selected',
218
+ items: currentArray
219
+ }
220
+ ]}
220
221
  nothingFound={search.loading ? 'Loading...' : props || 'No options found'}
221
222
  comboboxProps={{
222
223
  withArrow: false
223
224
  }}
224
225
 
226
+ searchable={enableSearch}
225
227
  clearable={!required}
226
228
  required={required}
227
229
  allowDeselect={!required}
230
+ checkIconPosition="right"
228
231
 
232
+ dropdownOpened={opened}
229
233
  onDropdownOpen={() => setOpened(true)}
230
234
  onDropdownClose={() => setOpened(false)}
231
235
  onSearchChange={(keywords) => setSearch(s => ({ ...s, keywords }))}
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.5.9-53",
4
+ "version": "0.5.9-54",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
package/types/icons.d.ts CHANGED
@@ -1 +1 @@
1
- export type TIcones = "long-arrow-right"|"times"|"solid/spinner-third"|"sack-dollar"|"bell"|"bullseye"|"project-diagram"|"user-friends"|"eye"|"lock"|"comments"|"phone"|"chalkboard-teacher"|"rocket"|"chart-bar"|"planet-ringed"|"crosshairs"|"brands/linkedin"|"plus-circle"|"comments-alt"|"user-circle"|"arrow-right"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"user-plus"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"key"|"user"|"at"|"times-circle"|"calendar-alt"|"paper-plane"|"search"|"lightbulb"|"magnet"|"solid/crown"|"brands/discord"|"pen"|"plus"|"file"|"envelope"|"angle-up"|"angle-down"|"binoculars"|"info-circle"|"check-circle"|"exclamation-circle"|"check"|"meh-rolling-eyes"|"trash"|"arrow-left"|"bars"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"cog"|"power-off"|"question-circle"|"play"|"minus-circle"|"external-link"|"plane-departure"|"wind"|"usd-circle"|"users"|"home-alt"|"trophy"|"arrow-to-bottom"|"map-marker-alt"|"clock"|"ellipsis-h"|"building"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"unlink"|"font"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
1
+ export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"sack-dollar"|"bell"|"bullseye"|"project-diagram"|"user-friends"|"eye"|"lock"|"comments"|"phone"|"chalkboard-teacher"|"chart-bar"|"rocket"|"user-circle"|"planet-ringed"|"brands/linkedin"|"crosshairs"|"arrow-right"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"at"|"key"|"plus-circle"|"comments-alt"|"user-plus"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"user"|"calendar-alt"|"paper-plane"|"search"|"lightbulb"|"magnet"|"times-circle"|"angle-up"|"angle-down"|"envelope"|"plus"|"solid/crown"|"brands/discord"|"pen"|"file"|"binoculars"|"check"|"info-circle"|"check-circle"|"exclamation-circle"|"arrow-left"|"meh-rolling-eyes"|"trash"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"cog"|"power-off"|"bars"|"usd-circle"|"users"|"home-alt"|"trophy"|"plane-departure"|"wind"|"question-circle"|"play"|"minus-circle"|"external-link"|"map-marker-alt"|"clock"|"arrow-to-bottom"|"ellipsis-h"|"building"|"unlink"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"font"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"