@evergis/react 3.1.51 → 3.1.52

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,4 +1,3 @@
1
- export declare const ElementValueWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
2
1
  export declare const ContainerWrapper: any;
3
2
  export declare const DashboardChip: import('styled-components').StyledComponent<any, any, any, any>;
4
3
  export declare const DashboardPlaceholderWrap: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps, never>;
package/dist/index.js CHANGED
@@ -4507,6 +4507,75 @@ const DashboardChip$1 = styled(uilibGl.Chip) `
4507
4507
  ${({ $fontColor, $isDefault }) => !!$fontColor && !$isDefault && CustomChipColorMixin}
4508
4508
  `;
4509
4509
 
4510
+ const getAttributeByName = (attributeName, attributes) => {
4511
+ return Array.isArray(attributeName)
4512
+ ? null
4513
+ : attributeName
4514
+ ? attributes?.find(({ name }) => name === attributeName)
4515
+ : null;
4516
+ };
4517
+
4518
+ const formatElementValue = ({ t, value, elementConfig, attributes, wrap, }) => {
4519
+ const { id, type, defaultValue, options, style, attributeName, templateName } = elementConfig || {};
4520
+ const attribute = attributeName ? getAttributeByName(attributeName, attributes) : null;
4521
+ const { fontColor, fontSize, noUnits, tagView, bgColor, withDivider, radius } = options || {};
4522
+ const valueOrDefault = value || defaultValue;
4523
+ const resultValue = type === "attributeValue" && attribute?.type && attribute?.stringFormat
4524
+ ? formatAttributeValue({
4525
+ t,
4526
+ type: attribute.type,
4527
+ value: valueOrDefault,
4528
+ stringFormat: attribute.stringFormat,
4529
+ noUnits,
4530
+ })
4531
+ : valueOrDefault;
4532
+ if (!wrap)
4533
+ return resultValue;
4534
+ return (jsxRuntime.jsxs(React.Fragment, { children: [tagView ? (jsxRuntime.jsx(DashboardChip$1, { text: resultValue, "$bgColor": bgColor, "$fontColor": fontColor, "$fontSize": fontSize, "$radius": radius, style: style })) : resultValue, withDivider && jsxRuntime.jsx(uilibGl.Divider, {})] }, id));
4535
+ };
4536
+
4537
+ const getAttributeValue = (element, attributes) => {
4538
+ const attribute = getAttributeByName(element?.attributeName, attributes);
4539
+ const { maxLength, separator, expandable, lineBreak } = element.options || {};
4540
+ let value = "";
4541
+ if (attribute?.type === api.AttributeType.Boolean && typeof attribute.value === "boolean") {
4542
+ return jsxRuntime.jsx(DashboardCheckbox, { title: attribute.alias || attribute.name, checked: attribute.value });
4543
+ }
4544
+ if (Array.isArray(element?.attributeName)) {
4545
+ const concatAttributes = element.attributeName.map((attributeName) => attributes?.find(({ name }) => name === attributeName)?.value || "");
4546
+ value = concatAttributes.join(separator || ", ");
4547
+ }
4548
+ else {
4549
+ value = attribute?.value?.toString() || "";
4550
+ }
4551
+ return maxLength && maxLength < value.length ? (jsxRuntime.jsx(TextTrim, { maxLength: maxLength, expandable: expandable, lineBreak: lineBreak, children: value })) : (value);
4552
+ };
4553
+
4554
+ const getChartAxes = (chartElement) => chartElement?.options?.relatedDataSources?.filter(({ chartAxis }) => chartAxis === "y");
4555
+
4556
+ const getChartFilterName = (relatedDataSources) => {
4557
+ const relatedAttributes = relatedDataSources || [];
4558
+ const axes = relatedAttributes.filter(({ chartAxis }) => chartAxis === "y");
4559
+ return axes?.[0]?.filterName;
4560
+ };
4561
+
4562
+ function getValueIndex(items, attributes) {
4563
+ return items?.findIndex(({ name }) => name.toString() === attributes.value?.toString());
4564
+ }
4565
+ const getChartMarkers = (items, markers, dataSources) => {
4566
+ if (typeof markers === "string") {
4567
+ const dataSource = getDataSource(markers, dataSources);
4568
+ return dataSource?.features?.map(({ attributes }) => ({
4569
+ ...attributes,
4570
+ value: getValueIndex(items, attributes),
4571
+ })) || [];
4572
+ }
4573
+ return (markers?.map(marker => ({
4574
+ ...marker,
4575
+ value: getValueIndex(items, marker),
4576
+ })) || []);
4577
+ };
4578
+
4510
4579
  const ChartLegendContainer = styled(uilibGl.Flex) `
4511
4580
  flex-direction: column;
4512
4581
  flex-wrap: wrap;
@@ -4535,156 +4604,6 @@ const ChartLegendName = styled.div `
4535
4604
  color: ${({ theme: { palette }, $fontColor }) => $fontColor || palette.textPrimary};
4536
4605
  `;
4537
4606
 
4538
- const Container = styled(uilibGl.Flex) `
4539
- flex-direction: column;
4540
- width: 100%;
4541
-
4542
- ${({ isColumn }) => isColumn
4543
- ? styled.css `
4544
- > * {
4545
- width: 100%;
4546
- }
4547
- `
4548
- : styled.css `
4549
- flex-direction: row;
4550
- justify-content: space-between;
4551
- align-items: center;
4552
- `}
4553
-
4554
- ${({ isMain, isColumn }) => (isMain || isColumn) &&
4555
- styled.css `
4556
- > :not(:last-child) {
4557
- margin-bottom: 1.5rem;
4558
- }
4559
- `}
4560
-
4561
- ${({ isTitle }) => isTitle &&
4562
- styled.css `
4563
- &&&& {
4564
- margin-bottom: 0.75rem;
4565
- }
4566
- `}
4567
-
4568
- ${({ noBorders }) => noBorders && styled.css `
4569
- ${ContainerWrapper} {
4570
- box-shadow: none;
4571
- padding: 0;
4572
- }
4573
- `}
4574
- `;
4575
- const ContainerAlias = styled(uilibGl.Flex) `
4576
- align-items: center;
4577
- flex-wrap: nowrap;
4578
- margin-bottom: ${({ hasBottomMargin }) => (hasBottomMargin ? 0.25 : 0)}rem;
4579
- font-size: 0.75rem;
4580
- color: ${({ theme: { palette } }) => palette.textSecondary};
4581
-
4582
- span[kind] {
4583
- margin-right: 0.5rem;
4584
-
4585
- :after {
4586
- color: ${({ theme: { palette } }) => palette.primary};
4587
- }
4588
- }
4589
- `;
4590
- const ContainerAliasIcon = styled.div `
4591
- margin-right: 0.5rem;
4592
- `;
4593
- const ContainerChart = styled(uilibGl.Flex) `
4594
- justify-content: flex-start;
4595
-
4596
- > * {
4597
- display: flex;
4598
- justify-content: center;
4599
- width: 100%;
4600
- }
4601
- `;
4602
- const ContainerLegend = styled(uilibGl.Flex) ``;
4603
- const ContainerUnits = styled.div `
4604
- margin-left: 0.5rem;
4605
- white-space: nowrap;
4606
- font-size: 0.75rem;
4607
- `;
4608
- const ContainerValue = styled(uilibGl.Flex) `
4609
- justify-content: flex-end;
4610
- align-items: center;
4611
- flex-wrap: nowrap;
4612
- width: 100%;
4613
- font-size: ${({ big }) => (big ? 1.5 : 1)}rem;
4614
- color: ${({ fontColor, theme: { palette } }) => fontColor || palette.textPrimary};
4615
-
4616
- > * {
4617
- width: ${({ column }) => (column ? "100%" : "auto")};
4618
- }
4619
-
4620
- ${ContainerChart}, ${ContainerLegend} {
4621
- width: ${({ column }) => (column ? "100%" : "50%")};
4622
- }
4623
-
4624
- ${ContainerLegend} {
4625
- margin-left: ${({ column }) => (column ? 0 : "1rem")};
4626
- }
4627
-
4628
- ${ChartLegendContainer} {
4629
- flex-direction: ${({ column }) => (column ? "row" : "column")};
4630
- margin-top: ${({ column }) => (column ? "1rem" : 0)};
4631
- }
4632
- `;
4633
- const ColorIconMixin = styled.css `
4634
- :after {
4635
- color: ${({ $fontColor }) => $fontColor} !important;
4636
- }
4637
- `;
4638
- const SizeIconMixin = styled.css `
4639
- :after {
4640
- font-size: ${({ $fontSize }) => $fontSize}px !important;
4641
- }
4642
- `;
4643
- const ContainerIcon = styled(uilibGl.Icon) `
4644
- width: auto;
4645
- height: auto;
4646
- margin-bottom: 0.5rem;
4647
- ${({ $fontColor }) => !!$fontColor && ColorIconMixin};
4648
- ${({ $fontSize }) => !!$fontSize && SizeIconMixin};
4649
- `;
4650
- const SvgContainerColorMixin$1 = styled.css `
4651
- path,
4652
- line,
4653
- circle {
4654
- fill: ${({ $fontColor }) => $fontColor};
4655
- }
4656
- `;
4657
- const SvgContainer$1 = styled.div `
4658
- &&& {
4659
- min-width: ${({ $width }) => ($width ? `${$width}px` : "1rem")};
4660
- max-width: ${({ $width }) => ($width ? `${$width}px` : "1rem")};
4661
-
4662
- ${({ $fontColor }) => !!$fontColor && SvgContainerColorMixin$1};
4663
-
4664
- > * {
4665
- min-width: inherit;
4666
- }
4667
- }
4668
- `;
4669
- const TwoColumnContainerWrapper = styled(uilibGl.Flex) `
4670
- width: 100%;
4671
- flex-direction: row;
4672
- flex-wrap: nowrap;
4673
- align-items: center;
4674
-
4675
- > * {
4676
- flex: 1;
4677
- }
4678
-
4679
- > ${ContainerValue} {
4680
- justify-content: flex-end;
4681
-
4682
- > * {
4683
- text-align: right;
4684
- }
4685
- }
4686
- `;
4687
-
4688
4607
  const LayerGroupContainer = styled(uilibGl.Flex) `
4689
4608
  display: flex;
4690
4609
  justify-content: center;
@@ -5213,12 +5132,8 @@ const LayerListContainer = styled(uilibGl.Flex) `
5213
5132
  box-sizing: border-box;
5214
5133
  `;
5215
5134
 
5216
- const ElementValueWrapper = styled.div `
5217
- transition: background-color ${uilibGl.transition.toggle};
5218
- `;
5219
5135
  const ContainerWrapper = styled(uilibGl.Flex) `
5220
5136
  position: relative;
5221
- min-height: 1rem;
5222
5137
  box-sizing: border-box;
5223
5138
  width: 100%;
5224
5139
  background: ${({ theme: { palette } }) => palette.backgroundAlpha};
@@ -5230,7 +5145,7 @@ const ContainerWrapper = styled(uilibGl.Flex) `
5230
5145
  z-index: ${({ $zIndex }) => $zIndex ?? 1};
5231
5146
  transition: background-color ${uilibGl.transition.toggle};
5232
5147
 
5233
- ${Container} > ${ElementValueWrapper}:not(:last-child) {
5148
+ ${Container} > :not(:last-child) {
5234
5149
  margin-bottom: 1.5rem;
5235
5150
  }
5236
5151
  `;
@@ -5483,74 +5398,155 @@ const FeatureControls = styled(uilibGl.Flex) `
5483
5398
  }
5484
5399
  `;
5485
5400
 
5486
- const getAttributeByName = (attributeName, attributes) => {
5487
- return Array.isArray(attributeName)
5488
- ? null
5489
- : attributeName
5490
- ? attributes?.find(({ name }) => name === attributeName)
5491
- : null;
5492
- };
5493
-
5494
- const formatElementValue = ({ t, value, elementConfig, attributes, wrap, }) => {
5495
- const { id, type, defaultValue, options, style, attributeName, templateName } = elementConfig || {};
5496
- const attribute = attributeName ? getAttributeByName(attributeName, attributes) : null;
5497
- const { fontColor, fontSize, noUnits, tagView, bgColor, withDivider, radius } = options || {};
5498
- const valueOrDefault = value || defaultValue;
5499
- const resultValue = type === "attributeValue" && attribute?.type && attribute?.stringFormat
5500
- ? formatAttributeValue({
5501
- t,
5502
- type: attribute.type,
5503
- value: valueOrDefault,
5504
- stringFormat: attribute.stringFormat,
5505
- noUnits,
5506
- })
5507
- : valueOrDefault;
5508
- if (!wrap)
5509
- return resultValue;
5510
- return (jsxRuntime.jsxs(React.Fragment, { children: [tagView ? (jsxRuntime.jsx(DashboardChip$1, { text: resultValue, "$bgColor": bgColor, "$fontColor": fontColor, "$fontSize": fontSize, "$radius": radius, style: style })) : (jsxRuntime.jsx(ElementValueWrapper, { "data-id": id, "data-templatename": templateName, style: style, children: resultValue })), withDivider && jsxRuntime.jsx(uilibGl.Divider, {})] }, id));
5511
- };
5512
-
5513
- const getAttributeValue = (element, attributes) => {
5514
- const attribute = getAttributeByName(element?.attributeName, attributes);
5515
- const { maxLength, separator, expandable, lineBreak } = element.options || {};
5516
- let value = "";
5517
- if (attribute?.type === api.AttributeType.Boolean && typeof attribute.value === "boolean") {
5518
- return jsxRuntime.jsx(DashboardCheckbox, { title: attribute.alias || attribute.name, checked: attribute.value });
5519
- }
5520
- if (Array.isArray(element?.attributeName)) {
5521
- const concatAttributes = element.attributeName.map((attributeName) => attributes?.find(({ name }) => name === attributeName)?.value || "");
5522
- value = concatAttributes.join(separator || ", ");
5523
- }
5524
- else {
5525
- value = attribute?.value?.toString() || "";
5526
- }
5527
- return maxLength && maxLength < value.length ? (jsxRuntime.jsx(TextTrim, { maxLength: maxLength, expandable: expandable, lineBreak: lineBreak, children: value })) : (value);
5528
- };
5529
-
5530
- const getChartAxes = (chartElement) => chartElement?.options?.relatedDataSources?.filter(({ chartAxis }) => chartAxis === "y");
5531
-
5532
- const getChartFilterName = (relatedDataSources) => {
5533
- const relatedAttributes = relatedDataSources || [];
5534
- const axes = relatedAttributes.filter(({ chartAxis }) => chartAxis === "y");
5535
- return axes?.[0]?.filterName;
5536
- };
5537
-
5538
- function getValueIndex(items, attributes) {
5539
- return items?.findIndex(({ name }) => name.toString() === attributes.value?.toString());
5540
- }
5541
- const getChartMarkers = (items, markers, dataSources) => {
5542
- if (typeof markers === "string") {
5543
- const dataSource = getDataSource(markers, dataSources);
5544
- return dataSource?.features?.map(({ attributes }) => ({
5545
- ...attributes,
5546
- value: getValueIndex(items, attributes),
5547
- })) || [];
5548
- }
5549
- return (markers?.map(marker => ({
5550
- ...marker,
5551
- value: getValueIndex(items, marker),
5552
- })) || []);
5553
- };
5401
+ const Container = styled(uilibGl.Flex) `
5402
+ flex-direction: column;
5403
+ width: 100%;
5404
+
5405
+ ${({ isColumn }) => isColumn
5406
+ ? styled.css `
5407
+ > * {
5408
+ width: 100%;
5409
+ }
5410
+ `
5411
+ : styled.css `
5412
+ flex-direction: row;
5413
+ justify-content: space-between;
5414
+ align-items: center;
5415
+ `}
5416
+
5417
+ ${({ isMain, isColumn }) => (isMain || isColumn) &&
5418
+ styled.css `
5419
+ > :not(:last-child) {
5420
+ margin-bottom: 1.5rem;
5421
+ }
5422
+ `}
5423
+
5424
+ ${({ isTitle }) => isTitle &&
5425
+ styled.css `
5426
+ &&&& {
5427
+ margin-bottom: 0.75rem;
5428
+ }
5429
+ `}
5430
+
5431
+ ${({ noBorders }) => noBorders && styled.css `
5432
+ ${ContainerWrapper} {
5433
+ box-shadow: none;
5434
+ padding: 0;
5435
+ }
5436
+ `}
5437
+ `;
5438
+ const ContainerAlias = styled(uilibGl.Flex) `
5439
+ align-items: center;
5440
+ flex-wrap: nowrap;
5441
+ margin-bottom: ${({ hasBottomMargin }) => (hasBottomMargin ? 0.25 : 0)}rem;
5442
+ font-size: 0.75rem;
5443
+ color: ${({ theme: { palette } }) => palette.textSecondary};
5444
+
5445
+ span[kind] {
5446
+ margin-right: 0.5rem;
5447
+
5448
+ :after {
5449
+ color: ${({ theme: { palette } }) => palette.primary};
5450
+ }
5451
+ }
5452
+ `;
5453
+ const ContainerAliasIcon = styled.div `
5454
+ margin-right: 0.5rem;
5455
+ `;
5456
+ const ContainerChart = styled(uilibGl.Flex) `
5457
+ justify-content: flex-start;
5458
+
5459
+ > * {
5460
+ display: flex;
5461
+ justify-content: center;
5462
+ width: 100%;
5463
+ }
5464
+ `;
5465
+ const ContainerLegend = styled(uilibGl.Flex) ``;
5466
+ const ContainerUnits = styled.div `
5467
+ margin-left: 0.5rem;
5468
+ white-space: nowrap;
5469
+ font-size: 0.75rem;
5470
+ `;
5471
+ const ContainerValue = styled(uilibGl.Flex) `
5472
+ justify-content: flex-end;
5473
+ align-items: center;
5474
+ flex-wrap: nowrap;
5475
+ width: 100%;
5476
+ font-size: ${({ big }) => (big ? 1.5 : 1)}rem;
5477
+ color: ${({ fontColor, theme: { palette } }) => fontColor || palette.textPrimary};
5478
+
5479
+ > * {
5480
+ width: ${({ column }) => (column ? "100%" : "auto")};
5481
+ }
5482
+
5483
+ ${ContainerChart}, ${ContainerLegend} {
5484
+ width: ${({ column }) => (column ? "100%" : "50%")};
5485
+ }
5486
+
5487
+ ${ContainerLegend} {
5488
+ margin-left: ${({ column }) => (column ? 0 : "1rem")};
5489
+ }
5490
+
5491
+ ${ChartLegendContainer} {
5492
+ flex-direction: ${({ column }) => (column ? "row" : "column")};
5493
+ margin-top: ${({ column }) => (column ? "1rem" : 0)};
5494
+ }
5495
+ `;
5496
+ const ColorIconMixin = styled.css `
5497
+ :after {
5498
+ color: ${({ $fontColor }) => $fontColor} !important;
5499
+ }
5500
+ `;
5501
+ const SizeIconMixin = styled.css `
5502
+ :after {
5503
+ font-size: ${({ $fontSize }) => $fontSize}px !important;
5504
+ }
5505
+ `;
5506
+ const ContainerIcon = styled(uilibGl.Icon) `
5507
+ width: auto;
5508
+ height: auto;
5509
+ margin-bottom: 0.5rem;
5510
+ ${({ $fontColor }) => !!$fontColor && ColorIconMixin};
5511
+ ${({ $fontSize }) => !!$fontSize && SizeIconMixin};
5512
+ `;
5513
+ const SvgContainerColorMixin$1 = styled.css `
5514
+ path,
5515
+ line,
5516
+ circle {
5517
+ fill: ${({ $fontColor }) => $fontColor};
5518
+ }
5519
+ `;
5520
+ const SvgContainer$1 = styled.div `
5521
+ &&& {
5522
+ min-width: ${({ $width }) => ($width ? `${$width}px` : "1rem")};
5523
+ max-width: ${({ $width }) => ($width ? `${$width}px` : "1rem")};
5524
+
5525
+ ${({ $fontColor }) => !!$fontColor && SvgContainerColorMixin$1};
5526
+
5527
+ > * {
5528
+ min-width: inherit;
5529
+ }
5530
+ }
5531
+ `;
5532
+ const TwoColumnContainerWrapper = styled(uilibGl.Flex) `
5533
+ width: 100%;
5534
+ flex-direction: row;
5535
+ flex-wrap: nowrap;
5536
+ align-items: center;
5537
+
5538
+ > * {
5539
+ flex: 1;
5540
+ }
5541
+
5542
+ > ${ContainerValue} {
5543
+ justify-content: flex-end;
5544
+
5545
+ > * {
5546
+ text-align: right;
5547
+ }
5548
+ }
5549
+ `;
5554
5550
 
5555
5551
  const ContainersGroupContainer = React.memo(({ elementConfig, type, renderElement }) => {
5556
5552
  const { expandedContainers } = useWidgetContext(type);
@@ -6767,7 +6763,7 @@ const UploadContainer = React.memo(({ type, elementConfig, renderElement }) => {
6767
6763
  const onUpload = React.useCallback(async (input) => {
6768
6764
  const files = Array.isArray(input) ? input : [input];
6769
6765
  const response = await Promise.all(files.map(file => {
6770
- return api.file.upload(file, true, parentResourceId);
6766
+ return api.file.upload(file, true, parentResourceId, file.name);
6771
6767
  }));
6772
6768
  const uploadedFiles = response.map(item => ({
6773
6769
  name: item.name,
@@ -10817,7 +10813,6 @@ exports.ElementMarkdown = ElementMarkdown;
10817
10813
  exports.ElementSlideshow = ElementSlideshow;
10818
10814
  exports.ElementSvg = ElementSvg;
10819
10815
  exports.ElementTooltip = ElementTooltip;
10820
- exports.ElementValueWrapper = ElementValueWrapper;
10821
10816
  exports.ExpandableTitle = ExpandableTitle;
10822
10817
  exports.FEATURE_CARD_DEFAULT_COLORS = FEATURE_CARD_DEFAULT_COLORS;
10823
10818
  exports.FEATURE_CARD_OTHER_COLOR = FEATURE_CARD_OTHER_COLOR;