5htp-core 0.5.9-52 → 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.
@@ -92,6 +92,10 @@
92
92
 
93
93
  &.menu {
94
94
  padding: @cardPaddingLong;
95
+
96
+ &.popover {
97
+ padding: @cardPaddingMini;
98
+ }
95
99
  }
96
100
 
97
101
  /*----------------------------------
@@ -1,6 +1,10 @@
1
1
  .table {
2
+
2
3
  overflow: auto;
3
- max-height: 90vh;
4
+
5
+ &.scrollable {
6
+ max-height: 90vh;
7
+ }
4
8
 
5
9
  > table {
6
10
  border-collapse: collapse;
@@ -27,7 +31,6 @@ table {
27
31
 
28
32
  // By default, chrome disables text inherits
29
33
  line-height: inherit;
30
- font-size: 0.9em;
31
34
 
32
35
  th {
33
36
  font-weight: 500;
@@ -37,7 +40,8 @@ table {
37
40
 
38
41
  td, th {
39
42
 
40
- padding: 1em 1em;
43
+ padding: 0.6em 1em;
44
+ font-size: 1rem;
41
45
  text-align: left;
42
46
 
43
47
  &:not(:last-child) {
@@ -74,7 +78,7 @@ table {
74
78
  top: 0;
75
79
  background: var(--cBg);
76
80
  white-space: break-spaces;
77
- z-index: 5;
81
+ z-index: 2;
78
82
  }
79
83
 
80
84
  tbody {
@@ -126,14 +130,6 @@ table {
126
130
  }
127
131
  }
128
132
 
129
- // Size
130
- &.s, .table.s & {
131
- td, th {
132
- padding: 0.7em 1em;
133
- font-size: 1rem;
134
- }
135
- }
136
-
137
133
  // Tableua responsive
138
134
  // Utilisation déconseillée (lauvaise utilisation de l'espace, ergonomie horrible
139
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,
@@ -30,18 +29,17 @@ export type Choice = ComboboxItem;
30
29
 
31
30
  const ensureChoice = (
32
31
  choice: ComboboxItem | string,
33
- choices: ComboboxItem[]
32
+ choices: ComboboxItem[],
33
+ current: ComboboxItem[]
34
34
  ): ComboboxItem => {
35
35
 
36
36
  // Allready a choice
37
- if (typeof choice === 'object' && choice.label) {
37
+ if (typeof choice === 'object')
38
38
  return choice;
39
- }
40
39
 
41
40
  // Find the choice
42
- const found = choices.find( c => c.value === choice);
43
- if (found)
44
- return found;
41
+ const found = [...choices, ...current].find( c => c.value === choice );
42
+ if (found) return found;
45
43
 
46
44
  // Create a new choice
47
45
  return {
@@ -66,24 +64,16 @@ export default (initProps: Props) => {
66
64
  ...props
67
65
  }] = useMantineInput<Props, string|number>(initProps);
68
66
 
69
- const initRef = React.useRef<boolean>();
67
+ const currentArray = Array.isArray(current) ? current : current ? [current] : [];
70
68
 
71
69
  const choicesViaFunc = typeof initChoices === 'function';
72
70
  if (choicesViaFunc)
73
71
  enableSearch = true;
74
72
  else
75
- initChoices = initChoices?.map( c => ensureChoice(c, []) ) || [];
76
-
77
- if (enableSearch)
78
- props.searchable = true;
73
+ initChoices = initChoices?.map( c => ensureChoice(c, [], currentArray) ) || [];
79
74
 
80
75
  let [choices, setChoices] = React.useState<ComboboxItem[]>( choicesViaFunc
81
- ? (Array.isArray(current)
82
- ? current.map( c => ensureChoice(c, []) )
83
- : current
84
- ? [ensureChoice(current, [])]
85
- : []
86
- ) || []
76
+ ? currentArray.map( c => ensureChoice(c, [], currentArray) )
87
77
  : initChoices
88
78
  );
89
79
 
@@ -100,8 +90,6 @@ export default (initProps: Props) => {
100
90
  - ACTIONS
101
91
  ----------------------------------*/
102
92
 
103
- const valueToChoice = (value: string) => choices.find(c => c.value === value);
104
-
105
93
  React.useEffect(() => {
106
94
 
107
95
  if (choicesViaFunc && opened) {
@@ -117,8 +105,6 @@ export default (initProps: Props) => {
117
105
  })
118
106
  }
119
107
 
120
- initRef.current = true;
121
-
122
108
  }, [
123
109
  opened,
124
110
  search.keywords,
@@ -127,26 +113,37 @@ export default (initProps: Props) => {
127
113
  typeof initChoices === 'function' ? true : initChoices
128
114
  ]);
129
115
 
130
- let Component: typeof MantineSelect | typeof MantineMultiSelect;
116
+ /*----------------------------------
117
+ - RENDER
118
+ ----------------------------------*/
119
+
131
120
  if (multiple) {
132
- Component = MantineMultiSelect;
133
- props.value = current ? current.map( c => ensureChoice(c, choices).value ) : [];
121
+
122
+ props.value = current
123
+ ? current.map( c => ensureChoice(c, choices, currentArray).value )
124
+ : [];
125
+
134
126
  props.onChange = (value: string[]) => {
135
- onChange( value.map(valueToChoice) )
127
+ onChange( value.map(value => ensureChoice(value, choices, currentArray)) )
136
128
  };
129
+
137
130
  } else {
138
- Component = MantineSelect;
139
- props.value = current ? ensureChoice(current, choices).value : '';
140
- props.onChange = (value: string) => onChange( valueToChoice(value) );
141
- }
142
131
 
143
- if (props.placeholder === 'Languages') {
144
- console.log("CHOICES", current, props.value);
145
- }
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
+ }
146
146
 
147
- /*----------------------------------
148
- - RENDER
149
- ----------------------------------*/
150
147
  if (minimal) {
151
148
  return (
152
149
  <Menu width={300} opened={opened} onChange={setOpened}
@@ -207,19 +204,32 @@ export default (initProps: Props) => {
207
204
 
208
205
  } else {
209
206
  return (
210
- <Component
207
+ <MantineMultiSelect
211
208
  {...props}
212
209
 
213
- 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
+ ]}
214
221
  nothingFound={search.loading ? 'Loading...' : props || 'No options found'}
215
222
  comboboxProps={{
216
223
  withArrow: false
217
224
  }}
218
225
 
226
+ searchable={enableSearch}
219
227
  clearable={!required}
220
228
  required={required}
221
229
  allowDeselect={!required}
230
+ checkIconPosition="right"
222
231
 
232
+ dropdownOpened={opened}
223
233
  onDropdownOpen={() => setOpened(true)}
224
234
  onDropdownClose={() => setOpened(false)}
225
235
  onSearchChange={(keywords) => setSearch(s => ({ ...s, keywords }))}
@@ -136,33 +136,37 @@ export default function Liste<TRow extends TDonneeInconnue>({
136
136
  }
137
137
  }
138
138
 
139
- const isCurrentlySorted = sort && sorted && sorted.id === sort.id;
140
- const isSortable = sort && onSort;
141
- if (isSortable) {
142
- classe += ' clickable';
143
- cellProps.onClick = () => {
144
- if (isCurrentlySorted)
145
- onSort(null, sort.order);
146
- else
147
- onSort(sort.id, sort.order);
139
+ if (iDonnee === 0) {
140
+
141
+ const headerProps = { className: '', ...cellProps };
142
+ const isCurrentlySorted = sort && sorted && sorted.id === sort.id;
143
+ const isSortable = sort && onSort;
144
+ if (isSortable) {
145
+ headerProps.className += ' clickable';
146
+ headerProps.onClick = () => {
147
+ if (isCurrentlySorted)
148
+ onSort(null, sort.order);
149
+ else
150
+ onSort(sort.id, sort.order);
151
+ }
148
152
  }
153
+
154
+ renduColonnes.push(
155
+ <th {...headerProps}>
156
+ <div class="row sp-btw">
157
+
158
+ {isSortable ? (
159
+ <a>{label}</a>
160
+ ) : label}
161
+
162
+ {isCurrentlySorted && (
163
+ <i src={sort.order === "asc" ? "caret-up" : "caret-down"} />
164
+ )}
165
+ </div>
166
+ </th>
167
+ );
149
168
  }
150
169
 
151
- if (iDonnee === 0) renduColonnes.push(
152
- <th class={classe} {...cellProps}>
153
- <div class="row sp-btw">
154
-
155
- {isSortable ? (
156
- <a>{label}</a>
157
- ) : label}
158
-
159
- {isCurrentlySorted && (
160
- <i src={sort.order === "asc" ? "caret-up" : "caret-down"} />
161
- )}
162
- </div>
163
- </th>
164
- );
165
-
166
170
  let render: ComponentChild;
167
171
  if (Array.isArray(cell)) {
168
172
 
@@ -113,7 +113,7 @@ export default (props: Props) => {
113
113
  renderedContent = React.cloneElement(
114
114
  content,
115
115
  {
116
- className: 'card popover pd-1'
116
+ className: 'card popover'
117
117
  + (position ? ' pos_' + position.cote : '')
118
118
  + ' ' + (content.props.className || ''),
119
119
 
@@ -29,7 +29,7 @@
29
29
 
30
30
  list-style: none;
31
31
  text-align: left;
32
- line-height: 2rem;
32
+ //line-height: 2rem; Why ?
33
33
 
34
34
  overflow: auto;
35
35
 
@@ -103,6 +103,7 @@ export {
103
103
  Progress,
104
104
  Radio,
105
105
  Rating,
106
+ RangeSlider,
106
107
  RingProgress,
107
108
  SegmentedControl,
108
109
  //Select,
@@ -57,7 +57,7 @@ const sizeAdapter = {
57
57
  }
58
58
 
59
59
  export function useMantineInput<TProps extends __BaseInputProps & InputBaseProps<any>, TValue>({
60
- title, wrapper, hint, errors, icon, iconR, minimal, onChange, value, ...props
60
+ title, wrapper, hint, errors, icon, iconR, prefix, suffix, minimal, onChange, value, ...props
61
61
  }: InputBaseProps<TValue> & TProps): [
62
62
  InputBaseProps<any>,
63
63
  TProps
@@ -74,11 +74,11 @@ export function useMantineInput<TProps extends __BaseInputProps & InputBaseProps
74
74
  props.description = hint;
75
75
  }
76
76
  // Prefix
77
- if (props.leftSection === undefined && icon !== undefined)
78
- props.leftSection = <i src={icon} />;
77
+ if (props.leftSection === undefined)
78
+ props.leftSection = icon !== undefined ? <i src={icon} /> : prefix;
79
79
  // Suffix
80
- if (props.rightSection === undefined && iconR !== undefined)
81
- props.rightSection = <i src={iconR} />;
80
+ if (props.rightSection === undefined)
81
+ props.rightSection = iconR !== undefined ? <i src={iconR} /> : suffix;
82
82
 
83
83
  // Errors
84
84
  if (errors?.length)
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-52",
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",
@@ -220,13 +220,13 @@ export default abstract class AuthService<
220
220
  // Insufficient permissions
221
221
  } else if (!user.roles.includes(role)) {
222
222
 
223
- console.warn(LogPrefix, "Refusé: " + role + " pour " + user.name + " (" + (user.roles ? user.roles.join(', ') : 'role inconnu') + ")");
223
+ console.warn(LogPrefix, "Refusé: " + role + " pour " + user.name + " (" + (user.roles || 'role inconnu') + ")");
224
224
 
225
225
  throw new Forbidden("You do not have sufficient permissions to access this resource.");
226
226
 
227
227
  } else {
228
228
 
229
- console.warn(LogPrefix, "Autorisé " + role + " pour " + user.name + " (" + user.roles.join(', ') + ")");
229
+ console.warn(LogPrefix, "Autorisé " + role + " pour " + user.name + " (" + user.roles + ")");
230
230
 
231
231
  }
232
232
 
package/types/icons.d.ts CHANGED
@@ -1 +1 @@
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"|"rocket"|"chart-bar"|"planet-ringed"|"brands/linkedin"|"user-circle"|"crosshairs"|"plus-circle"|"comments-alt"|"arrow-right"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"key"|"user"|"at"|"user-plus"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"times-circle"|"calendar-alt"|"paper-plane"|"search"|"lightbulb"|"magnet"|"angle-up"|"angle-down"|"solid/crown"|"brands/discord"|"pen"|"plus"|"file"|"envelope"|"binoculars"|"info-circle"|"check-circle"|"exclamation-circle"|"check"|"arrow-left"|"trash"|"meh-rolling-eyes"|"bars"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"cog"|"power-off"|"question-circle"|"play"|"minus-circle"|"external-link"|"plane-departure"|"wind"|"map-marker-alt"|"clock"|"arrow-to-bottom"|"ellipsis-h"|"usd-circle"|"users"|"home-alt"|"trophy"|"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"
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"