goblin-magic 1.0.3

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.
Files changed (88) hide show
  1. package/.editorconfig +9 -0
  2. package/.zou-flow +2 -0
  3. package/eslint.config.js +65 -0
  4. package/magicNavigation.js +7 -0
  5. package/package.json +45 -0
  6. package/widgets/dialog/widget.js +78 -0
  7. package/widgets/element-helpers/element-has-direct-text.js +9 -0
  8. package/widgets/element-helpers/is-empty-area-element.js +17 -0
  9. package/widgets/element-helpers/is-flat-element.js +52 -0
  10. package/widgets/get-modifiers/get-modifiers.js +34 -0
  11. package/widgets/input-group/styles.js +74 -0
  12. package/widgets/input-group/widget.js +24 -0
  13. package/widgets/magic-action/styles.js +45 -0
  14. package/widgets/magic-action/widget.js +44 -0
  15. package/widgets/magic-background/bg-alps.jpg +0 -0
  16. package/widgets/magic-background/bg-fur.png +0 -0
  17. package/widgets/magic-background/bg-milkyway.png +0 -0
  18. package/widgets/magic-background/bg-space.jpg +0 -0
  19. package/widgets/magic-background/bg-synth.jpg +0 -0
  20. package/widgets/magic-background/bg-white.png +0 -0
  21. package/widgets/magic-background/styles.js +81 -0
  22. package/widgets/magic-background/widget.js +20 -0
  23. package/widgets/magic-box/styles.js +10 -0
  24. package/widgets/magic-box/widget.js +28 -0
  25. package/widgets/magic-box-old/styles.js +111 -0
  26. package/widgets/magic-box-old/widget.js +30 -0
  27. package/widgets/magic-button/styles.js +156 -0
  28. package/widgets/magic-button/widget.js +89 -0
  29. package/widgets/magic-checkbox/styles.js +116 -0
  30. package/widgets/magic-checkbox/widget.js +68 -0
  31. package/widgets/magic-color-field/styles.js +22 -0
  32. package/widgets/magic-color-field/widget.js +68 -0
  33. package/widgets/magic-date-field/styles.js +9 -0
  34. package/widgets/magic-date-field/widget.js +145 -0
  35. package/widgets/magic-datetime-field/styles.js +11 -0
  36. package/widgets/magic-datetime-field/widget.js +95 -0
  37. package/widgets/magic-dialog/styles.js +39 -0
  38. package/widgets/magic-dialog/widget.js +116 -0
  39. package/widgets/magic-div/styles.js +22 -0
  40. package/widgets/magic-div/widget.js +20 -0
  41. package/widgets/magic-emoji/styles.js +14 -0
  42. package/widgets/magic-emoji/widget.js +33 -0
  43. package/widgets/magic-emoji-picker/styles.js +21 -0
  44. package/widgets/magic-emoji-picker/widget.js +44 -0
  45. package/widgets/magic-inplace-input/styles.js +55 -0
  46. package/widgets/magic-inplace-input/widget.js +26 -0
  47. package/widgets/magic-input/styles.js +50 -0
  48. package/widgets/magic-input/widget.js +397 -0
  49. package/widgets/magic-label/styles.js +20 -0
  50. package/widgets/magic-label/widget.js +24 -0
  51. package/widgets/magic-navigation/service.js +1306 -0
  52. package/widgets/magic-navigation/styles.js +103 -0
  53. package/widgets/magic-navigation/view-context.js +15 -0
  54. package/widgets/magic-navigation/widget.js +540 -0
  55. package/widgets/magic-number-field/styles.js +10 -0
  56. package/widgets/magic-number-field/widget.js +103 -0
  57. package/widgets/magic-panel/styles.js +61 -0
  58. package/widgets/magic-panel/widget.js +63 -0
  59. package/widgets/magic-radio/styles.js +93 -0
  60. package/widgets/magic-radio/widget.js +74 -0
  61. package/widgets/magic-scroll/styles.js +22 -0
  62. package/widgets/magic-scroll/widget.js +20 -0
  63. package/widgets/magic-select/styles.js +16 -0
  64. package/widgets/magic-select/widget.js +134 -0
  65. package/widgets/magic-table/reducer.js +63 -0
  66. package/widgets/magic-table/styles.js +170 -0
  67. package/widgets/magic-table/widget.js +627 -0
  68. package/widgets/magic-tag/styles.js +32 -0
  69. package/widgets/magic-tag/widget.js +32 -0
  70. package/widgets/magic-text-field/styles.js +58 -0
  71. package/widgets/magic-text-field/widget.js +66 -0
  72. package/widgets/magic-time-field/styles.js +8 -0
  73. package/widgets/magic-time-field/widget.js +142 -0
  74. package/widgets/magic-timer/styles.js +30 -0
  75. package/widgets/magic-timer/widget.js +162 -0
  76. package/widgets/magic-zen/styles.js +61 -0
  77. package/widgets/magic-zen/widget.js +42 -0
  78. package/widgets/main-tabs/styles.js +106 -0
  79. package/widgets/main-tabs/widget.js +23 -0
  80. package/widgets/menu/styles.js +156 -0
  81. package/widgets/menu/test-menu.html +154 -0
  82. package/widgets/menu/widget.js +575 -0
  83. package/widgets/movable/widget.js +80 -0
  84. package/widgets/splitter/styles.js +57 -0
  85. package/widgets/splitter/widget.js +40 -0
  86. package/widgets/tab-layout/styles.js +31 -0
  87. package/widgets/tab-layout/widget.js +59 -0
  88. package/widgets/with-computed-size/widget.js +52 -0
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import Widget from 'goblin-laboratory/widgets/widget';
3
+ import SplitterLayout from 'react-splitter-layout';
4
+ import 'react-splitter-layout/lib/index.css';
5
+ import * as styles from './styles.js';
6
+
7
+ class Splitter extends Widget {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.styles = styles;
11
+ }
12
+
13
+ render() {
14
+ const {
15
+ primaryMinSize,
16
+ secondaryMinSize,
17
+ secondaryInitialSize,
18
+ percentage,
19
+ vertical,
20
+ children,
21
+ className = '',
22
+ } = this.props;
23
+ return (
24
+ <SplitterLayout
25
+ customClassName={this.styles.classNames.splitter + ' ' + className}
26
+ primaryMinSize={primaryMinSize}
27
+ secondaryMinSize={secondaryMinSize}
28
+ secondaryInitialSize={secondaryInitialSize}
29
+ percentage={percentage}
30
+ vertical={vertical}
31
+ >
32
+ {children}
33
+ </SplitterLayout>
34
+ );
35
+ }
36
+ }
37
+
38
+ /******************************************************************************/
39
+
40
+ export default Splitter;
@@ -0,0 +1,31 @@
1
+ export default function styles() {
2
+ const tabLayout = {
3
+ 'display': 'flex',
4
+ 'flexDirection': 'column',
5
+ 'minWidth': 0, // allow to shrink
6
+
7
+ '& > *+*': {
8
+ flexGrow: 1,
9
+ minHeight: 0, // allow to shrink
10
+ },
11
+ };
12
+
13
+ const tabs = {
14
+ '& > *': {
15
+ 'color': 'inherit',
16
+ 'fontSize': 'inherit',
17
+ 'cursor': 'pointer',
18
+
19
+ '&[data-active=true]': {},
20
+
21
+ ':hover': {},
22
+
23
+ ':active': {},
24
+ },
25
+ };
26
+
27
+ return {
28
+ tabLayout,
29
+ tabs,
30
+ };
31
+ }
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import Widget from 'goblin-laboratory/widgets/widget';
3
+ import * as styles from './styles.js';
4
+ import withC from 'goblin-laboratory/widgets/connect-helpers/with-c.js';
5
+
6
+ class TabLayout extends Widget {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.styles = styles;
10
+ }
11
+
12
+ render() {
13
+ const {children, className = '', ...props} = this.props;
14
+ return (
15
+ <div
16
+ {...props}
17
+ className={this.styles.classNames.tabLayout + ' ' + className}
18
+ >
19
+ {children}
20
+ </div>
21
+ );
22
+ }
23
+ }
24
+
25
+ class TabLayoutTabs extends Widget {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.styles = styles;
29
+ this.handleTabClick = this.handleTabClick.bind(this);
30
+ }
31
+
32
+ handleTabClick(value, event) {
33
+ this.props.onTabClick?.(value, event);
34
+ }
35
+
36
+ render() {
37
+ const {currentTab, onTabClick, ...props} = this.props;
38
+ const className = this.props.className || '';
39
+ return (
40
+ <div {...props} className={this.styles.classNames.tabs + ' ' + className}>
41
+ {React.Children.map(this.props.children, (child) => {
42
+ if (!child) {
43
+ return child;
44
+ }
45
+ const value = child.props.value;
46
+ return React.cloneElement(child, {
47
+ 'onClick': (event) =>
48
+ (child.props.onClick || this.handleTabClick)(value, event),
49
+ 'data-active': currentTab === value,
50
+ });
51
+ })}
52
+ </div>
53
+ );
54
+ }
55
+ }
56
+
57
+ TabLayout.Tabs = withC(TabLayoutTabs);
58
+
59
+ export default TabLayout;
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import Widget from 'goblin-laboratory/widgets/widget/index.js';
3
+
4
+ const hiddenStyle = {
5
+ position: 'fixed',
6
+ top: '0px',
7
+ left: '0px',
8
+ visibility: 'hidden',
9
+ };
10
+
11
+ class WithComputedSize extends Widget {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.state = {
15
+ size: null,
16
+ mounted: false,
17
+ };
18
+ this.contentRef = React.createRef();
19
+ }
20
+
21
+ componentDidMount() {
22
+ // If we use getBoundingClientRect in componentDidMount, the width and height are zero
23
+ this.setState({
24
+ mounted: true,
25
+ });
26
+ }
27
+
28
+ componentDidUpdate() {
29
+ if (!this.state.size) {
30
+ const element = this.contentRef.current;
31
+ if (!element) {
32
+ console.error(
33
+ `Ref not available in <WithComputedSize>. Unable to render its content.`
34
+ );
35
+ }
36
+ const {width, height} = element.getBoundingClientRect();
37
+ this.setState({
38
+ size: {width, height},
39
+ });
40
+ }
41
+ }
42
+
43
+ render() {
44
+ const style = this.state.size ? null : hiddenStyle;
45
+ return (
46
+ this.state.mounted &&
47
+ this.props.children(this.contentRef, style, this.state.size)
48
+ );
49
+ }
50
+ }
51
+
52
+ export default WithComputedSize;