@gisce/react-ooui 0.19.0 → 0.21.0

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 +1 @@
1
- {"version":3,"file":"Notebook.d.ts","sourceRoot":"","sources":["../../../src/widgets/containers/Notebook.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAsB,MAAM,aAAa,CAAC;AAG3E,aAAK,KAAK,GAAG;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,iBAAS,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,CAoBlD;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Notebook.d.ts","sourceRoot":"","sources":["../../../src/widgets/containers/Notebook.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAsB,MAAM,aAAa,CAAC;AAG3E,aAAK,KAAK,GAAG;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,iBAAS,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,CA6BlD;AAED,eAAe,QAAQ,CAAC"}
@@ -5,15 +5,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var react_1 = __importDefault(require("react"));
7
7
  var antd_1 = require("antd");
8
+ var iconMapper_1 = __importDefault(require("@/helpers/iconMapper"));
8
9
  var TabPane = antd_1.Tabs.TabPane;
9
10
  var index_1 = require("@/index");
10
11
  function Notebook(props) {
11
12
  var ooui = props.ooui, responsiveBehaviour = props.responsiveBehaviour;
12
- var tabs = [].concat.apply([], ooui.container.rows);
13
- return (react_1.default.createElement(antd_1.Tabs, { defaultActiveKey: "1" }, tabs
13
+ var tabs = ooui.pages;
14
+ function getPageIcon(icon) {
15
+ if (icon) {
16
+ var Icon = iconMapper_1.default(icon);
17
+ return Icon && react_1.default.createElement(Icon, null);
18
+ }
19
+ return undefined;
20
+ }
21
+ return (react_1.default.createElement(antd_1.Tabs, { defaultActiveKey: "1", tabPosition: ooui.tabPosition }, tabs
14
22
  .filter(function (page) { return !page.invisible; })
15
23
  .map(function (page) {
16
- return (react_1.default.createElement(TabPane, { tab: page.label, key: page.label },
24
+ return (react_1.default.createElement(TabPane, { tab: react_1.default.createElement(react_1.default.Fragment, null,
25
+ getPageIcon(page.icon),
26
+ " ",
27
+ page.label), key: page.label },
17
28
  react_1.default.createElement(index_1.Group, { ooui: page, showLabel: false, responsiveBehaviour: responsiveBehaviour })));
18
29
  })));
19
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Notebook.js","sourceRoot":"","sources":["../../../src/widgets/containers/Notebook.tsx"],"names":[],"mappings":";;;;;AAAA,gDAA0B;AAC1B,6BAA4B;AACpB,IAAA,OAAO,GAAK,WAAI,QAAT,CAAU;AAGzB,iCAAgC;AAOhC,SAAS,QAAQ,CAAC,KAAY;IACpB,IAAA,IAAI,GAA0B,KAAK,KAA/B,EAAE,mBAAmB,GAAK,KAAK,oBAAV,CAAW;IAC5C,IAAM,IAAI,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,IAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO,CACL,8BAAC,WAAI,IAAC,gBAAgB,EAAC,GAAG,IACvB,IAAI;SACF,MAAM,CAAC,UAAC,IAAS,IAAK,OAAA,CAAC,IAAI,CAAC,SAAS,EAAf,CAAe,CAAC;SACtC,GAAG,CAAC,UAAC,IAAS;QACb,OAAO,CACL,8BAAC,OAAO,IAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CA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ACM,CACX,CAAC;IACJ,CAAC,CAAC,CACC,CACR,CAAC;AACJ,CAAC;AAED,kBAAe,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist",
@@ -24,9 +24,10 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@ant-design/charts": "^1.3.6",
27
- "@gisce/ooui": "^0.14.0",
27
+ "@gisce/ooui": "^0.16.1",
28
28
  "@gisce/react-formiga-table": "^0.5.0",
29
29
  "@monaco-editor/react": "^4.4.5",
30
+ "@tabler/icons": "^1.95.1",
30
31
  "fiber-diagram": "github:gisce/fiber-diagram",
31
32
  "file-type": "^16.5.0",
32
33
  "react-grid-layout": "^1.3.4",
@@ -1,4 +1,6 @@
1
- import * as Icons from "@ant-design/icons";
1
+ import Icon, * as Icons from "@ant-design/icons";
2
+ import * as TablerIcons from "@tabler/icons";
3
+ import React from "react";
2
4
 
3
5
  const iconMapping: { [key: string]: React.ElementType } = {
4
6
  STOCK_HELP: Icons.QuestionOutlined,
@@ -96,13 +98,17 @@ export default (key: string): React.ElementType => {
96
98
  }
97
99
  if (iconMapping.hasOwnProperty(key)) {
98
100
  return iconMapping[key];
99
- } else {
100
- const antKey = `${key.split("-").map((word) => (
101
- word.replace(/\w\S*/g, (w) => (w.charAt(0).toUpperCase() + w.substr(1).toLowerCase())))
102
- ).join("")}Outlined`
101
+ }
102
+ const IconCamelCase = `${key.split("-").map((word) => (
103
+ word.replace(/\w\S*/g, (w) => (w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())))
104
+ ).join("")}`;
105
+ const antKey = `${IconCamelCase}Outlined`
106
+ if (Icons.hasOwnProperty(antKey)) {
103
107
  // @ts-ignore
104
108
  return Icons[antKey];
105
109
  }
106
-
107
-
110
+ const tablerKey = `Icon${IconCamelCase}`;
111
+ // @ts-ignore
112
+ const CustomIcon = () => React.createElement(Icon, {component: TablerIcons[tablerKey]});
113
+ return CustomIcon
108
114
  };
@@ -73,6 +73,19 @@ export const WithUnexistingdIcon = (): React.ReactElement => {
73
73
  );
74
74
  };
75
75
 
76
+ export const WithTablerIcon = (): React.ReactElement => {
77
+ const ooui = new ButtonOoui({
78
+ name: "button_field",
79
+ string: "Lorem ipsum",
80
+ icon: "bulb-off"
81
+ });
82
+ return (
83
+ <LocaleProvider lang="en_US">
84
+ <Button ooui={ooui} />
85
+ </LocaleProvider>
86
+ );
87
+ };
88
+
76
89
  export const PrimaryButton = (): React.ReactElement => {
77
90
  const ooui = new ButtonOoui({
78
91
  name: "button_field",
@@ -88,3 +88,82 @@ export const Test = (): React.ReactElement => {
88
88
  </LocaleProvider>
89
89
  );
90
90
  };
91
+
92
+ export const BottomPosition = (): React.ReactElement => {
93
+
94
+ const arch = `<form>
95
+ <notebook name="notebook" tabpos="bottom">
96
+ <page string="General">
97
+ <field name="name" />
98
+ </page>
99
+ <page string="Secondary">
100
+ <field name="surname" />
101
+ </page>
102
+ </notebook>
103
+ </form>`;
104
+
105
+ const formOoui = new FormOoui(fields);
106
+ formOoui.parse(arch);
107
+ const notebookOoui = formOoui.findById("notebook") as NotebookOoui;
108
+
109
+ return (
110
+ <LocaleProvider lang="en_US">
111
+ <Form>
112
+ <Notebook ooui={notebookOoui} />
113
+ </Form>
114
+ </LocaleProvider>
115
+ );
116
+ };
117
+
118
+
119
+ export const LeftPosition = (): React.ReactElement => {
120
+
121
+ const arch = `<form>
122
+ <notebook name="notebook" tabpos="left">
123
+ <page string="General">
124
+ <field name="name" />
125
+ </page>
126
+ <page string="Secondary">
127
+ <field name="surname" />
128
+ </page>
129
+ </notebook>
130
+ </form>`;
131
+
132
+ const formOoui = new FormOoui(fields);
133
+ formOoui.parse(arch);
134
+ const notebookOoui = formOoui.findById("notebook") as NotebookOoui;
135
+
136
+ return (
137
+ <LocaleProvider lang="en_US">
138
+ <Form>
139
+ <Notebook ooui={notebookOoui} />
140
+ </Form>
141
+ </LocaleProvider>
142
+ );
143
+ };
144
+
145
+ export const IconTabs = (): React.ReactElement => {
146
+
147
+ const arch = `<form>
148
+ <notebook name="notebook">
149
+ <page string="Home" icon="home">
150
+ <field name="name" />
151
+ </page>
152
+ <page string="Attributes" icon="project">
153
+ <field name="surname" />
154
+ </page>
155
+ </notebook>
156
+ </form>`;
157
+
158
+ const formOoui = new FormOoui(fields);
159
+ formOoui.parse(arch);
160
+ const notebookOoui = formOoui.findById("notebook") as NotebookOoui;
161
+
162
+ return (
163
+ <LocaleProvider lang="en_US">
164
+ <Form>
165
+ <Notebook ooui={notebookOoui} />
166
+ </Form>
167
+ </LocaleProvider>
168
+ );
169
+ };
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { Tabs } from "antd";
3
+ import iconMapper from "@/helpers/iconMapper";
3
4
  const { TabPane } = Tabs;
4
5
 
5
6
  import { Notebook as NotebookOoui, Group as GroupOoui } from "@gisce/ooui";
@@ -12,14 +13,23 @@ type Props = {
12
13
 
13
14
  function Notebook(props: Props): React.ReactElement {
14
15
  const { ooui, responsiveBehaviour } = props;
15
- const tabs = [].concat.apply([], ooui!.container.rows);
16
+ const tabs = ooui.pages;
17
+
18
+ function getPageIcon(icon: string) {
19
+ if (icon) {
20
+ const Icon: React.ElementType = iconMapper(icon);
21
+ return Icon && <Icon />;
22
+ }
23
+ return undefined;
24
+ }
25
+
16
26
  return (
17
- <Tabs defaultActiveKey="1">
27
+ <Tabs defaultActiveKey="1" tabPosition={ooui.tabPosition}>
18
28
  {tabs
19
29
  .filter((page: any) => !page.invisible)
20
30
  .map((page: any) => {
21
31
  return (
22
- <TabPane tab={page.label} key={page.label}>
32
+ <TabPane tab={<>{getPageIcon(page.icon)} {page.label}</>} key={page.label}>
23
33
  <Group
24
34
  ooui={page as GroupOoui}
25
35
  showLabel={false}