@ramesesinc/platform-core 0.1.9 → 0.1.11

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 (76) hide show
  1. package/dist/components/action/DeleteData.d.ts +1 -0
  2. package/dist/components/action/DeleteData.js +16 -5
  3. package/dist/components/action/LookupPage.d.ts +2 -1
  4. package/dist/components/action/LookupPage.js +4 -3
  5. package/dist/components/action/Play.d.ts +6 -0
  6. package/dist/components/action/Play.js +40 -0
  7. package/dist/components/action/ProgressBar.d.ts +8 -0
  8. package/dist/components/action/ProgressBar.js +146 -0
  9. package/dist/components/action/ViewPage.d.ts +3 -1
  10. package/dist/components/action/ViewPage.js +22 -10
  11. package/dist/components/common/UIMenu.d.ts +1 -0
  12. package/dist/components/common/UIMenu.js +5 -3
  13. package/dist/components/index.d.ts +4 -1
  14. package/dist/components/index.js +4 -1
  15. package/dist/components/input/Combo.d.ts +21 -0
  16. package/dist/components/input/Combo.js +137 -0
  17. package/dist/components/input/DateField.js +7 -14
  18. package/dist/components/input/Text.d.ts +5 -0
  19. package/dist/components/input/Text.js +42 -7
  20. package/dist/components/input/YearPicker.js +3 -2
  21. package/dist/components/list/EditableMenu.d.ts +2 -0
  22. package/dist/components/list/EditableMenu.js +128 -0
  23. package/dist/components/list/TabMenu.js +2 -2
  24. package/dist/components/list/TreeMenu.js +35 -13
  25. package/dist/components/table/DataList.d.ts +1 -1
  26. package/dist/components/table/DataList.js +56 -29
  27. package/dist/components/table/DataTable.d.ts +2 -0
  28. package/dist/components/table/DataTable.js +31 -22
  29. package/dist/components/view/FilterView.js +1 -1
  30. package/dist/components/view/HtmlForm.js +12 -9
  31. package/dist/components/view/HtmlView.js +1 -1
  32. package/dist/components/view/PageView.d.ts +1 -0
  33. package/dist/components/view/PageView.js +38 -11
  34. package/dist/components/view/PopupView.d.ts +1 -0
  35. package/dist/components/view/PopupView.js +4 -4
  36. package/dist/components/view/RootView.d.ts +1 -0
  37. package/dist/components/view/RootView.js +18 -18
  38. package/dist/components/view/WizardView.d.ts +1 -1
  39. package/dist/components/view/WizardView.js +7 -25
  40. package/dist/core/AuthContext.js +1 -1
  41. package/dist/core/DynamicComponent.d.ts +2 -1
  42. package/dist/core/DynamicComponent.js +24 -2
  43. package/dist/core/Page.d.ts +1 -0
  44. package/dist/core/Page.js +6 -5
  45. package/dist/core/PageCache.d.ts +0 -2
  46. package/dist/core/PageCache.js +3 -8
  47. package/dist/core/PageContext.d.ts +1 -0
  48. package/dist/core/PageContext.js +16 -2
  49. package/dist/core/PageViewContext.d.ts +8 -2
  50. package/dist/core/PageViewContext.js +155 -86
  51. package/dist/core/Panel.js +34 -12
  52. package/dist/core/StepHandler.d.ts +1 -1
  53. package/dist/core/StepHandler.js +58 -21
  54. package/dist/index.css +98 -0
  55. package/dist/layouts/CardLayout.d.ts +2 -2
  56. package/dist/layouts/CardLayout.js +3 -4
  57. package/dist/layouts/HPanel.d.ts +2 -2
  58. package/dist/layouts/HPanel.js +1 -2
  59. package/dist/layouts/VPanel.d.ts +2 -2
  60. package/dist/layouts/VPanel.js +1 -2
  61. package/dist/layouts/index.d.ts +2 -3
  62. package/dist/layouts/index.js +2 -3
  63. package/dist/lib/utils/ExprUtil.js +18 -29
  64. package/dist/lib/utils/ResourceLoader.js +19 -7
  65. package/dist/lib/utils/SectionProvider.js +1 -1
  66. package/dist/lib/utils/initResourceLoader.d.ts +2 -0
  67. package/dist/lib/utils/initResourceLoader.js +64 -95
  68. package/dist/lib/utils/nunjucks.d.ts +2 -0
  69. package/dist/lib/utils/nunjucks.js +8 -0
  70. package/dist/templates/CrudFormTemplate.js +2 -3
  71. package/dist/templates/DataListTemplate.js +1 -1
  72. package/dist/templates/WizardTemplate.d.ts +3 -0
  73. package/dist/templates/WizardTemplate.js +17 -10
  74. package/package.json +1 -1
  75. package/dist/components/input/Select.d.ts +0 -14
  76. package/dist/components/input/Select.js +0 -40
@@ -1,8 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import BorderLayout from "../layouts/BorderLayout";
3
- import HPanel from "../layouts/HPanel";
4
- import VPanel from "../layouts/VPanel";
5
- import { SectionProvider } from "../lib/utils/SectionProvider";
3
+ import { HPanel, VPanel } from "../layouts";
4
+ import { SectionProvider } from "../lib";
6
5
  const CrudFormTemplate = (props) => {
7
6
  const sp = SectionProvider(props !== null && props !== void 0 ? props : {});
8
7
  const getRight = () => {
@@ -9,7 +9,7 @@ const DataListTemplate = (props) => {
9
9
  const getPreferredTitle = () => {
10
10
  return title !== null && title !== void 0 ? title : pageView.getUI().getTitle();
11
11
  };
12
- const attr = { title: getPreferredTitle(), cols, data, rowsPerPage, commonActions, rowActions, toolbarActions, bulkActions, filters };
12
+ const attr = { title: getPreferredTitle(), cols, data, rowsPerPage, commonActions, rowActions, toolbarActions, bulkActions, filters, searchable };
13
13
  const loadPanel = (section) => {
14
14
  return _jsx(Panel, { content: section });
15
15
  };
@@ -1,6 +1,9 @@
1
+ import React from "react";
1
2
  import { StepActionHandler } from "../core/StepHandler";
2
3
  type WizardTemplateProps = {
4
+ title?: string;
3
5
  component?: string;
6
+ componentid?: string;
4
7
  attr?: Record<string, any>;
5
8
  stepHandler: StepActionHandler;
6
9
  children?: React.ReactNode;
@@ -1,21 +1,26 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button } from "@ramesesinc/client";
3
- import { useEffect, useState } from "react";
3
+ import React, { useEffect, useState } from "react";
4
4
  import { useApp } from "../core/AppContext";
5
5
  import BorderLayout from "../layouts/BorderLayout";
6
+ import { ResourceLoader } from "../lib/utils/ResourceLoader";
6
7
  const WizardTemplate = (props) => {
7
- const { component, attr = {}, stepHandler, children } = props !== null && props !== void 0 ? props : {};
8
+ const { title, component, componentid, stepHandler, children } = props !== null && props !== void 0 ? props : {};
8
9
  const [view, setView] = useState(null);
9
10
  const { getComponentCache } = useApp();
10
11
  const loadComponent = async () => {
11
- if (component == null || component.trim() === "") {
12
- setView(null);
12
+ var _a;
13
+ if (componentid === null || componentid === void 0 ? void 0 : componentid.trim()) {
14
+ const comp = await getComponentCache(componentid);
15
+ setView(comp.template);
13
16
  return;
14
17
  }
15
- const comp = await getComponentCache(component);
16
- const Tmpl = comp.template;
17
- const el = _jsx(Tmpl, Object.assign({}, (attr !== null && attr !== void 0 ? attr : {})));
18
- setView(el);
18
+ if (component === null || component === void 0 ? void 0 : component.trim()) {
19
+ const Comp = ResourceLoader.getComponent(component);
20
+ setView(_jsx(React.Suspense, { fallback: _jsx("div", { children: "Loading..." }), children: _jsx(Comp, Object.assign({}, ((_a = props.attr) !== null && _a !== void 0 ? _a : {}))) }));
21
+ return;
22
+ }
23
+ setView(null);
19
24
  };
20
25
  const render = () => {
21
26
  if (view != null) {
@@ -24,14 +29,16 @@ const WizardTemplate = (props) => {
24
29
  return children;
25
30
  };
26
31
  useEffect(() => {
32
+ setView(null);
27
33
  loadComponent();
28
- }, []);
34
+ }, [component, componentid]);
29
35
  const handleNext = () => {
30
36
  stepHandler === null || stepHandler === void 0 ? void 0 : stepHandler.next();
31
37
  };
32
38
  const handleBack = () => {
33
39
  stepHandler === null || stepHandler === void 0 ? void 0 : stepHandler.back();
34
40
  };
35
- return (_jsx("div", { children: _jsx(BorderLayout, { south: _jsxs("div", { className: "flex justify-between gap-2", children: [(stepHandler === null || stepHandler === void 0 ? void 0 : stepHandler.hasPrev()) && _jsx(Button, { onClick: handleBack, children: "Back" }), (stepHandler === null || stepHandler === void 0 ? void 0 : stepHandler.hasNext()) && (_jsx("div", { className: "flex gap-2", children: _jsx(Button, { onClick: handleNext, children: "Next" }) }))] }), children: render() }) }));
41
+ const south = (_jsxs("div", { className: "flex justify-between gap-2 p-4 font-proxima-600", children: [_jsx("div", { className: "flex gap-2", children: (stepHandler === null || stepHandler === void 0 ? void 0 : stepHandler.hasPrev()) && (_jsx(Button, { onClick: handleBack, className: "bg-transparent text-gray-500 border-none shadow-none hover:bg-gray-100", children: "Back" })) }), _jsx("div", { className: "flex gap-2", children: (stepHandler === null || stepHandler === void 0 ? void 0 : stepHandler.hasNext()) && (_jsx(Button, { onClick: handleNext, className: "bg-primary-500 text-white hover:bg-primary-600", children: "Next" })) })] }));
42
+ return (_jsx(BorderLayout, { north: _jsx("div", { className: "mb-2 font-semibold text-lg", children: title }), south: south, children: render() }));
36
43
  };
37
44
  export default WizardTemplate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramesesinc/platform-core",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Platform Core Library",
5
5
  "author": "Rameses Systems Inc.",
6
6
  "license": "MIT",
@@ -1,14 +0,0 @@
1
- import { UIInputProps } from "../common/UIInput";
2
- type SelectOption = {
3
- label: string;
4
- value: string;
5
- };
6
- type SelectFieldProps = UIInputProps & {
7
- required?: boolean;
8
- immediate?: boolean;
9
- options?: SelectOption[];
10
- placeholder?: string;
11
- onChange?: (value: string) => void;
12
- };
13
- declare const SelectField: (props: SelectFieldProps) => import("react/jsx-runtime").JSX.Element;
14
- export default SelectField;
@@ -1,40 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useRef, useState } from "react";
3
- import UIComponent from "../common/UIComponent";
4
- import useUIInput from "../common/UIInput";
5
- const SelectField = (props) => {
6
- const { immediate = true, options = [], placeholder } = props !== null && props !== void 0 ? props : {};
7
- const [focused, setFocused] = useState(false);
8
- const selectRef = useRef(null);
9
- const valueRef = useRef("");
10
- const className = "border rounded px-2 py-1 w-full";
11
- const handleFocus = () => {
12
- setFocused(true);
13
- };
14
- const handleBlur = () => {
15
- if (!immediate) {
16
- setValue(selectValue);
17
- }
18
- setFocused(false);
19
- };
20
- const onRefresh = () => {
21
- setSelectValue(getValue());
22
- };
23
- const { initialValue, getValue, setValue, binding } = useUIInput(Object.assign(Object.assign({}, props), { onRefresh }));
24
- valueRef.current = initialValue !== null && initialValue !== void 0 ? initialValue : "";
25
- const [selectValue, setSelectValue] = useState(valueRef.current);
26
- const onChange = (e) => {
27
- var _a, _b;
28
- const text = (_a = e.target.value) !== null && _a !== void 0 ? _a : "";
29
- if (text !== selectValue) {
30
- valueRef.current = text;
31
- setSelectValue(valueRef.current);
32
- }
33
- if (immediate) {
34
- setValue(text);
35
- }
36
- (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, text);
37
- };
38
- return (_jsx(UIComponent, Object.assign({}, (props !== null && props !== void 0 ? props : {}), { children: _jsxs("select", { ref: selectRef, onChange: onChange, value: selectValue, onFocus: handleFocus, onBlur: handleBlur, className: className, children: [placeholder && (_jsx("option", { value: "", disabled: true, children: placeholder })), options.map((opt) => (_jsx("option", { value: opt.value, children: opt.label }, opt.value)))] }) })));
39
- };
40
- export default SelectField;