@gisce/react-ooui 1.4.3-rc.0 → 1.4.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.
@@ -1,5 +1,7 @@
1
1
  import React from "react";
2
2
  import { WidgetProps } from '../../types';
3
+ import { TagProps } from 'antd';
3
4
  export declare const Tag: (props: WidgetProps) => React.JSX.Element;
4
5
  export declare const TagInput: (props: any) => React.JSX.Element | null;
6
+ export declare const CustomTag: (props: TagProps) => React.JSX.Element;
5
7
  //# sourceMappingURL=Tag.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["Tag.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAKtC,eAAO,MAAM,GAAG,UAAW,WAAW,sBAMrC,CAAC;AAEF,eAAO,MAAM,QAAQ,UAAW,GAAG,6BAiBlC,CAAA"}
1
+ {"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["Tag.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAkB,QAAQ,EAAE,MAAM,MAAM,CAAC;AAIhD,eAAO,MAAM,GAAG,UAAW,WAAW,sBAMrC,CAAC;AAEF,eAAO,MAAM,QAAQ,UAAW,GAAG,6BAiBlC,CAAA;AAGD,eAAO,MAAM,SAAS,UAAW,QAAQ,sBAaxC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tags.d.ts","sourceRoot":"","sources":["Tags.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAg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files": [
5
5
  "dist",
6
6
  "src",
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useState } from "react";
2
- import { Space, Spin } from "antd";
2
+ import { Space } from "antd";
3
3
  import ChangeViewButton from "./ChangeViewButton";
4
4
  import {
5
5
  ActionViewContext,
@@ -151,13 +151,6 @@ function TreeActionBar(props: Props) {
151
151
 
152
152
  return (
153
153
  <Space wrap={true}>
154
- {treeIsLoading && (
155
- <>
156
- <Spin />
157
- {separator()}
158
- {separator()}
159
- </>
160
- )}
161
154
  {treeExpandable ? null : (
162
155
  <>
163
156
  <SearchBar
@@ -295,11 +295,3 @@ export const colorTextFromBackground = (color: string) => {
295
295
  return getTextColor(color);
296
296
 
297
297
  }
298
-
299
- export const colorsFromString = (text: string): any => {
300
- const backgroundColor = colorFromString(text)
301
- return {
302
- backgroundColor,
303
- textColor: colorTextFromBackground(backgroundColor)
304
- }
305
- }
@@ -293,7 +293,6 @@ export const useSearch = (opts: UseSearchOpts) => {
293
293
 
294
294
  const changeSort = useCallback(
295
295
  (newSorter: any) => {
296
- if (JSON.stringify(newSorter) === JSON.stringify(sorter)) return;
297
296
  setSorter?.(newSorter);
298
297
  const sortedResults =
299
298
  newSorter !== undefined
@@ -0,0 +1,16 @@
1
+ // @ts-ignore
2
+ import React from "react";
3
+ import { CustomTag } from "../widgets/custom/Tag";
4
+ import { colorFromString } from "../helpers/formHelper";
5
+
6
+ export default {
7
+ title: "Components/Pure",
8
+ };
9
+
10
+
11
+
12
+ export const CustomTagWithColor = (): React.ReactElement => {
13
+ const text = "Hacker";
14
+ const color = colorFromString(text);
15
+ return <CustomTag color={color}>{text}</CustomTag>
16
+ };
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import Field from "@/common/Field";
3
3
  import { WidgetProps } from "@/types";
4
- import { Tag as AntdTag } from 'antd';
5
- import { isPresetStatusColor } from 'antd/lib/_util/colors'
6
- import { colorFromString, colorTextFromBackground } from "@/helpers/formHelper";
4
+ import { Tag as AntdTag, TagProps } from 'antd';
5
+ import { isPresetStatusColor, isPresetColor } from 'antd/lib/_util/colors'
6
+ import { colorFromString } from "@/helpers/formHelper";
7
7
 
8
8
  export const Tag = (props: WidgetProps) => {
9
9
  return (
@@ -28,6 +28,22 @@ export const TagInput = (props: any) => {
28
28
  }
29
29
  const color = ooui.colors === "auto" ? colorFromString(colorValue) : ooui.colors[colorValue] || colorFromString(colorValue);
30
30
  return (
31
- <AntdTag color={color} style={isPresetStatusColor(color) ? {} : {color: colorTextFromBackground(color)}}>{formattedValue}</AntdTag>
31
+ <CustomTag color={color}>{formattedValue}</CustomTag>
32
32
  );
33
- }
33
+ }
34
+
35
+
36
+ export const CustomTag = (props: TagProps) => {
37
+ let { color } = props;
38
+ let style = {}
39
+ if (!isPresetStatusColor(props.color) && !isPresetColor(props.color)) {
40
+ style = {
41
+ color: color,
42
+ borderColor: color,
43
+ borderStyle: "solid",
44
+ borderWidth: "1px",
45
+ }
46
+ color = `${color}20`;
47
+ }
48
+ return <AntdTag {...props} style={style} color={color}>{props.children}</AntdTag>
49
+ }
@@ -5,9 +5,10 @@ import { WidgetProps } from "@/types";
5
5
  import { One2manyItem, One2manyValue } from "../base/one2many/One2manyInput";
6
6
  import useDeepCompareEffect from "use-deep-compare-effect";
7
7
  import { FormContext, FormContextType } from "@/context/FormContext";
8
- import { Alert, Tag as AntTag, Select } from "antd";
9
- import { colorsFromString, transformPlainMany2Ones } from "@/helpers/formHelper";
8
+ import { Alert, Select } from "antd";
9
+ import { colorFromString, transformPlainMany2Ones } from "@/helpers/formHelper";
10
10
  import ConnectionProvider from "@/ConnectionProvider";
11
+ import { CustomTag } from "@/widgets/custom/Tag";
11
12
 
12
13
  type TagsProps = WidgetProps & {
13
14
  ooui: TagsOoui;
@@ -126,17 +127,17 @@ export const TagsInput = (props: TagsInputProps) => {
126
127
  event.preventDefault();
127
128
  event.stopPropagation();
128
129
  };
129
- const colors = colorsFromString(label);
130
+ const color = colorFromString(label);
130
131
  return (
131
- <AntTag
132
- color={colors.backgroundColor}
132
+ <CustomTag
133
+ color={color}
133
134
  onMouseDown={onPreventMouseDown}
134
- style={{ margin: "5px", color: colors.textColor }}
135
135
  closable={closable}
136
136
  onClose={onClose}
137
+ closeIcon={<span style={{color}}>X</span>}
137
138
  >
138
139
  {label}
139
- </AntTag>
140
+ </CustomTag>
140
141
  );
141
142
  };
142
143
 
@@ -182,9 +182,9 @@ function SearchTree(props: Props, ref: any) {
182
182
  setInitialFetchDone(true);
183
183
  } catch (error) {
184
184
  setInitialError(error);
185
- setTreeIsLoading?.(false);
186
185
  } finally {
187
186
  setIsLoading(false);
187
+ setTreeIsLoading?.(false);
188
188
  }
189
189
  };
190
190
 
@@ -118,7 +118,7 @@ const imageComponent = (value: string): React.ReactElement => {
118
118
  };
119
119
 
120
120
  const TagComponent = (
121
- value: any,
121
+ value: any,
122
122
  key: string,
123
123
  ooui: any,
124
124
  context: any
@@ -127,12 +127,14 @@ const TagComponent = (
127
127
  };
128
128
 
129
129
  const SelectionComponent = (
130
- value: any,
130
+ value: any,
131
131
  key: string,
132
132
  ooui: any,
133
133
  context: any
134
134
  ): React.ReactElement => {
135
- return <>{ooui.selectionValues.get(value)}</>;
135
+ return (
136
+ <>{ooui.selectionValues.get(value)}</>
137
+ );
136
138
  };
137
139
 
138
140
  const referenceComponent = (
@@ -152,12 +154,9 @@ const referenceComponent = (
152
154
  );
153
155
  };
154
156
 
155
- const AvatarFn = (
156
- value: any,
157
- key: string,
158
- ooui: any,
159
- context: any
160
- ): React.ReactElement => <Avatar ooui={ooui} value={value} />;
157
+ const AvatarFn = (value: any, key:string, ooui: any, context: any): React.ReactElement => (
158
+ <Avatar ooui={ooui} value={value} />
159
+ )
161
160
 
162
161
  function Tree(props: Props): React.ReactElement {
163
162
  const {
@@ -309,7 +308,9 @@ function Tree(props: Props): React.ReactElement {
309
308
  summary.push(`${sumField.label}: ${Math.round(total * 100) / 100}`);
310
309
  });
311
310
 
312
- return <div className="p-1 pb-0 pl-2 mt-2 ">{summary.join(", ")}</div>;
311
+ return (
312
+ <div className="p-1 pb-0 pl-2 mt-2 ">{summary.join(", ")}</div>
313
+ );
313
314
  }
314
315
 
315
316
  let dataTable;
@@ -332,12 +333,11 @@ function Tree(props: Props): React.ReactElement {
332
333
  ) : (
333
334
  <div>
334
335
  {pagination()}
335
- {loading && <Spin className="pb-4" />}
336
336
  <GisceTable
337
337
  height={adjustedHeight!}
338
338
  columns={dataTable.columns}
339
339
  dataSource={items}
340
- loading={false}
340
+ loading={loading}
341
341
  loadingComponent={<Spin />}
342
342
  onRowStyle={(record: any) => {
343
343
  if (colorsForResults![record.id]) {