@devtron-labs/devtron-fe-common-lib 0.0.41-beta-3 → 0.0.41-beta-5

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,3 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { FieldRowProps } from './types';
3
- export declare const FieldRowWithLabel: ({ showLabel, label, required, children, id, shouldAlignCenter, }: FieldRowProps) => JSX.Element;
3
+ import { DO_NOT_SHOW_LABEL } from '../constants';
4
+ export declare const FieldRowWithLabel: ({ showLabel, label, required, children, id, shouldAlignCenter, }: Omit<FieldRowProps, "label"> & {
5
+ label: FieldRowProps['label'] | typeof DO_NOT_SHOW_LABEL;
6
+ }) => JSX.Element;
@@ -3,3 +3,5 @@ export declare const PLACEHOLDERS: {
3
3
  INPUT: string;
4
4
  OBJECT_KEY: string;
5
5
  };
6
+ export declare const DEFAULT_FIELD_TITLE = "Key not available";
7
+ export declare const DO_NOT_SHOW_LABEL: unique symbol;
package/dist/index.js CHANGED
@@ -23866,11 +23866,20 @@ function AppStatus(_a) {
23866
23866
  return hideStatusMessage ? (iconClass || isVirtualEnv ? (jsxRuntime.jsx(Tippy, __assign({ className: "default-tt", arrow: false, placement: "top", content: textContent }, { children: jsxRuntime.jsx("div", __assign({ className: "flex" }, { children: renderIcon() })) }))) : (renderIcon())) : (jsxRuntime.jsxs("div", __assign({ className: "flex left" }, { children: [jsxRuntime.jsx("div", __assign({ className: "flex mr-6" }, { children: renderIcon() })), jsxRuntime.jsx("p", __assign({ "data-testid": "".concat(status, "-app-status"), className: "dc__truncate-text dc__first-letter-capitalize cn-6 m-0" }, { children: textContent }))] })));
23867
23867
  }
23868
23868
 
23869
+ var PLACEHOLDERS = {
23870
+ SELECT: 'Please select an option',
23871
+ INPUT: 'Please enter an input',
23872
+ OBJECT_KEY: 'Please enter a value for the key',
23873
+ };
23874
+ var DEFAULT_FIELD_TITLE = 'Key not available';
23875
+ // Using symbol to ensure uniqueness across the fields
23876
+ var DO_NOT_SHOW_LABEL = Symbol('Do not show label');
23877
+
23869
23878
  var FieldRowWithLabel = function (_a) {
23870
23879
  var showLabel = _a.showLabel, label = _a.label, required = _a.required, children = _a.children, id = _a.id, _b = _a.shouldAlignCenter, shouldAlignCenter = _b === void 0 ? true : _b;
23871
23880
  return (jsxRuntime.jsxs("div", __assign({ className: showLabel
23872
23881
  ? "display-grid dc__gap-12 rjsf-form-template__field ".concat(shouldAlignCenter ? 'flex-align-center' : '')
23873
- : '' }, { children: [showLabel && (jsxRuntime.jsx("label", __assign({ className: "cn-7 fs-13 lh-32 fw-4 flexbox mb-0", htmlFor: id }, { children: !!label && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", __assign({ className: "dc__ellipsis-right" }, { children: label })), required && jsxRuntime.jsx("span", __assign({ className: "cr-5" }, { children: "\u00A0*" }))] })) }))), children] })));
23882
+ : '' }, { children: [showLabel && (jsxRuntime.jsx("label", __assign({ className: "cn-7 fs-13 lh-32 fw-4 flexbox mb-0", htmlFor: id }, { children: label !== DO_NOT_SHOW_LABEL && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", __assign({ className: "dc__ellipsis-right" }, { children: label || DEFAULT_FIELD_TITLE })), required && jsxRuntime.jsx("span", __assign({ className: "cr-5" }, { children: "\u00A0*" }))] })) }))), children] })));
23874
23883
  };
23875
23884
 
23876
23885
  var ActionButton = function (_a) {
@@ -23886,7 +23895,7 @@ var ArrayFieldTemplate = function (_a) {
23886
23895
  return (jsxRuntime.jsx("fieldset", __assign({ className: className, id: idSchema.$id }, { children: items.length ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [items.map(function (_a, index) {
23887
23896
  var key = _a.key, itemProps = __rest(_a, ["key"]);
23888
23897
  // Show the title as the label for the first field
23889
- var children = __assign(__assign({}, itemProps.children), { props: __assign(__assign({}, itemProps.children.props), { name: index === 0 ? label : '' }) });
23898
+ var children = __assign(__assign({}, itemProps.children), { props: __assign(__assign({}, itemProps.children.props), { name: index === 0 ? label : DO_NOT_SHOW_LABEL }) });
23890
23899
  return (jsxRuntime.jsx(ArrayFieldItemTemplate, __assign({}, itemProps, { children: children }), key));
23891
23900
  }), jsxRuntime.jsx(ActionButton, { canAdd: canAdd, onAddClick: onAddClick, disabled: disabled, readonly: readonly, uiSchema: uiSchema, registry: registry })] })) : (jsxRuntime.jsx(FieldRowWithLabel, __assign({ label: label, required: required, showLabel: true, id: idSchema.$id }, { children: jsxRuntime.jsx(ActionButton, { canAdd: canAdd, onAddClick: onAddClick, disabled: disabled, readonly: readonly, uiSchema: uiSchema, registry: registry }) }))) })));
23892
23901
  };
@@ -23897,12 +23906,6 @@ var ArrayFieldItemTemplate = function (_a) {
23897
23906
  return (jsxRuntime.jsxs("div", __assign({ className: "display-grid rjsf-form-template__array-field-item flex-align-center dc__gap-8 mb-12" }, { children: [children, hasToolbar && hasRemove && (jsxRuntime.jsx(RemoveButton, { disabled: disabled || readonly, onClick: onDropIndexClick(index), uiSchema: uiSchema, registry: registry }))] })));
23898
23907
  };
23899
23908
 
23900
- var PLACEHOLDERS = {
23901
- SELECT: 'Please select an option',
23902
- INPUT: 'Please enter an input',
23903
- OBJECT_KEY: 'Please enter a value for the key',
23904
- };
23905
-
23906
23909
  var BaseInputTemplate = RJSF.getDefaultRegistry().templates.BaseInputTemplate;
23907
23910
  var BaseInput = function (_a) {
23908
23911
  var placeholder = _a.placeholder, props = __rest(_a, ["placeholder"]);
@@ -23973,7 +23976,9 @@ var ObjectFieldTemplate = function (props) {
23973
23976
  var TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, options);
23974
23977
  var hasAdditionalProperties = !!schema.additionalProperties;
23975
23978
  var showTitle = title && !hasAdditionalProperties;
23976
- return (jsxRuntime.jsxs("fieldset", __assign({ id: idSchema.$id }, { children: [showTitle && (jsxRuntime.jsx(TitleFieldTemplate, { id: utils.titleId(idSchema), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry })), jsxRuntime.jsx("div", __assign({ className: schema.properties && idSchema.$id !== 'root' ? 'dc__border-left pl-5' : '' }, { children: jsxRuntime.jsx(Field, __assign({}, props)) }))] })));
23979
+ return (jsxRuntime.jsxs("fieldset", __assign({ id: idSchema.$id }, { children: [showTitle && (jsxRuntime.jsx(TitleFieldTemplate, { id: utils.titleId(idSchema), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry })), jsxRuntime.jsx("div", __assign({ className: schema.properties && !hasAdditionalProperties && idSchema.$id !== 'root'
23980
+ ? 'dc__border-left pl-5'
23981
+ : '' }, { children: jsxRuntime.jsx(Field, __assign({}, props)) }))] })));
23977
23982
  };
23978
23983
 
23979
23984
  var TitleField = function (_a) {
@@ -26556,7 +26561,7 @@ var templates = {
26556
26561
  WrapIfAdditionalTemplate: WrapIfAdditionalTemplate,
26557
26562
  };
26558
26563
 
26559
- var css_248z = ".rjsf-form-template__field {\n grid-template-columns: 250px 1fr;\n}\n.rjsf-form-template__additional-fields {\n grid-template-columns: 1fr 1fr minmax(20px, auto);\n}\n.rjsf-form-template__array-field-item {\n grid-template-columns: 1fr auto;\n}\n.rjsf-form-template__array-field-item :first-child {\n margin: 0;\n}";
26564
+ var css_248z = ".rjsf-form-template__field {\n grid-template-columns: 250px 1fr;\n}\n.rjsf-form-template__additional-fields {\n grid-template-columns: 1fr 1fr minmax(20px, auto);\n}\n.rjsf-form-template__array-field-item {\n grid-template-columns: 1fr auto;\n}\n.rjsf-form-template__array-field-item > :first-child {\n margin: 0;\n}";
26560
26565
  styleInject(css_248z);
26561
26566
 
26562
26567
  // Need to use this way because the default import was not working as expected
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.41-beta-3",
3
+ "version": "0.0.41-beta-5",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
2
  import { FieldRowProps } from './types'
3
+ import { DEFAULT_FIELD_TITLE, DO_NOT_SHOW_LABEL } from '../constants'
3
4
 
4
5
  export const FieldRowWithLabel = ({
5
6
  showLabel,
@@ -8,7 +9,9 @@ export const FieldRowWithLabel = ({
8
9
  children,
9
10
  id,
10
11
  shouldAlignCenter = true,
11
- }: FieldRowProps) => (
12
+ }: Omit<FieldRowProps, 'label'> & {
13
+ label: FieldRowProps['label'] | typeof DO_NOT_SHOW_LABEL
14
+ }) => (
12
15
  <div
13
16
  className={
14
17
  showLabel
@@ -19,9 +22,9 @@ export const FieldRowWithLabel = ({
19
22
  {showLabel && (
20
23
  <label className="cn-7 fs-13 lh-32 fw-4 flexbox mb-0" htmlFor={id}>
21
24
  {/* The check is added here intentionally for proper layout for array type field */}
22
- {!!label && (
25
+ {label !== DO_NOT_SHOW_LABEL && (
23
26
  <>
24
- <span className="dc__ellipsis-right">{label}</span>
27
+ <span className="dc__ellipsis-right">{label || DEFAULT_FIELD_TITLE}</span>
25
28
  {required && <span className="cr-5">&nbsp;*</span>}
26
29
  </>
27
30
  )}
@@ -3,3 +3,8 @@ export const PLACEHOLDERS = {
3
3
  INPUT: 'Please enter an input',
4
4
  OBJECT_KEY: 'Please enter a value for the key',
5
5
  }
6
+
7
+ export const DEFAULT_FIELD_TITLE = 'Key not available'
8
+
9
+ // Using symbol to ensure uniqueness across the fields
10
+ export const DO_NOT_SHOW_LABEL = Symbol('Do not show label')
@@ -10,7 +10,8 @@
10
10
  &__array-field-item {
11
11
  grid-template-columns: 1fr auto;
12
12
 
13
- & :first-child {
13
+ & > :first-child {
14
+ // This is added as the array field itself has a margin bottom
14
15
  margin: 0;
15
16
  }
16
17
  }
@@ -1,6 +1,7 @@
1
1
  import React from 'react'
2
2
  import { getTemplate, getUiOptions, ArrayFieldTemplateProps, ArrayFieldTemplateItemType } from '@rjsf/utils'
3
3
  import { FieldRowWithLabel } from '../common/FieldRow'
4
+ import { DO_NOT_SHOW_LABEL } from '../constants'
4
5
 
5
6
  const ActionButton = ({ canAdd, onAddClick, disabled, readonly, uiSchema, registry }) => {
6
7
  const {
@@ -42,7 +43,7 @@ export const ArrayFieldTemplate = ({
42
43
  ...itemProps.children,
43
44
  props: {
44
45
  ...itemProps.children.props,
45
- name: index === 0 ? label : '',
46
+ name: index === 0 ? label : DO_NOT_SHOW_LABEL,
46
47
  },
47
48
  }
48
49
  return (
@@ -91,7 +91,13 @@ export const ObjectFieldTemplate = (props: ObjectFieldTemplateProps) => {
91
91
  />
92
92
  )}
93
93
  {/* Not adding the border and padding for non-objects and root schema */}
94
- <div className={schema.properties && idSchema.$id !== 'root' ? 'dc__border-left pl-5' : ''}>
94
+ <div
95
+ className={
96
+ schema.properties && !hasAdditionalProperties && idSchema.$id !== 'root'
97
+ ? 'dc__border-left pl-5'
98
+ : ''
99
+ }
100
+ >
95
101
  <Field {...props} />
96
102
  </div>
97
103
  </fieldset>