@k-int/stripes-kint-components 2.1.2 → 2.3.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.
Files changed (207) hide show
  1. package/CHANGELOG.md +26 -4
  2. package/es/index.js +150 -4
  3. package/es/lib/ActionList/ActionList.js +10 -2
  4. package/es/lib/ActionList/ActionListFieldArray.js +53 -11
  5. package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +3 -2
  6. package/es/lib/CustomProperties/Config/CustomPropertyForm.js +88 -44
  7. package/es/lib/CustomProperties/Config/{CustomPropertiesView.js → CustomPropertyView.js} +27 -14
  8. package/es/lib/CustomProperties/Config/index.js +6 -4
  9. package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.js +72 -0
  10. package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +133 -0
  11. package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +279 -0
  12. package/es/lib/CustomProperties/Edit/CustomPropertyField.js +370 -0
  13. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +156 -0
  14. package/es/lib/CustomProperties/Edit/index.js +51 -0
  15. package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +216 -0
  16. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +236 -0
  17. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +159 -0
  18. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +119 -0
  19. package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +173 -0
  20. package/es/lib/CustomProperties/Filter/index.js +59 -0
  21. package/es/lib/CustomProperties/Filter/useOperators.js +138 -0
  22. package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +97 -0
  23. package/es/lib/CustomProperties/Filter/useValueProps.js +101 -0
  24. package/es/lib/CustomProperties/View/CustomPropertiesView.js +73 -0
  25. package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +187 -0
  26. package/es/lib/CustomProperties/View/CustomPropertyCard.js +204 -0
  27. package/es/lib/CustomProperties/View/index.js +35 -0
  28. package/es/lib/CustomProperties/index.js +125 -0
  29. package/es/lib/EditableRefdataList/EditableRefdataList.js +12 -16
  30. package/es/lib/FormModal/FormModal.js +20 -11
  31. package/es/lib/QueryTypedown/QueryTypedown.js +9 -4
  32. package/es/lib/constants/customProperties.js +4 -1
  33. package/es/lib/hooks/index.js +16 -0
  34. package/es/lib/hooks/typedownHooks/useTypedownData.js +9 -2
  35. package/es/lib/hooks/useAvailableCustomProperties.js +106 -0
  36. package/es/lib/hooks/useInvalidateRefdata.js +53 -0
  37. package/es/lib/hooks/useMutateRefdataValue.js +11 -6
  38. package/es/lib/hooks/useRefdata.js +1 -3
  39. package/es/lib/utils/groupCustomPropertiesByCtx.js +69 -0
  40. package/es/lib/utils/index.js +24 -0
  41. package/es/lib/utils/refdataQueryKey.js +48 -0
  42. package/es/lib/utils/typedownQueryKey.js +48 -0
  43. package/es/lib/utils/validators.js +160 -0
  44. package/git_translate.sh +8 -0
  45. package/junit.xml +38 -38
  46. package/package.json +1 -1
  47. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +11 -2
  48. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +25 -13
  49. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +3 -3
  50. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.js.html +1 -1
  51. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesLookup.js.html +1 -1
  52. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesSettings.js.html +5 -2
  53. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesView.js.html +75 -9
  54. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyForm.js.html +195 -33
  55. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.html +10 -10
  56. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.js.html +1 -1
  57. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +1 -1
  58. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +1 -1
  59. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +1 -1
  60. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +1 -1
  61. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +1 -1
  62. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +1 -1
  63. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +1 -1
  64. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +1 -1
  65. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +1 -1
  66. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +1 -1
  67. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +1 -1
  68. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +1 -1
  69. package/src/artifacts/coverage-jest/lcov-report/FormModal/FormModal.js.html +7 -22
  70. package/src/artifacts/coverage-jest/lcov-report/FormModal/index.html +7 -7
  71. package/src/artifacts/coverage-jest/lcov-report/FormModal/index.js.html +1 -1
  72. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +1 -1
  73. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.html +1 -1
  74. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.js.html +1 -1
  75. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/QueryTypedown.js.html +1 -1
  76. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +1 -1
  77. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +1 -1
  78. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +1 -1
  79. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +1 -1
  80. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +1 -1
  81. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/SASQLookupComponent.js.html +1 -1
  82. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +1 -1
  83. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +1 -1
  84. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +1 -1
  85. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.html +1 -1
  86. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.js.html +1 -1
  87. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/SASQViewComponent.js.html +1 -1
  88. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.html +1 -1
  89. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.js.html +1 -1
  90. package/src/artifacts/coverage-jest/lcov-report/SearchField/SearchField.js.html +1 -1
  91. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.html +1 -1
  92. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.js.html +1 -1
  93. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPage.js.html +1 -1
  94. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +1 -1
  95. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +1 -1
  96. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.js.html +1 -1
  97. package/src/artifacts/coverage-jest/lcov-report/Typedown/Typedown.js.html +1 -1
  98. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +1 -1
  99. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +1 -1
  100. package/src/artifacts/coverage-jest/lcov-report/constants/customProperties.js.html +1 -1
  101. package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +1 -1
  102. package/src/artifacts/coverage-jest/lcov-report/constants/index.html +1 -1
  103. package/src/artifacts/coverage-jest/lcov-report/contexts/SettingsContext.js.html +1 -1
  104. package/src/artifacts/coverage-jest/lcov-report/contexts/index.html +1 -1
  105. package/src/artifacts/coverage-jest/lcov-report/contexts/index.js.html +1 -1
  106. package/src/artifacts/coverage-jest/lcov-report/hooks/index.html +1 -1
  107. package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +1 -1
  108. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +1 -1
  109. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.js.html +1 -1
  110. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettingSection.js.html +1 -1
  111. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.js.html +1 -1
  112. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +1 -1
  113. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.js.html +1 -1
  114. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedown.js.html +1 -1
  115. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownData.js.html +1 -1
  116. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownToggle.js.html +1 -1
  117. package/src/artifacts/coverage-jest/lcov-report/hooks/useActiveElement.js.html +1 -1
  118. package/src/artifacts/coverage-jest/lcov-report/hooks/useCustomProperties.js.html +1 -1
  119. package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +1 -1
  120. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtFieldArray.js.html +1 -1
  121. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtSASQuery.js.html +1 -1
  122. package/src/artifacts/coverage-jest/lcov-report/hooks/useLocalStorageState.js.html +1 -1
  123. package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateCustomProperties.js.html +1 -1
  124. package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +1 -1
  125. package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +1 -1
  126. package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +1 -1
  127. package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +1 -1
  128. package/src/artifacts/coverage-jest/lcov-report/index.html +27 -27
  129. package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +1 -1
  130. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +1 -1
  131. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +16 -10
  132. package/src/artifacts/coverage-jest/lcov-report/utils/index.html +24 -9
  133. package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +1 -1
  134. package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +1 -1
  135. package/src/artifacts/coverage-jest/lcov-report/utils/renderHelpText.js.html +1 -1
  136. package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +1 -1
  137. package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +1 -1
  138. package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +1 -1
  139. package/src/artifacts/coverage-jest/lcov-report/utils/validators.js.html +202 -0
  140. package/src/artifacts/coverage-jest/lcov.info +366 -296
  141. package/src/index.js +35 -3
  142. package/src/lib/ActionList/ActionList.js +8 -2
  143. package/src/lib/ActionList/ActionListFieldArray.js +44 -17
  144. package/src/lib/ActionList/README.md +24 -20
  145. package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +3 -2
  146. package/src/lib/CustomProperties/Config/CustomPropertyForm.js +77 -23
  147. package/src/lib/CustomProperties/Config/{CustomPropertiesView.js → CustomPropertyView.js} +31 -9
  148. package/src/lib/CustomProperties/Config/index.js +1 -1
  149. package/src/lib/CustomProperties/Edit/CustomPropertiesEdit.js +35 -0
  150. package/src/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +85 -0
  151. package/src/lib/CustomProperties/Edit/CustomPropertiesListField.js +194 -0
  152. package/src/lib/CustomProperties/Edit/CustomPropertyField.js +299 -0
  153. package/src/lib/CustomProperties/Edit/CustomPropertyFormCard.js +131 -0
  154. package/src/lib/CustomProperties/Edit/index.js +5 -0
  155. package/src/lib/CustomProperties/Filter/CustomPropertiesFilter.js +125 -0
  156. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +148 -0
  157. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +113 -0
  158. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +74 -0
  159. package/src/lib/CustomProperties/Filter/CustomPropertiesRule.js +122 -0
  160. package/src/lib/CustomProperties/Filter/index.js +6 -0
  161. package/src/lib/CustomProperties/Filter/useOperators.js +55 -0
  162. package/src/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +35 -0
  163. package/src/lib/CustomProperties/Filter/useValueProps.js +45 -0
  164. package/src/lib/CustomProperties/View/CustomPropertiesView.js +36 -0
  165. package/src/lib/CustomProperties/View/CustomPropertiesViewCtx.js +112 -0
  166. package/src/lib/CustomProperties/View/CustomPropertyCard.js +177 -0
  167. package/src/lib/CustomProperties/View/index.js +3 -0
  168. package/src/lib/CustomProperties/index.js +30 -0
  169. package/src/lib/EditableRefdataList/EditableRefdataList.js +13 -10
  170. package/src/lib/FormModal/FormModal.js +37 -22
  171. package/src/lib/QueryTypedown/QueryTypedown.js +3 -1
  172. package/src/lib/constants/customProperties.js +1 -0
  173. package/src/lib/hooks/index.js +2 -0
  174. package/src/lib/hooks/typedownHooks/useTypedownData.js +9 -3
  175. package/src/lib/hooks/useAvailableCustomProperties.js +40 -0
  176. package/src/lib/hooks/useInvalidateRefdata.js +11 -0
  177. package/src/lib/hooks/useMutateRefdataValue.js +7 -3
  178. package/src/lib/hooks/useRefdata.js +2 -3
  179. package/src/lib/utils/generateKiwtQueryParams.js +2 -2
  180. package/src/lib/utils/groupCustomPropertiesByCtx.js +13 -0
  181. package/src/lib/utils/index.js +5 -0
  182. package/src/lib/utils/refdataQueryKey.js +9 -0
  183. package/src/lib/utils/typedownQueryKey.js +9 -0
  184. package/src/lib/utils/validators.js +79 -0
  185. package/translate.sh +63 -0
  186. package/translations/stripes-kint-components/ar.json +105 -0
  187. package/translations/stripes-kint-components/ca.json +1 -0
  188. package/translations/stripes-kint-components/cs_CZ.json +105 -0
  189. package/translations/stripes-kint-components/da.json +1 -0
  190. package/translations/stripes-kint-components/de.json +105 -0
  191. package/translations/stripes-kint-components/en.json +59 -2
  192. package/translations/stripes-kint-components/es.json +105 -0
  193. package/translations/stripes-kint-components/fr.json +105 -0
  194. package/translations/stripes-kint-components/he.json +1 -0
  195. package/translations/stripes-kint-components/hi_IN.json +105 -0
  196. package/translations/stripes-kint-components/hu.json +105 -0
  197. package/translations/stripes-kint-components/it_IT.json +105 -0
  198. package/translations/stripes-kint-components/ja.json +105 -0
  199. package/translations/stripes-kint-components/ko.json +105 -0
  200. package/translations/stripes-kint-components/nb.json +1 -0
  201. package/translations/stripes-kint-components/nn.json +1 -0
  202. package/translations/stripes-kint-components/pl.json +105 -0
  203. package/translations/stripes-kint-components/pt_PT.json +105 -0
  204. package/translations/stripes-kint-components/ru.json +105 -0
  205. package/translations/stripes-kint-components/sv.json +105 -0
  206. package/translations/stripes-kint-components/ur.json +1 -0
  207. package/translations/stripes-kint-components/zh_CN.json +105 -0
package/src/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  // Useful hooks
2
2
  export {
3
3
  useActiveElement,
4
+ useAvailableCustomProperties,
4
5
  useCustomProperties,
5
6
  useHelperApp,
7
+ useInvalidateRefdata,
6
8
  useKiwtFieldArray,
7
9
  useKiwtSASQuery,
8
10
  useLocalStorageState,
@@ -18,10 +20,21 @@ export {
18
20
  export {
19
21
  generateKiwtQuery,
20
22
  generateKiwtQueryParams,
23
+ groupCustomPropertiesByCtx,
21
24
  refdataOptions,
22
- selectorSafe
25
+ refdataQueryKey,
26
+ selectorSafe,
27
+ typedownQueryKey,
23
28
  } from './lib/utils';
24
29
 
30
+ // Validators (Some/all copied from stripes-erm-components but this gives another way to acquire them)
31
+ export {
32
+ composeValidators,
33
+ invalidNumber,
34
+ required,
35
+ requiredObject,
36
+ } from './lib/utils/validators';
37
+
25
38
  // Contexts
26
39
  export {
27
40
  SettingsContext,
@@ -77,9 +90,28 @@ export { default as FormModal } from './lib/FormModal';
77
90
 
78
91
  // Custom properties
79
92
  export {
93
+ // Config
80
94
  CustomPropertiesLookup,
81
95
  CustomPropertiesSettings,
82
- CustomPropertiesView
83
- } from './lib/CustomProperties/Config';
96
+ CustomPropertyView,
97
+ CustomPropertyForm,
98
+ // Edit
99
+ CustomPropertiesEdit,
100
+ CustomPropertiesEditCtx,
101
+ CustomPropertiesListField,
102
+ CustomPropertyFormCard,
103
+ CustomPropertyField,
104
+ // View
105
+ CustomPropertiesView,
106
+ CustomPropertiesViewCtx,
107
+ CustomPropertyCard,
108
+ // Filter
109
+ CustomPropertiesFilter,
110
+ CustomPropertiesFilterForm,
111
+ CustomPropertiesFilterField,
112
+ CustomPropertiesFilterFieldArray,
113
+ useOperators,
114
+ useParseActiveFilterStrings
115
+ } from './lib/CustomProperties';
84
116
 
85
117
  export * as customPropertyContants from './lib/constants/customProperties';
@@ -13,19 +13,23 @@ const propTypes = {
13
13
  columnMapping: PropTypes.object,
14
14
  contentData: PropTypes.arrayOf(PropTypes.object),
15
15
  creatableFields: PropTypes.object,
16
+ createCallback: PropTypes.func,
16
17
  editableFields: PropTypes.object,
17
18
  fieldComponents: PropTypes.object,
19
+ hideCreateButton: PropTypes.bool,
18
20
  visibleFields: PropTypes.arrayOf(PropTypes.string)
19
21
  };
20
22
 
21
23
  const ActionList = ({
22
24
  actionAssigner,
23
- actionCalls = {},
25
+ actionCalls = {}, // DEPRECATED
24
26
  columnMapping,
25
27
  contentData,
26
28
  creatableFields = {},
29
+ createCallback,
27
30
  editableFields = {},
28
31
  fieldComponents = {},
32
+ hideCreateButton,
29
33
  visibleFields,
30
34
  ...mclProps // Assume anything left over is to directly apply to the MCL
31
35
  }) => {
@@ -35,7 +39,7 @@ const ActionList = ({
35
39
  enableReinitialize
36
40
  initialValues={{ contentData }}
37
41
  mutators={arrayMutators}
38
- onSubmit={actionCalls.edit}
42
+ onSubmit={() => null}
39
43
  subscription={{ contentData: true }}
40
44
  >
41
45
  {() => (
@@ -46,8 +50,10 @@ const ActionList = ({
46
50
  columnMapping={columnMapping}
47
51
  component={ActionListFieldArray}
48
52
  creatableFields={creatableFields}
53
+ createCallback={createCallback}
49
54
  editableFields={editableFields}
50
55
  fieldComponents={fieldComponents}
56
+ hideCreateButton={hideCreateButton}
51
57
  name="contentData"
52
58
  visibleFields={visibleFields}
53
59
  {...mclProps}
@@ -16,21 +16,25 @@ const propTypes = {
16
16
  actionCalls: PropTypes.object,
17
17
  columnMapping: PropTypes.object,
18
18
  creatableFields: PropTypes.object,
19
+ createCallback: PropTypes.func,
19
20
  editableFields: PropTypes.object,
20
21
  fields: PropTypes.object,
21
22
  fieldComponents: PropTypes.object,
22
23
  formatter: PropTypes.object,
24
+ hideCreateButton: PropTypes.bool,
23
25
  visibleFields: PropTypes.arrayOf(PropTypes.string)
24
26
  };
25
27
 
26
28
  const ActionListFieldArray = ({
27
29
  actionAssigner,
28
- actionCalls,
30
+ actionCalls, // DEPRECATED
29
31
  columnMapping,
30
32
  creatableFields,
33
+ createCallback,
31
34
  editableFields,
32
35
  fields,
33
36
  fieldComponents,
37
+ hideCreateButton = false,
34
38
  visibleFields,
35
39
  ...mclProps // Assume anything left over is to directly apply to the MCL
36
40
  }) => {
@@ -53,15 +57,26 @@ const ActionListFieldArray = ({
53
57
  }
54
58
  };
55
59
 
56
-
57
60
  const handleSave = (index) => {
58
61
  const { actionListActions: _a, ...rowData } = fields.value[index];
59
- actionCalls.edit(rowData);
62
+
63
+ // Find "edit" entry in actionAssigner
64
+ const editCallback = actionAssigner.find(act => act.name === 'edit')?.callback;
65
+ if (editCallback) {
66
+ editCallback(rowData);
67
+ } else {
68
+ actionCalls.edit(rowData); // DEPRECATED
69
+ }
60
70
  };
61
71
 
62
72
  const handleCreate = (index) => {
63
73
  const { actionListActions: _a, ...rowData } = fields.value[index];
64
- actionCalls.create(rowData);
74
+
75
+ if (createCallback) {
76
+ createCallback(rowData);
77
+ } else {
78
+ actionCalls.create(rowData); // DEPRECATED
79
+ }
65
80
  };
66
81
 
67
82
  const getColumnWidths = () => {
@@ -131,7 +146,15 @@ const ActionListFieldArray = ({
131
146
  return (
132
147
  <div>
133
148
  {actions?.map(action => {
134
- let actionFunction = () => actionCalls[action.name](rest);
149
+ let actionFunction;
150
+ if (action.callback) {
151
+ actionFunction = () => action.callback(rest);
152
+ }
153
+
154
+ if (!actionFunction && actionCalls[action.name]) {
155
+ actionFunction = () => actionCalls[action.name](rest); // DEPRECATED
156
+ }
157
+
135
158
  // Edit has special action functionality, revealing fields etc.
136
159
  if (action.name === 'edit') {
137
160
  actionFunction = () => toggleEditing(data.id);
@@ -145,7 +168,8 @@ const ActionListFieldArray = ({
145
168
  disabled={editing}
146
169
  icon={action.icon}
147
170
  marginBottom0
148
- onClick={actionFunction}
171
+ onClick={() => (actionFunction ? actionFunction() : () => null)}
172
+ to={action.to}
149
173
  />
150
174
  );
151
175
  }
@@ -156,7 +180,8 @@ const ActionListFieldArray = ({
156
180
  key={`action-${action.name}[${data.rowIndex}]`}
157
181
  disabled={editing}
158
182
  marginBottom0
159
- onClick={actionFunction}
183
+ onClick={() => (actionFunction ? actionFunction() : () => null)}
184
+ to={action.to}
160
185
  >
161
186
  {action.label ?? action.name}
162
187
  </Button>
@@ -242,16 +267,18 @@ const ActionListFieldArray = ({
242
267
 
243
268
  return (
244
269
  <>
245
- <Button
246
- buttonClass={css.buttonRight}
247
- disabled={!actionCalls.create}
248
- onClick={() => {
249
- toggleEditing('NEW_ROW');
250
- fields.push({});
251
- }}
252
- >
253
- <FormattedMessage id="stripes-kint-components.actionList.create" />
254
- </Button>
270
+ {!hideCreateButton &&
271
+ <Button
272
+ buttonClass={css.buttonRight}
273
+ disabled={(!actionCalls.create && !createCallback)} // DEPRECATED actionCalls
274
+ onClick={() => {
275
+ toggleEditing('NEW_ROW');
276
+ fields.push({});
277
+ }}
278
+ >
279
+ <FormattedMessage id="stripes-kint-components.actionList.create" />
280
+ </Button>
281
+ }
255
282
  <MultiColumnList
256
283
  columnMapping={{
257
284
  ...columnMapping,
@@ -23,32 +23,34 @@ const [contentData, setContentData] = useState({
23
23
 
24
24
  const actionAssigner = () => {
25
25
  return [
26
- { name: 'edit' },
27
- { name: 'delete' }
26
+ {
27
+ name: 'edit',
28
+ callback: (data) => setContentData({
29
+ ...contentData,
30
+ data
31
+ )}
32
+ },
33
+ {
34
+ name: 'delete',
35
+ callback: (data) => {
36
+ setContentData(contentData.filter(cd => cd.id !== data.id))
37
+ }
38
+ }
28
39
  ];
29
40
  };
30
41
 
31
- const actionCalls = {
32
- create: (data) => setContentData({
33
- ...contentData,
34
- {
35
- id: generateUUID(),
36
- ...data
37
- }
38
- }),
39
- edit: (data) => setContentData({
40
- ...contentData,
41
- data
42
- ),
43
- delete: (data) => {
44
- setContentData(contentData.filter(cd => cd.id !== data.id))
42
+ createCallback = (data) => setContentData({
43
+ ...contentData,
44
+ {
45
+ id: generateUUID(),
46
+ ...data
45
47
  }
46
- };
48
+ });
47
49
 
48
50
  <ActionList
49
51
  actionAssigner={actionAssigner}
50
- actionCalls={actionCalls}
51
52
  contentData={contentData}
53
+ createCallback={createCallback}
52
54
  visibleFields={['name', 'occupation']}
53
55
  />
54
56
  ```
@@ -57,13 +59,15 @@ const actionCalls = {
57
59
 
58
60
  Name | Type | Description | default | required
59
61
  --- | --- | --- | --- | ---
60
- actionAssigner | function | A function which will be passed the entire row object, and can use that to assign an array of actions valid for that row, in the form `{ name: 'actionName', label: "Action Label", icon: 'someIcon' }`. The prop `name` is required, but `label` and `icon` are optional props. | | ✓ |
61
- actionCalls | object<function> | An object with keys matching any "actions" the `actionAssigner` may have assigned (In addition to special case `create`, if relevant), and values which are functions. These functions will be handed the row as a parameter. | {} | ✕ |
62
+ actionAssigner | function | A function which will be passed the entire row object, and can use that to assign an array of actions valid for that row, in the form `{ name: 'actionName', label: "Action Label", icon: 'someIcon', callback: () => null, to: toObject }`. The prop `name` is required, but `label` and `icon` are optional props. The `callback` prop will be prioritised ahead of the deprecated actionCalls prop. If a `to` prop is passed, then the resulting button will be rendered as a <Link/> element, as per Stripes Button/IconButton.| | ✓ |
63
+ actionCalls (DEPRECATED) | object<function> | An object with keys matching any "actions" the `actionAssigner` may have assigned (In addition to special case `create`, if relevant), and values which are functions. These functions will be handed the row as a parameter. THESE CAN NOW BE PASSED AS "callback" in the actionAssigner. | {} | ✕ |
62
64
  columnMapping | object | An object which will act on the rendered MultiColumnList headers to map the labels for each `visibleField` | | ✕ |
63
65
  contentData | array | An array of objects to render along with their actions | | ✓ |
64
66
  creatableFields | object<function> | An object with keys from the `visibleFields` array, and values of functions which take the entire row object and return a boolean indicating whether that field is fillable on create or not. | | ✕ |
67
+ createCallback | <function> | A callback to be used for the built in "create" action (ie "save" on a new row). Will be prioritised ahead of a `create` entry in the deprecated actionCalls prop. | {} | ✕ |
65
68
  editableFields | object<function> | An object with keys from the `visibleFields` array, and values of functions which take the entire row object and return a boolean indicating whether that field is editable or not. No key for a given field will be interpreted as () => true, so a field is editable by default. | | ✕ |
66
69
  fieldComponents | object<function> | An object with keys from the `visibleFields` array, and values of functions which take some `fieldProps` (currently only the name of the field `name`), and returns a Field component to be used in "edit mode" for the visible field specified. | | ✕ |
67
70
  formatter | object<function> | A "formatter" object that takes the same shape as an MCL formatter, and is used in the same way whilst a row is NOT being edited. While editing a given row, this formatter entry is ignored. | | ✕ |
71
+ hideCreateButton | boolean | A simple bool to hide the create button. Default behaviour without create action is disabled. | false | ✕ |
68
72
  visibleFields | array<String> | An array of strings corresponding to those fields to be displayed in the rendered MultiColumnList | | ✓ |
69
73
  ...mclProps | any | Any other props supplied to ActionList will be applied to the MCL directly. *WARNING* Some MCL props may override important functionality within ActionList | | ✕ |
@@ -14,7 +14,7 @@ import { Button, ConfirmationModal, Pane } from '@folio/stripes/components';
14
14
  import FormModal from '../../FormModal/FormModal';
15
15
 
16
16
  import CustomPropertiesLookup from './CustomPropertiesLookup';
17
- import CustomPropertiesView from './CustomPropertiesView';
17
+ import CustomPropertyView from './CustomPropertyView';
18
18
  import CustomPropertiesForm from './CustomPropertyForm';
19
19
  import { useMutateCustomProperties, useRefdata } from '../../hooks';
20
20
 
@@ -160,7 +160,7 @@ const CustomPropertiesSettings = ({
160
160
  renderViewPaneTitle ?? customProperty?.label ?? customProperty?.name
161
161
  }
162
162
  >
163
- <CustomPropertiesView
163
+ <CustomPropertyView
164
164
  customProperty={customProperty}
165
165
  labelOverrides={labelOverrides}
166
166
  />
@@ -171,6 +171,7 @@ const CustomPropertiesSettings = ({
171
171
  {
172
172
  weight: 0,
173
173
  primary: true,
174
+ retired: false,
174
175
  defaultInternal: true
175
176
  } :
176
177
  {
@@ -12,7 +12,7 @@ import {
12
12
  TextArea,
13
13
  TextField
14
14
  } from '@folio/stripes/components';
15
- import { requiredValidator } from '@folio/stripes-erm-components';
15
+ import { required as requiredValidator, composeValidators } from '../../utils/validators';
16
16
 
17
17
  const CustomPropertyForm = ({
18
18
  contextFilterOptions,
@@ -43,6 +43,14 @@ const CustomPropertyForm = ({
43
43
  }
44
44
  };
45
45
 
46
+ const primaryRetiredValidator = (_v, allValues) => {
47
+ if (allValues.primary && allValues.retired) {
48
+ return labelOverrides?.primaryRetired ??
49
+ <FormattedMessage id="stripes-kint-components.errors.primaryRetired" />;
50
+ }
51
+ return null;
52
+ };
53
+
46
54
  return (
47
55
  <>
48
56
  <Row>
@@ -90,7 +98,7 @@ const CustomPropertyForm = ({
90
98
  </Col>
91
99
  </Row>
92
100
  <Row>
93
- <Col xs={12}>
101
+ <Col xs={9}>
94
102
  <Field
95
103
  component={TextArea}
96
104
  label={labelOverrides?.description ??
@@ -106,6 +114,26 @@ const CustomPropertyForm = ({
106
114
  validate={requiredValidator}
107
115
  />
108
116
  </Col>
117
+ <Col xs={3}>
118
+ <Field
119
+ actions={[{ onSelect: addCtx, render: renderAddCtx }]}
120
+ component={MultiSelection}
121
+ dataOptions={contextOptions}
122
+ emptyMessage={intl.formatMessage({ id: 'stripes-kint-components.customProperties.noCtxFound' })}
123
+ label={labelOverrides?.ctx ??
124
+ <FormattedMessage id="stripes-kint-components.customProperties.ctx" />
125
+ }
126
+ name="ctx"
127
+ onChange={(selectedItems) => {
128
+ if (selectedItems.length) {
129
+ change('ctx', [selectedItems?.[selectedItems?.length - 1]]);
130
+ } else {
131
+ change('ctx', undefined);
132
+ }
133
+ }}
134
+ validate={value => (value?.length > 1 ? <FormattedMessage id="stripes-kint-components.customProperties.ctx.error.moreThanOne" /> : null)}
135
+ />
136
+ </Col>
109
137
  </Row>
110
138
  <Row>
111
139
  <Col xs={3}>
@@ -156,7 +184,47 @@ const CustomPropertyForm = ({
156
184
  content={helpPopovers?.primary}
157
185
  /> : null
158
186
  }
159
- validate={requiredValidator}
187
+ validate={composeValidators(
188
+ requiredValidator,
189
+ primaryRetiredValidator
190
+ )}
191
+ />
192
+ </Col>
193
+ <Col xs={3}>
194
+ <Field
195
+ component={Select}
196
+ dataOptions={[
197
+ {
198
+ label: intl.formatMessage({
199
+ id: 'stripes-kint-components.yes',
200
+ }),
201
+ value: 'true',
202
+ },
203
+ {
204
+ label: intl.formatMessage({
205
+ id: 'stripes-kint-components.no',
206
+ }),
207
+ value: 'false',
208
+ },
209
+ ]}
210
+ format={booleanToString}
211
+ label={labelOverrides?.retired ??
212
+ <FormattedMessage
213
+ id="stripes-kint-components.customProperties.retired"
214
+ />
215
+ }
216
+ name="retired"
217
+ parse={stringToBoolean}
218
+ required
219
+ startControl={helpPopovers?.primary ?
220
+ <InfoPopover
221
+ content={helpPopovers?.primary}
222
+ /> : null
223
+ }
224
+ validate={composeValidators(
225
+ requiredValidator,
226
+ primaryRetiredValidator
227
+ )}
160
228
  />
161
229
  </Col>
162
230
  <Col xs={3}>
@@ -193,26 +261,6 @@ const CustomPropertyForm = ({
193
261
  validate={requiredValidator}
194
262
  />
195
263
  </Col>
196
- <Col xs={3}>
197
- <Field
198
- actions={[{ onSelect: addCtx, render: renderAddCtx }]}
199
- component={MultiSelection}
200
- dataOptions={contextOptions}
201
- emptyMessage={intl.formatMessage({ id: 'stripes-kint-components.customProperties.noCtxFound' })}
202
- label={labelOverrides?.ctx ??
203
- <FormattedMessage id="stripes-kint-components.customProperties.ctx" />
204
- }
205
- name="ctx"
206
- onChange={(selectedItems) => {
207
- if (selectedItems.length) {
208
- change('ctx', [selectedItems?.[selectedItems?.length - 1]]);
209
- } else {
210
- change('ctx', undefined);
211
- }
212
- }}
213
- validate={value => (value?.length > 1 ? <FormattedMessage id="stripes-kint-components.customProperties.ctx.error.moreThanOne" /> : null)}
214
- />
215
- </Col>
216
264
  </Row>
217
265
  {/* Users can only configure the type of a custom property when creating it, not when editing it */}
218
266
  {!values?.id && (
@@ -246,6 +294,12 @@ const CustomPropertyForm = ({
246
294
  }),
247
295
  value: 'Refdata',
248
296
  },
297
+ {
298
+ label: intl.formatMessage({
299
+ id: 'stripes-kint-components.customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyLocalDate',
300
+ }),
301
+ value: 'LocalDate',
302
+ },
249
303
  ]
250
304
  }
251
305
  label={labelOverrides?.type ??
@@ -5,7 +5,7 @@ import { Col, KeyValue, NoValue, Row } from '@folio/stripes/components';
5
5
  import { REFDATA_CLASS_NAME } from '../../constants/customProperties';
6
6
 
7
7
  // A default option for CustProp view pane, with the ability to override labels for fields
8
- const CustomPropertiesView = ({
8
+ const CustomPropertyView = ({
9
9
  customProperty,
10
10
  labelOverrides
11
11
  }) => {
@@ -46,24 +46,34 @@ const CustomPropertiesView = ({
46
46
  <Col xs={6}>
47
47
  <KeyValue
48
48
  label={
49
- labelOverrides?.weight ??
50
- <FormattedMessage id="stripes-kint-components.customProperties.weight" />
49
+ labelOverrides?.primary ??
50
+ <FormattedMessage
51
+ id="stripes-kint-components.customProperties.primary"
52
+ />
53
+ }
54
+ value={
55
+ <FormattedMessage
56
+ id={
57
+ customProperty?.primary
58
+ ? 'stripes-kint-components.yes'
59
+ : 'stripes-kint-components.no'
60
+ }
61
+ />
51
62
  }
52
- value={customProperty?.weight}
53
63
  />
54
64
  </Col>
55
65
  <Col xs={6}>
56
66
  <KeyValue
57
67
  label={
58
- labelOverrides?.primary ??
68
+ labelOverrides?.retired ??
59
69
  <FormattedMessage
60
- id="stripes-kint-components.customProperties.primary"
70
+ id="stripes-kint-components.customProperties.retired"
61
71
  />
62
72
  }
63
73
  value={
64
74
  <FormattedMessage
65
75
  id={
66
- customProperty?.primary
76
+ customProperty?.retired
67
77
  ? 'stripes-kint-components.yes'
68
78
  : 'stripes-kint-components.no'
69
79
  }
@@ -73,6 +83,15 @@ const CustomPropertiesView = ({
73
83
  </Col>
74
84
  </Row>
75
85
  <Row>
86
+ <Col xs={6}>
87
+ <KeyValue
88
+ label={
89
+ labelOverrides?.weight ??
90
+ <FormattedMessage id="stripes-kint-components.customProperties.weight" />
91
+ }
92
+ value={customProperty?.weight}
93
+ />
94
+ </Col>
76
95
  <Col xs={6}>
77
96
  <KeyValue
78
97
  label={
@@ -90,6 +109,8 @@ const CustomPropertiesView = ({
90
109
  }
91
110
  />
92
111
  </Col>
112
+ </Row>
113
+ <Row>
93
114
  <Col xs={6}>
94
115
  <KeyValue
95
116
  label={
@@ -128,7 +149,7 @@ const CustomPropertiesView = ({
128
149
  );
129
150
  };
130
151
 
131
- CustomPropertiesView.propTypes = {
152
+ CustomPropertyView.propTypes = {
132
153
  customProperty: PropTypes.shape({
133
154
  id: PropTypes.string,
134
155
  label: PropTypes.string,
@@ -136,6 +157,7 @@ CustomPropertiesView.propTypes = {
136
157
  description: PropTypes.string,
137
158
  weight: PropTypes.number,
138
159
  primary: PropTypes.bool,
160
+ retired: PropTypes.bool,
139
161
  defaultInternal: PropTypes.bool,
140
162
  ctx: PropTypes.string,
141
163
  type: PropTypes.string,
@@ -147,4 +169,4 @@ CustomPropertiesView.propTypes = {
147
169
  labelOverrides: PropTypes.object
148
170
  };
149
171
 
150
- export default CustomPropertiesView;
172
+ export default CustomPropertyView;
@@ -1,4 +1,4 @@
1
1
  export { default as CustomPropertiesLookup } from './CustomPropertiesLookup';
2
- export { default as CustomPropertiesView } from './CustomPropertiesLookup';
2
+ export { default as CustomPropertyView } from './CustomPropertyView';
3
3
  export { default as CustomPropertiesSettings } from './CustomPropertiesSettings';
4
4
  export { default as CustomPropertyForm } from './CustomPropertyForm';
@@ -0,0 +1,35 @@
1
+ import PropTypes from 'prop-types';
2
+ import CustomPropertiesEditCtx from './CustomPropertiesEditCtx';
3
+
4
+ const CustomPropertiesEdit = ({
5
+ contexts = [],
6
+ customPropertiesEndpoint,
7
+ id,
8
+ labelOverrides = {},
9
+ nameOverride
10
+ }) => {
11
+ return (
12
+ contexts.map(ctx => (
13
+ <CustomPropertiesEditCtx
14
+ key={`customPropertiesEdit-${ctx}`}
15
+ {...{
16
+ ctx,
17
+ customPropertiesEndpoint,
18
+ id,
19
+ labelOverrides,
20
+ nameOverride
21
+ }}
22
+ />
23
+ ))
24
+ );
25
+ };
26
+
27
+ CustomPropertiesEdit.propTypes = {
28
+ contexts: PropTypes.arrayOf(PropTypes.string),
29
+ customPropertiesEndpoint: PropTypes.string,
30
+ id: PropTypes.string,
31
+ labelOverrides: PropTypes.object,
32
+ nameOverride: PropTypes.string
33
+ };
34
+
35
+ export default CustomPropertiesEdit;