react-ui-basics 0.0.247 → 0.0.249

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,6 +1,6 @@
1
1
  {
2
2
  "name": "react-ui-basics",
3
- "version": "0.0.247",
3
+ "version": "0.0.249",
4
4
  "description": "",
5
5
  "module": "index.js",
6
6
  "_main": "index.cjs.js",
@@ -2,8 +2,8 @@ declare const history: History;
2
2
  export type HistoryAction = 'pushState' | 'replaceState';
3
3
  export type HistoryActionArgs = Parameters<typeof history[HistoryAction]>;
4
4
  export type HistoryMiddleware = (action: HistoryAction, args: HistoryActionArgs) => HistoryActionArgs;
5
- export declare const pushLocation: (path: string) => void;
6
- export declare const replaceLocation: (path: string) => void;
5
+ export declare const pushLocation: (path: string | URL) => void;
6
+ export declare const replaceLocation: (path: string | URL) => void;
7
7
  export declare const addMiddleware: (middleware: HistoryMiddleware) => void;
8
8
  export declare const removeMiddleware: (middleware: HistoryMiddleware) => void;
9
9
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"HistoryTools.js","sources":["../src/router/HistoryTools.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;AAM/B,MAAM,WAAW,GAAwB,EAAE,CAAA;AAE3C,MAAM,MAAM,GAAoB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AAC9D,MAAM,CAAC,OAAO,CAAC,CAAC,IAAG;AACf,IAAA,IAAI,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,OAAO,CAAC,CAAC,CAAC,GAAG,YAAA;QACT,IAAI,IAAI,GAAG,SAAqC,CAAC;AACjD,QAAA,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;AAClC,YAAA,IAAI,GAAG,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;AAC1B,YAAA,IAAI,CAAC,IAAI;gBAAE,MAAK;AACnB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a,GAAG,CAAC,UAA6B,KAAI;AAC3D,IAAA,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACjC,EAAE;AACW,MAAA,gBAAgB,GAAG,CAAC,UAA6B,KAAI;IAC9D,IAAI,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAC5C,IAAA,KAAK,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;AACjD,EAAE;AAEF,IAAI,MAAM,CAAC,4BAA4B,CAAC,EAAE;;;IAGtC,MAAM,CAAC,eAAe,CAAC,GAAG;QACtB,eAAe;QACf,aAAa;QACb,gBAAgB;KACnB,CAAA;AACJ;;;;"}
@@ -170,6 +170,7 @@ class AutocompleteSelect extends PureComponent {
170
170
  selectCustomOnClickOutside: true,
171
171
  withReset: false,
172
172
  scrollToValue: false,
173
+ disabled: false,
173
174
  mode: MODE_DEFAULT,
174
175
  selectedMode: 'full',
175
176
  listPortalPosition: 'left',
@@ -204,6 +205,7 @@ class AutocompleteSelect extends PureComponent {
204
205
  className,
205
206
  scrollToValue,
206
207
  scroll,
208
+ disabled,
207
209
  required,
208
210
  allowCustom,
209
211
  inlineSelected,
@@ -227,17 +229,21 @@ class AutocompleteSelect extends PureComponent {
227
229
  const selectedIds = Object.values(selected);
228
230
  const hasSelected = __length(selectedIds) !== 0;
229
231
  const setActive = (e) => {
230
- stopPropagation(e);
231
- this.setState({isActive: true}, () => {
232
- scrollToValue && __length(selectedIds) > 0 && data.includes(selectedIds[0]) && this.list.selected(selectedIds[0]);
233
- });
232
+ if (!disabled) {
233
+ stopPropagation(e);
234
+ this.setState({isActive: true}, () => {
235
+ scrollToValue && __length(selectedIds) > 0 && data.includes(selectedIds[0]) && this.list.selected(selectedIds[0]);
236
+ });
237
+ }
234
238
  };
235
239
  const toggle = (e) => {
236
- if (!__state(this).isActive) {
237
- setActive(e);
238
- } else {
239
- stopPropagation(e);
240
- this.setState({isActive: false});
240
+ if (!disabled) {
241
+ if (!__state(this).isActive) {
242
+ setActive(e);
243
+ } else {
244
+ stopPropagation(e);
245
+ this.setState({isActive: false});
246
+ }
241
247
  }
242
248
  };
243
249
 
@@ -278,6 +284,7 @@ class AutocompleteSelect extends PureComponent {
278
284
  errored && 'errored',
279
285
  inlineSelected && 'inlineSelected',
280
286
  hasSelected && 'hasSelected',
287
+ disabled && 'disabled',
281
288
  )}
282
289
  ref={ref('el', this)}>
283
290
  {label && <label className={classNames(`label`, (hasSelected || filterValue) && 'active', hasSelected && 'hasSelected')}
@@ -297,6 +304,7 @@ class AutocompleteSelect extends PureComponent {
297
304
  <div
298
305
  className={classNames('selected',
299
306
  !label && 'nolabel',
307
+ disabled && 'disabled',
300
308
  (mode === MODE_MULTIPLE_MINI || mode === MODE_MINI || mode === MODE_MULTIPLE_MINI_INLINE) && 'clickable',
301
309
  selectedMode)}
302
310
  onClick={toggle}>
@@ -305,8 +313,10 @@ class AutocompleteSelect extends PureComponent {
305
313
  <div className="value" key={id}>
306
314
  {React.createElement(selectedComponent, {...childProps, id, label: getLabel(labels, id), [ReactConstants[6]]: setActive})}
307
315
  <div className="button remove" onClick={e => {
308
- stopPropagation(e);
309
- this.remove(id);
316
+ if (!disabled) {
317
+ stopPropagation(e);
318
+ this.remove(id);
319
+ }
310
320
  }}>
311
321
  {removeIcon}
312
322
  </div>
@@ -319,7 +329,7 @@ class AutocompleteSelect extends PureComponent {
319
329
  </React.Fragment>
320
330
  )}
321
331
  {!label && withArrow && <span className="arrow"/>}
322
- {withReset && <Button className="reset" raised={false} onClick={this.clean}>
332
+ {withReset && <Button className="reset" disabled={disabled} raised={false} onClick={this.clean}>
323
333
  {removeIcon}
324
334
  </Button>}
325
335
  </div>
@@ -330,8 +340,10 @@ class AutocompleteSelect extends PureComponent {
330
340
  <div className="value" key={id}>
331
341
  {React.createElement(selectedComponent, {...childProps, id, label: getLabel(labels, id), [ReactConstants[6]]: setActive})}
332
342
  <div className="button remove" onClick={e => {
333
- stopPropagation(e);
334
- this.remove(id);
343
+ if (!disabled) {
344
+ stopPropagation(e);
345
+ this.remove(id);
346
+ }
335
347
  }}>
336
348
  {removeIcon}
337
349
  </div>
@@ -352,6 +364,7 @@ class AutocompleteSelect extends PureComponent {
352
364
  focused={isActive}
353
365
  value={filterValue}
354
366
  label={inputLabel}
367
+ disabled={disabled}
355
368
  onChange={this[ReactConstants[7]]}
356
369
  onFocus={e => this.setState({isActive: true})}
357
370
  check={__props(this).filterCheck}
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, {CSSProperties} from 'react';
2
2
  import ReactCreateElement from './ReactCreateElement';
3
3
  import {classNames} from "./Tools";
4
4
 
@@ -13,6 +13,7 @@ export interface MaterialIconProps {
13
13
  icon: MaterialIconType
14
14
  className?: string
15
15
  type?: 'Outlined' | 'Filled' | 'Rounded' | 'Sharp' | 'TwoTone'
16
+ style?: CSSProperties
16
17
  }
17
18
 
18
19
  let DEFAULT_CLASS_NAME = 'material-icons';
@@ -24,7 +25,7 @@ const typeToClass = {
24
25
  'TwoTone': DEFAULT_CLASS_NAME + '-two-tone',
25
26
  }
26
27
 
27
- const MaterialIcon = ({icon, className, type = 'Filled'}: MaterialIconProps) => (
28
- <i className={classNames('MaterialIcon', typeToClass[type] || DEFAULT_CLASS_NAME, className)} translate="no">{icon}</i>
28
+ const MaterialIcon = ({icon, className, type = 'Filled', style}: MaterialIconProps) => (
29
+ <i className={classNames('MaterialIcon', typeToClass[type] || DEFAULT_CLASS_NAME, className)} style={style} translate="no">{icon}</i>
29
30
  );
30
31
  export default MaterialIcon;
package/src/ModalMenu.tsx CHANGED
@@ -5,10 +5,9 @@ import {PureComponent, stateGS, render} from "./ReactConstants";
5
5
  import {classNames} from "./Tools";
6
6
  import Animated from "./Animated";
7
7
  import Button from "./Button";
8
- import MaterialIcon, {MaterialIconType} from "./MaterialIcon";
8
+ import MaterialIcon, {MaterialIconProps} from "./MaterialIcon";
9
9
 
10
- export interface ModalMenuItem {
11
- icon: MaterialIconType,
10
+ export interface ModalMenuItem extends MaterialIconProps {
12
11
  action: MouseEventHandler
13
12
  }
14
13
 
@@ -45,7 +44,7 @@ class ModalMenu extends PureComponent<ModalMenuProps> {
45
44
  }}
46
45
  >
47
46
  <Button flat={true} round={true} onClick={it.action}>
48
- <MaterialIcon icon={it.icon}/>
47
+ <MaterialIcon {...it}/>
49
48
  </Button>
50
49
  </Animated>)}
51
50
 
@@ -13,21 +13,16 @@ export const stateFieldSetter = (that, key, cb?: () => void) => (value, cb2?) =>
13
13
  };
14
14
 
15
15
  export type Callback = () => void;
16
- export function createStateGetterSetter<C extends React.Component, K extends keyof C["state"]>(that: C, key: K, cb?: Callback): {
16
+ export const createStateGetterSetter = <C extends React.Component, K extends keyof C["state"]>(that: C, key: K, cb?: Callback): {
17
17
  (): C["state"][K];
18
18
  (value: C["state"][K], cb2?: Callback): void;
19
- } {
20
- return ((value?: C["state"][K], cb2?: Callback): C["state"][K] => {
21
- if (arguments.length === 0) {
22
- // getter
23
- // @ts-ignore
24
- return that.state[key];
25
- } else {
26
- // setter
27
- that.setState({[key]: value} as any, cb2 ?? cb);
28
- }
29
- }) as any;
30
- }
19
+ } => (function (value?: C["state"][K], cb2?: Callback): C["state"][K] {
20
+ return arguments.length === 0 ?
21
+ // @ts-ignore
22
+ state(that)[key]
23
+ :
24
+ setState(that, {[key]: value} as any, cb2 ?? cb)
25
+ });
31
26
 
32
27
  type GetterSetter<T> = (v?: T, cb?: () => void) => T;
33
28
  export const stateGS: (<T>(that: React.Component) => GetterSetter<T>) = (that) => {
@@ -27,9 +27,9 @@ const fireEvent = (name) => {
27
27
  WINDOW.dispatchEvent(event);
28
28
  };
29
29
 
30
- export const pushLocation = (path: string) => path !== WINDOW.location.pathname && history[events[0]](null, null, path);
30
+ export const pushLocation = (path: string | URL) => path !== WINDOW.location.pathname && history[events[0]](null, null, path);
31
31
 
32
- export const replaceLocation = (path: string) => history[events[1]](null, null, path);
32
+ export const replaceLocation = (path: string | URL) => history[events[1]](null, null, path);
33
33
 
34
34
  export const addMiddleware = (middleware: HistoryMiddleware) => {
35
35
  middlewares.push(middleware);