@darajs/components 1.0.0-a.1
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.
- package/LICENSE +201 -0
- package/README.md +5 -0
- package/dist/common/accordion/accordion.d.ts +17 -0
- package/dist/common/accordion/accordion.d.ts.map +1 -0
- package/dist/common/accordion/accordion.js +34 -0
- package/dist/common/accordion/accordion.js.map +1 -0
- package/dist/common/anchor/anchor.d.ts +17 -0
- package/dist/common/anchor/anchor.d.ts.map +1 -0
- package/dist/common/anchor/anchor.js +25 -0
- package/dist/common/anchor/anchor.js.map +1 -0
- package/dist/common/bullet-list/bullet_list.d.ts +16 -0
- package/dist/common/bullet-list/bullet_list.d.ts.map +1 -0
- package/dist/common/bullet-list/bullet_list.js +17 -0
- package/dist/common/bullet-list/bullet_list.js.map +1 -0
- package/dist/common/button/button.d.ts +24 -0
- package/dist/common/button/button.d.ts.map +1 -0
- package/dist/common/button/button.js +46 -0
- package/dist/common/button/button.js.map +1 -0
- package/dist/common/button-bar/button-bar.d.ts +22 -0
- package/dist/common/button-bar/button-bar.d.ts.map +1 -0
- package/dist/common/button-bar/button-bar.js +26 -0
- package/dist/common/button-bar/button-bar.js.map +1 -0
- package/dist/common/card/card.d.ts +24 -0
- package/dist/common/card/card.d.ts.map +1 -0
- package/dist/common/card/card.js +54 -0
- package/dist/common/card/card.js.map +1 -0
- package/dist/common/carousel/carousel.d.ts +27 -0
- package/dist/common/carousel/carousel.d.ts.map +1 -0
- package/dist/common/carousel/carousel.js +42 -0
- package/dist/common/carousel/carousel.js.map +1 -0
- package/dist/common/checkbox-group/checkbox-group.d.ts +24 -0
- package/dist/common/checkbox-group/checkbox-group.d.ts.map +1 -0
- package/dist/common/checkbox-group/checkbox-group.js +36 -0
- package/dist/common/checkbox-group/checkbox-group.js.map +1 -0
- package/dist/common/code/code.d.ts +15 -0
- package/dist/common/code/code.d.ts.map +1 -0
- package/dist/common/code/code.js +41 -0
- package/dist/common/code/code.js.map +1 -0
- package/dist/common/component-select-list/component-select-list.d.ts +23 -0
- package/dist/common/component-select-list/component-select-list.d.ts.map +1 -0
- package/dist/common/component-select-list/component-select-list.js +29 -0
- package/dist/common/component-select-list/component-select-list.js.map +1 -0
- package/dist/common/constants.d.ts +19 -0
- package/dist/common/constants.d.ts.map +1 -0
- package/dist/common/constants.js +21 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/context/form-context.d.ts +21 -0
- package/dist/common/context/form-context.d.ts.map +1 -0
- package/dist/common/context/form-context.js +28 -0
- package/dist/common/context/form-context.js.map +1 -0
- package/dist/common/context/index.d.ts +2 -0
- package/dist/common/context/index.d.ts.map +1 -0
- package/dist/common/context/index.js +2 -0
- package/dist/common/context/index.js.map +1 -0
- package/dist/common/datepicker/datepicker.d.ts +31 -0
- package/dist/common/datepicker/datepicker.d.ts.map +1 -0
- package/dist/common/datepicker/datepicker.js +70 -0
- package/dist/common/datepicker/datepicker.js.map +1 -0
- package/dist/common/dropzone/dropzone.d.ts +19 -0
- package/dist/common/dropzone/dropzone.d.ts.map +1 -0
- package/dist/common/dropzone/dropzone.js +101 -0
- package/dist/common/dropzone/dropzone.js.map +1 -0
- package/dist/common/form/form.d.ts +11 -0
- package/dist/common/form/form.d.ts.map +1 -0
- package/dist/common/form/form.js +46 -0
- package/dist/common/form/form.js.map +1 -0
- package/dist/common/form-page/form-page.d.ts +12 -0
- package/dist/common/form-page/form-page.d.ts.map +1 -0
- package/dist/common/form-page/form-page.js +18 -0
- package/dist/common/form-page/form-page.js.map +1 -0
- package/dist/common/grid/column.d.ts +24 -0
- package/dist/common/grid/column.d.ts.map +1 -0
- package/dist/common/grid/column.js +22 -0
- package/dist/common/grid/column.js.map +1 -0
- package/dist/common/grid/grid.d.ts +18 -0
- package/dist/common/grid/grid.d.ts.map +1 -0
- package/dist/common/grid/grid.js +31 -0
- package/dist/common/grid/grid.js.map +1 -0
- package/dist/common/grid/row.d.ts +22 -0
- package/dist/common/grid/row.d.ts.map +1 -0
- package/dist/common/grid/row.js +236 -0
- package/dist/common/grid/row.js.map +1 -0
- package/dist/common/heading/heading.d.ts +9 -0
- package/dist/common/heading/heading.d.ts.map +1 -0
- package/dist/common/heading/heading.js +14 -0
- package/dist/common/heading/heading.js.map +1 -0
- package/dist/common/html-raw/html-raw.d.ts +15 -0
- package/dist/common/html-raw/html-raw.d.ts.map +1 -0
- package/dist/common/html-raw/html-raw.js +22 -0
- package/dist/common/html-raw/html-raw.js.map +1 -0
- package/dist/common/icon/icon.d.ts +8 -0
- package/dist/common/icon/icon.d.ts.map +1 -0
- package/dist/common/icon/icon.js +11 -0
- package/dist/common/icon/icon.js.map +1 -0
- package/dist/common/if/if.d.ts +27 -0
- package/dist/common/if/if.d.ts.map +1 -0
- package/dist/common/if/if.js +52 -0
- package/dist/common/if/if.js.map +1 -0
- package/dist/common/image/image.d.ts +15 -0
- package/dist/common/image/image.d.ts.map +1 -0
- package/dist/common/image/image.js +21 -0
- package/dist/common/image/image.js.map +1 -0
- package/dist/common/index.d.ts +43 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +41 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/input/input.d.ts +20 -0
- package/dist/common/input/input.d.ts.map +1 -0
- package/dist/common/input/input.js +45 -0
- package/dist/common/input/input.js.map +1 -0
- package/dist/common/label/label.d.ts +21 -0
- package/dist/common/label/label.d.ts.map +1 -0
- package/dist/common/label/label.js +28 -0
- package/dist/common/label/label.js.map +1 -0
- package/dist/common/markdown/markdown.d.ts +17 -0
- package/dist/common/markdown/markdown.d.ts.map +1 -0
- package/dist/common/markdown/markdown.js +186 -0
- package/dist/common/markdown/markdown.js.map +1 -0
- package/dist/common/modal/modal.d.ts +15 -0
- package/dist/common/modal/modal.d.ts.map +1 -0
- package/dist/common/modal/modal.js +19 -0
- package/dist/common/modal/modal.js.map +1 -0
- package/dist/common/overlay/overlay.d.ts +16 -0
- package/dist/common/overlay/overlay.d.ts.map +1 -0
- package/dist/common/overlay/overlay.js +31 -0
- package/dist/common/overlay/overlay.js.map +1 -0
- package/dist/common/paragraph/paragraph.d.ts +9 -0
- package/dist/common/paragraph/paragraph.d.ts.map +1 -0
- package/dist/common/paragraph/paragraph.js +10 -0
- package/dist/common/paragraph/paragraph.js.map +1 -0
- package/dist/common/progress-bar/progress-bar.d.ts +17 -0
- package/dist/common/progress-bar/progress-bar.d.ts.map +1 -0
- package/dist/common/progress-bar/progress-bar.js +23 -0
- package/dist/common/progress-bar/progress-bar.js.map +1 -0
- package/dist/common/radio-group/radio-group.d.ts +21 -0
- package/dist/common/radio-group/radio-group.d.ts.map +1 -0
- package/dist/common/radio-group/radio-group.js +28 -0
- package/dist/common/radio-group/radio-group.js.map +1 -0
- package/dist/common/select/select.d.ts +31 -0
- package/dist/common/select/select.d.ts.map +1 -0
- package/dist/common/select/select.js +105 -0
- package/dist/common/select/select.js.map +1 -0
- package/dist/common/slider/slider.d.ts +29 -0
- package/dist/common/slider/slider.d.ts.map +1 -0
- package/dist/common/slider/slider.js +38 -0
- package/dist/common/slider/slider.js.map +1 -0
- package/dist/common/spacer/spacer.d.ts +10 -0
- package/dist/common/spacer/spacer.d.ts.map +1 -0
- package/dist/common/spacer/spacer.js +30 -0
- package/dist/common/spacer/spacer.js.map +1 -0
- package/dist/common/stack/stack.d.ts +14 -0
- package/dist/common/stack/stack.d.ts.map +1 -0
- package/dist/common/stack/stack.js +49 -0
- package/dist/common/stack/stack.js.map +1 -0
- package/dist/common/switch/switch.d.ts +14 -0
- package/dist/common/switch/switch.d.ts.map +1 -0
- package/dist/common/switch/switch.js +30 -0
- package/dist/common/switch/switch.js.map +1 -0
- package/dist/common/tabbed-card/tabbed-card.d.ts +24 -0
- package/dist/common/tabbed-card/tabbed-card.d.ts.map +1 -0
- package/dist/common/tabbed-card/tabbed-card.js +61 -0
- package/dist/common/tabbed-card/tabbed-card.js.map +1 -0
- package/dist/common/table/cells/adaptive-precision-cell.d.ts +9 -0
- package/dist/common/table/cells/adaptive-precision-cell.d.ts.map +1 -0
- package/dist/common/table/cells/adaptive-precision-cell.js +30 -0
- package/dist/common/table/cells/adaptive-precision-cell.js.map +1 -0
- package/dist/common/table/cells/badge-formatter-cell.d.ts +19 -0
- package/dist/common/table/cells/badge-formatter-cell.d.ts.map +1 -0
- package/dist/common/table/cells/badge-formatter-cell.js +16 -0
- package/dist/common/table/cells/badge-formatter-cell.js.map +1 -0
- package/dist/common/table/cells/code-cell.d.ts +12 -0
- package/dist/common/table/cells/code-cell.d.ts.map +1 -0
- package/dist/common/table/cells/code-cell.js +19 -0
- package/dist/common/table/cells/code-cell.js.map +1 -0
- package/dist/common/table/cells/compare-cell.d.ts +13 -0
- package/dist/common/table/cells/compare-cell.d.ts.map +1 -0
- package/dist/common/table/cells/compare-cell.js +34 -0
- package/dist/common/table/cells/compare-cell.js.map +1 -0
- package/dist/common/table/cells/formatted-text-cell.d.ts +9 -0
- package/dist/common/table/cells/formatted-text-cell.d.ts.map +1 -0
- package/dist/common/table/cells/formatted-text-cell.js +15 -0
- package/dist/common/table/cells/formatted-text-cell.js.map +1 -0
- package/dist/common/table/cells/index.d.ts +11 -0
- package/dist/common/table/cells/index.d.ts.map +1 -0
- package/dist/common/table/cells/index.js +11 -0
- package/dist/common/table/cells/index.js.map +1 -0
- package/dist/common/table/cells/link-cell.d.ts +10 -0
- package/dist/common/table/cells/link-cell.d.ts.map +1 -0
- package/dist/common/table/cells/link-cell.js +15 -0
- package/dist/common/table/cells/link-cell.js.map +1 -0
- package/dist/common/table/cells/number-cell.d.ts +11 -0
- package/dist/common/table/cells/number-cell.d.ts.map +1 -0
- package/dist/common/table/cells/number-cell.js +16 -0
- package/dist/common/table/cells/number-cell.js.map +1 -0
- package/dist/common/table/cells/number-intl-cell.d.ts +11 -0
- package/dist/common/table/cells/number-intl-cell.d.ts.map +1 -0
- package/dist/common/table/cells/number-intl-cell.js +16 -0
- package/dist/common/table/cells/number-intl-cell.js.map +1 -0
- package/dist/common/table/cells/percentage-cell.d.ts +11 -0
- package/dist/common/table/cells/percentage-cell.d.ts.map +1 -0
- package/dist/common/table/cells/percentage-cell.js +16 -0
- package/dist/common/table/cells/percentage-cell.js.map +1 -0
- package/dist/common/table/cells/threshold-formatted-cell.d.ts +15 -0
- package/dist/common/table/cells/threshold-formatted-cell.d.ts.map +1 -0
- package/dist/common/table/cells/threshold-formatted-cell.js +20 -0
- package/dist/common/table/cells/threshold-formatted-cell.js.map +1 -0
- package/dist/common/table/table.d.ts +56 -0
- package/dist/common/table/table.d.ts.map +1 -0
- package/dist/common/table/table.js +404 -0
- package/dist/common/table/table.js.map +1 -0
- package/dist/common/text/text.d.ts +12 -0
- package/dist/common/text/text.d.ts.map +1 -0
- package/dist/common/text/text.js +23 -0
- package/dist/common/text/text.js.map +1 -0
- package/dist/common/textarea/textarea.d.ts +19 -0
- package/dist/common/textarea/textarea.d.ts.map +1 -0
- package/dist/common/textarea/textarea.js +42 -0
- package/dist/common/textarea/textarea.js.map +1 -0
- package/dist/common/tooltip/tooltip.d.ts +18 -0
- package/dist/common/tooltip/tooltip.d.ts.map +1 -0
- package/dist/common/tooltip/tooltip.js +18 -0
- package/dist/common/tooltip/tooltip.js.map +1 -0
- package/dist/common/types.d.ts +26 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/types.js +9 -0
- package/dist/common/types.js.map +1 -0
- package/dist/dara_components-1.0.0a1-py3-none-any.whl +0 -0
- package/dist/graphs/causal-graph-viewer.d.ts +50 -0
- package/dist/graphs/causal-graph-viewer.d.ts.map +1 -0
- package/dist/graphs/causal-graph-viewer.js +32 -0
- package/dist/graphs/causal-graph-viewer.js.map +1 -0
- package/dist/graphs/graph-layout.d.ts +60 -0
- package/dist/graphs/graph-layout.d.ts.map +1 -0
- package/dist/graphs/graph-layout.js +110 -0
- package/dist/graphs/graph-layout.js.map +1 -0
- package/dist/graphs/index.d.ts +4 -0
- package/dist/graphs/index.d.ts.map +1 -0
- package/dist/graphs/index.js +4 -0
- package/dist/graphs/index.js.map +1 -0
- package/dist/graphs/node-hierarchy-builder.d.ts +24 -0
- package/dist/graphs/node-hierarchy-builder.d.ts.map +1 -0
- package/dist/graphs/node-hierarchy-builder.js +40 -0
- package/dist/graphs/node-hierarchy-builder.js.map +1 -0
- package/dist/graphs/visual-edge-encoder.d.ts +32 -0
- package/dist/graphs/visual-edge-encoder.d.ts.map +1 -0
- package/dist/graphs/visual-edge-encoder.js +84 -0
- package/dist/graphs/visual-edge-encoder.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/plotting/bokeh/bokeh.d.ts +28 -0
- package/dist/plotting/bokeh/bokeh.d.ts.map +1 -0
- package/dist/plotting/bokeh/bokeh.js +125 -0
- package/dist/plotting/bokeh/bokeh.js.map +1 -0
- package/dist/plotting/index.d.ts +4 -0
- package/dist/plotting/index.d.ts.map +1 -0
- package/dist/plotting/index.js +5 -0
- package/dist/plotting/index.js.map +1 -0
- package/dist/plotting/matplotlib/matplotlib.d.ts +12 -0
- package/dist/plotting/matplotlib/matplotlib.d.ts.map +1 -0
- package/dist/plotting/matplotlib/matplotlib.js +14 -0
- package/dist/plotting/matplotlib/matplotlib.js.map +1 -0
- package/dist/plotting/plotly/plotly.d.ts +60 -0
- package/dist/plotting/plotly/plotly.d.ts.map +1 -0
- package/dist/plotting/plotly/plotly.js +233 -0
- package/dist/plotting/plotly/plotly.js.map +1 -0
- package/dist/smart/code-editor.d.ts +11 -0
- package/dist/smart/code-editor.d.ts.map +1 -0
- package/dist/smart/code-editor.js +15 -0
- package/dist/smart/code-editor.js.map +1 -0
- package/dist/smart/data-slicer-filter/data-slicer-filter.d.ts +47 -0
- package/dist/smart/data-slicer-filter/data-slicer-filter.d.ts.map +1 -0
- package/dist/smart/data-slicer-filter/data-slicer-filter.js +123 -0
- package/dist/smart/data-slicer-filter/data-slicer-filter.js.map +1 -0
- package/dist/smart/filter-status-button/filter-status-button.d.ts +14 -0
- package/dist/smart/filter-status-button/filter-status-button.d.ts.map +1 -0
- package/dist/smart/filter-status-button/filter-status-button.js +49 -0
- package/dist/smart/filter-status-button/filter-status-button.js.map +1 -0
- package/dist/smart/hierarchy-selector/hierarchy-selector.d.ts +23 -0
- package/dist/smart/hierarchy-selector/hierarchy-selector.d.ts.map +1 -0
- package/dist/smart/hierarchy-selector/hierarchy-selector.js +17 -0
- package/dist/smart/hierarchy-selector/hierarchy-selector.js.map +1 -0
- package/dist/smart/hierarchy-viewer/hierarchy-viewer.d.ts +16 -0
- package/dist/smart/hierarchy-viewer/hierarchy-viewer.d.ts.map +1 -0
- package/dist/smart/hierarchy-viewer/hierarchy-viewer.js +17 -0
- package/dist/smart/hierarchy-viewer/hierarchy-viewer.js.map +1 -0
- package/dist/smart/index.d.ts +6 -0
- package/dist/smart/index.d.ts.map +1 -0
- package/dist/smart/index.js +7 -0
- package/dist/smart/index.js.map +1 -0
- package/dist/umd/dara.components.umd.js +386628 -0
- package/dist/umd/style.css +745 -0
- package/package.json +87 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.js","sourceRoot":"","sources":["../../../js/common/modal/modal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEH,gBAAgB,EAGhB,SAAS,EACT,kBAAkB,EAClB,WAAW,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAC;AASzD,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;AAEvC;;;;GAIG;AACH,SAAS,KAAK,CAAC,KAAiB;IAC5B,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACtD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEhD,SAAS,cAAc;QACnB,OAAO,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,CACH,KAAC,WAAW,eAAU,GAAG,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,kBAAI,GAAG,EAAE,SAAS,IAAK,KAAK,aACrG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAChC,KAAC,gBAAgB,IAAC,SAAS,EAAE,KAAK,IAAO,SAAS,GAAG,IAAI,KAAK,CAAC,GAAG,EAAE,CAAI,CAC3E,CAAC,GACQ,CACjB,CAAC;AACN,CAAC;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentInstance, StyledComponentProps, Variable } from '@darajs/core';
|
|
2
|
+
interface OverlayProps extends StyledComponentProps {
|
|
3
|
+
children: Array<ComponentInstance>;
|
|
4
|
+
margin?: string;
|
|
5
|
+
padding?: string;
|
|
6
|
+
position?: string;
|
|
7
|
+
show: Variable<boolean>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The overlay component accepts a set of children and renders them as an overlay depending on the value of the render flag.
|
|
11
|
+
*
|
|
12
|
+
* @param props the component props
|
|
13
|
+
*/
|
|
14
|
+
declare function Overlay(props: OverlayProps): JSX.Element;
|
|
15
|
+
export default Overlay;
|
|
16
|
+
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../js/common/overlay/overlay.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EAEjB,oBAAoB,EACpB,QAAQ,EAIX,MAAM,cAAc,CAAC;AA2BtB,UAAU,YAAa,SAAQ,oBAAoB;IAE/C,QAAQ,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAEnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC3B;AAED;;;;GAIG;AACH,iBAAS,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CAiBjD;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DynamicComponent, injectCss, useComponentStyles, useVariable, } from '@darajs/core';
|
|
3
|
+
import styled from '@darajs/styled-components';
|
|
4
|
+
const OverlayWrapper = injectCss(styled.div `
|
|
5
|
+
position: absolute;
|
|
6
|
+
z-index: 2000;
|
|
7
|
+
top: ${(props) => { var _a; return (((_a = props.position) === null || _a === void 0 ? void 0 : _a.includes('top')) ? '0' : null); }};
|
|
8
|
+
right: ${(props) => { var _a; return (((_a = props.position) === null || _a === void 0 ? void 0 : _a.includes('right')) ? '0' : null); }};
|
|
9
|
+
bottom: ${(props) => { var _a; return (((_a = props.position) === null || _a === void 0 ? void 0 : _a.includes('bottom')) ? '0' : null); }};
|
|
10
|
+
left: ${(props) => { var _a; return (((_a = props.position) === null || _a === void 0 ? void 0 : _a.includes('left')) ? '0' : null); }};
|
|
11
|
+
|
|
12
|
+
display: ${(props) => (props.render ? 'inline-flex' : 'none')};
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
|
|
15
|
+
max-width: 100%;
|
|
16
|
+
max-height: 100%;
|
|
17
|
+
margin: ${(props) => props.margin};
|
|
18
|
+
padding: ${(props) => (props.padding ? props.padding : '1rem')};
|
|
19
|
+
`);
|
|
20
|
+
/**
|
|
21
|
+
* The overlay component accepts a set of children and renders them as an overlay depending on the value of the render flag.
|
|
22
|
+
*
|
|
23
|
+
* @param props the component props
|
|
24
|
+
*/
|
|
25
|
+
function Overlay(props) {
|
|
26
|
+
const [styles, css] = useComponentStyles(props);
|
|
27
|
+
const [show] = useVariable(props.show || true);
|
|
28
|
+
return (_jsx(OverlayWrapper, { "$rawCss": css, margin: props.margin, padding: props.padding, position: props.position, render: show, style: styles, children: props.children.map((child, idx) => (_jsx(DynamicComponent, { component: child }, `overlay-${idx}-${child.uid}`))) }));
|
|
29
|
+
}
|
|
30
|
+
export default Overlay;
|
|
31
|
+
//# sourceMappingURL=overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.js","sourceRoot":"","sources":["../../../js/common/overlay/overlay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEH,gBAAgB,EAGhB,SAAS,EACT,kBAAkB,EAClB,WAAW,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAS/C,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAY;;;WAG5C,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,CAAC,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,QAAQ,CAAC,KAAK,CAAC,EAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA,EAAA;aACvD,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,CAAC,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,QAAQ,CAAC,OAAO,CAAC,EAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA,EAAA;cAC1D,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,CAAC,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,QAAQ,CAAC,QAAQ,CAAC,EAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA,EAAA;YAC9D,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,CAAC,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,QAAQ,CAAC,MAAM,CAAC,EAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA,EAAA;;eAEvD,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC;;;;;cAKnD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM;eACtB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;CACjE,CAAC,CAAC;AAgBH;;;;GAIG;AACH,SAAS,OAAO,CAAC,KAAmB;IAChC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;IAC/C,OAAO,CACH,KAAC,cAAc,eACF,GAAG,EACZ,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,MAAM,YAEZ,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAChC,KAAC,gBAAgB,IAAC,SAAS,EAAE,KAAK,IAAO,WAAW,GAAG,IAAI,KAAK,CAAC,GAAG,EAAE,CAAI,CAC7E,CAAC,GACW,CACpB,CAAC;AACN,CAAC;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentInstance, StyledComponentProps } from '@darajs/core';
|
|
2
|
+
interface ParagraphProps extends StyledComponentProps {
|
|
3
|
+
align: 'start' | 'end' | 'left' | 'right' | 'center' | 'justify' | 'match-parent';
|
|
4
|
+
children: Array<ComponentInstance>;
|
|
5
|
+
className: string;
|
|
6
|
+
}
|
|
7
|
+
declare function Paragraph(props: ParagraphProps): JSX.Element;
|
|
8
|
+
export default Paragraph;
|
|
9
|
+
//# sourceMappingURL=paragraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../../js/common/paragraph/paragraph.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EAGjB,oBAAoB,EAGvB,MAAM,cAAc,CAAC;AAItB,UAAU,cAAe,SAAQ,oBAAoB;IACjD,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,cAAc,CAAC;IAClF,QAAQ,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;CACrB;AAID,iBAAS,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,GAAG,CAAC,OAAO,CAWrD;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DisplayCtx, DynamicComponent, injectCss, useComponentStyles, } from '@darajs/core';
|
|
3
|
+
import { ComponentType } from '../constants';
|
|
4
|
+
const StyledP = injectCss('p');
|
|
5
|
+
function Paragraph(props) {
|
|
6
|
+
const [style, css] = useComponentStyles(props);
|
|
7
|
+
return (_jsx(StyledP, { "$rawCss": css, className: props.className, style: Object.assign(Object.assign({}, style), { textAlign: props.align }), children: _jsx(DisplayCtx.Provider, { value: { component: ComponentType.PARAGRAPH, direction: 'horizontal' }, children: props.children.map((child, idx) => (_jsx(DynamicComponent, { component: child }, `stack-${idx}-${child.name}`))) }) }));
|
|
8
|
+
}
|
|
9
|
+
export default Paragraph;
|
|
10
|
+
//# sourceMappingURL=paragraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paragraph.js","sourceRoot":"","sources":["../../../js/common/paragraph/paragraph.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEH,UAAU,EACV,gBAAgB,EAEhB,SAAS,EACT,kBAAkB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQ7C,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;AAE/B,SAAS,SAAS,CAAC,KAAqB;IACpC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,CACH,KAAC,OAAO,eAAU,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,kCAAO,KAAK,KAAE,SAAS,EAAE,KAAK,CAAC,KAAK,eACxF,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,YACtF,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAChC,KAAC,gBAAgB,IAAC,SAAS,EAAE,KAAK,IAAO,SAAS,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAI,CAC5E,CAAC,GACgB,GAChB,CACb,CAAC;AACN,CAAC;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StyledComponentProps, Variable } from '@darajs/core';
|
|
2
|
+
interface ProgressBarProps extends StyledComponentProps {
|
|
3
|
+
/** Optional color prop for the progress bar, should be a hex code */
|
|
4
|
+
color?: string;
|
|
5
|
+
/** The current progress as a percentage */
|
|
6
|
+
progress: number | Variable<number>;
|
|
7
|
+
/** Set the progress bar to view as a smaller strip with no label */
|
|
8
|
+
small?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A simple progress bar component, that displays the current progress to 100% as a bar with a small label
|
|
12
|
+
*
|
|
13
|
+
* @param props the component props
|
|
14
|
+
*/
|
|
15
|
+
declare function ProgressBar(props: ProgressBarProps): JSX.Element;
|
|
16
|
+
export default ProgressBar;
|
|
17
|
+
//# sourceMappingURL=progress-bar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-bar.d.ts","sourceRoot":"","sources":["../../../js/common/progress-bar/progress-bar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAA8C,MAAM,cAAc,CAAC;AAY1G,UAAU,gBAAiB,SAAQ,oBAAoB;IACnD,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpC,oEAAoE;IACpE,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAQzD;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { injectCss, useComponentStyles, useVariable } from '@darajs/core';
|
|
3
|
+
import styled from '@darajs/styled-components';
|
|
4
|
+
import { ProgressBar as UiProgressBar } from '@darajs/ui-components';
|
|
5
|
+
const ProgressBarWrapper = styled.div `
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
`;
|
|
11
|
+
const StyledProgressBar = injectCss(ProgressBarWrapper);
|
|
12
|
+
/**
|
|
13
|
+
* A simple progress bar component, that displays the current progress to 100% as a bar with a small label
|
|
14
|
+
*
|
|
15
|
+
* @param props the component props
|
|
16
|
+
*/
|
|
17
|
+
function ProgressBar(props) {
|
|
18
|
+
const [style, css] = useComponentStyles(props);
|
|
19
|
+
const [progress] = useVariable(props.progress);
|
|
20
|
+
return (_jsx(StyledProgressBar, { "$rawCss": css, style: style, children: _jsx(UiProgressBar, { color: props.color, progress: progress, small: props.small }) }));
|
|
21
|
+
}
|
|
22
|
+
export default ProgressBar;
|
|
23
|
+
//# sourceMappingURL=progress-bar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-bar.js","sourceRoot":"","sources":["../../../js/common/progress-bar/progress-bar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkC,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1G,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,WAAW,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAErE,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAKpC,CAAC;AACF,MAAM,iBAAiB,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAC;AAWxD;;;;GAIG;AACH,SAAS,WAAW,CAAC,KAAuB;IACxC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/C,OAAO,CACH,KAAC,iBAAiB,eAAU,GAAG,EAAE,KAAK,EAAE,KAAK,YACzC,KAAC,aAAa,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAI,GAC7D,CACvB,CAAC;AACN,CAAC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Variable } from '@darajs/core';
|
|
2
|
+
import { Item } from '@darajs/ui-components';
|
|
3
|
+
import { FormComponentProps } from '../types';
|
|
4
|
+
interface RadioGroupProps extends FormComponentProps {
|
|
5
|
+
/** Pass through the className property */
|
|
6
|
+
className: string;
|
|
7
|
+
/** An optional value which determines the direction of the radio group components by default is vertical */
|
|
8
|
+
direction?: 'horizontal' | 'vertical';
|
|
9
|
+
/** The list of items to choose from */
|
|
10
|
+
items: Array<Item> | Variable<Item[]>;
|
|
11
|
+
/** Whether to show radio in list style */
|
|
12
|
+
list_styling?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The RadioGroup component allows users to choose from a list of radio buttons.
|
|
16
|
+
*
|
|
17
|
+
* @param props the component props
|
|
18
|
+
*/
|
|
19
|
+
declare function RadioGroup(props: RadioGroupProps): JSX.Element;
|
|
20
|
+
export default RadioGroup;
|
|
21
|
+
//# sourceMappingURL=radio-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-group.d.ts","sourceRoot":"","sources":["../../../js/common/radio-group/radio-group.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAyD,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAE,IAAI,EAAyB,MAAM,uBAAuB,CAAC;AAGpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAI9C,UAAU,eAAgB,SAAQ,kBAAkB;IAChD,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,4GAA4G;IAC5G,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACtC,uCAAuC;IACvC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACtC,0CAA0C;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAID;;;;GAIG;AACH,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CA4BvD;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { injectCss, useAction, useComponentStyles, useVariable } from '@darajs/core';
|
|
4
|
+
import { RadioGroup as UiRadio } from '@darajs/ui-components';
|
|
5
|
+
import { useFormContext } from '../context';
|
|
6
|
+
const StyledRadio = injectCss(UiRadio);
|
|
7
|
+
// Disabling rules-of-hook as the assumption is that props changing the type of the select won't change
|
|
8
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
9
|
+
/**
|
|
10
|
+
* The RadioGroup component allows users to choose from a list of radio buttons.
|
|
11
|
+
*
|
|
12
|
+
* @param props the component props
|
|
13
|
+
*/
|
|
14
|
+
function RadioGroup(props) {
|
|
15
|
+
const formCtx = useFormContext(props);
|
|
16
|
+
const [items] = useVariable(props.items);
|
|
17
|
+
const [value, setValue] = useVariable(formCtx.resolveInitialValue([]));
|
|
18
|
+
const [style, css] = useComponentStyles(props);
|
|
19
|
+
const [onChangeAction] = useAction(props.onchange);
|
|
20
|
+
const onChange = useCallback((values) => {
|
|
21
|
+
setValue(values.value);
|
|
22
|
+
onChangeAction(values.value);
|
|
23
|
+
formCtx.updateForm(values.value);
|
|
24
|
+
}, [setValue]);
|
|
25
|
+
return (_jsx(StyledRadio, { "$rawCss": css, className: props.className, direction: props.direction, isListStyle: props.list_styling, items: items, onChange: onChange, style: style, value: items.find((item) => item.value === value) }));
|
|
26
|
+
}
|
|
27
|
+
export default RadioGroup;
|
|
28
|
+
//# sourceMappingURL=radio-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../../js/common/radio-group/radio-group.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAY,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAQ,UAAU,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,cAAc,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,31 @@
|
|
|
1
|
+
import { SingleVariable, UrlVariable, Variable } from '@darajs/core';
|
|
2
|
+
import { Item, ListSection } from '@darajs/ui-components';
|
|
3
|
+
import { FormComponentProps } from '../types';
|
|
4
|
+
export declare function getMultiselectItems(values: Array<any>, items: Array<Item>): Array<Item>;
|
|
5
|
+
interface SelectProps extends FormComponentProps {
|
|
6
|
+
/** Pass through the className property */
|
|
7
|
+
className: string;
|
|
8
|
+
/** The list of items to choose from */
|
|
9
|
+
items: Array<Item> | Variable<Item[]> | Array<ListSection> | Variable<Array<ListSection>>;
|
|
10
|
+
/** Optional number of rows to display in multiselect mode */
|
|
11
|
+
max_rows?: number;
|
|
12
|
+
/** Select multiple list items if True */
|
|
13
|
+
multiselect: boolean;
|
|
14
|
+
/** Placeholder to show when select is empty */
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
/** Searchable list if True */
|
|
17
|
+
searchable: boolean;
|
|
18
|
+
/** The selectedItem variable to read and update */
|
|
19
|
+
value?: SingleVariable<any> | UrlVariable<any>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The select component accepts a value Variable from the backend and allows the user to view and edit that variable
|
|
23
|
+
* from a selection of items provided in another prop. The value shared with the rest of the system is the value field
|
|
24
|
+
* from the currently selected item. Also takes a multiselect and searchable options that, respectively, enable multiple
|
|
25
|
+
* items to be selected and the list to be searchable if true.
|
|
26
|
+
*
|
|
27
|
+
* @param props the component props
|
|
28
|
+
*/
|
|
29
|
+
declare function Select(props: SelectProps): JSX.Element;
|
|
30
|
+
export default Select;
|
|
31
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../js/common/select/select.tsx"],"names":[],"mappings":"AAEA,OAAO,EACH,cAAc,EACd,WAAW,EACX,QAAQ,EAKX,MAAM,cAAc,CAAC;AACtB,OAAO,EAEH,IAAI,EAEJ,WAAW,EAId,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAWvF;AAUD,UAAU,WAAY,SAAQ,kBAAkB;IAC5C,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1F,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,mDAAmD;IAEnD,KAAK,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;CAClD;AAID;;;;;;;GAOG;AACH,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CA8H/C;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { injectCss, useAction, useComponentStyles, useVariable, } from '@darajs/core';
|
|
4
|
+
import { ComboBox, MultiSelect, SectionedList, Select as UiSelect, } from '@darajs/ui-components';
|
|
5
|
+
import { useFormContext } from '../context';
|
|
6
|
+
export function getMultiselectItems(values, items) {
|
|
7
|
+
if (!values) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return items.reduce((acc, item) => {
|
|
11
|
+
const stringOfValues = values.map((value) => String(value));
|
|
12
|
+
if (stringOfValues.includes(String(item.value))) {
|
|
13
|
+
return [...acc, item];
|
|
14
|
+
}
|
|
15
|
+
return acc;
|
|
16
|
+
}, []);
|
|
17
|
+
}
|
|
18
|
+
const StyledSelect = injectCss(UiSelect);
|
|
19
|
+
const StyledMultiSelect = injectCss(MultiSelect);
|
|
20
|
+
const StyledComboBox = injectCss(ComboBox);
|
|
21
|
+
const StyledSectionedList = injectCss(SectionedList);
|
|
22
|
+
function hasListSection(items) {
|
|
23
|
+
return items.length > 0 && 'items' in items[0];
|
|
24
|
+
}
|
|
25
|
+
// Disabling rules-of-hook as the assumption is that props changing the type of the select won't change
|
|
26
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
27
|
+
/**
|
|
28
|
+
* The select component accepts a value Variable from the backend and allows the user to view and edit that variable
|
|
29
|
+
* from a selection of items provided in another prop. The value shared with the rest of the system is the value field
|
|
30
|
+
* from the currently selected item. Also takes a multiselect and searchable options that, respectively, enable multiple
|
|
31
|
+
* items to be selected and the list to be searchable if true.
|
|
32
|
+
*
|
|
33
|
+
* @param props the component props
|
|
34
|
+
*/
|
|
35
|
+
function Select(props) {
|
|
36
|
+
const formCtx = useFormContext(props);
|
|
37
|
+
const [items] = useVariable(props.items);
|
|
38
|
+
const [style, css] = useComponentStyles(props);
|
|
39
|
+
const [value, setValue] = useVariable(formCtx.resolveInitialValue());
|
|
40
|
+
const [onChangeAction] = useAction(props.onchange);
|
|
41
|
+
// if someone were to update the component rule of Hooks could be broken if items switched from having sections to not, so we use a ref for this to be only run once
|
|
42
|
+
const itemHasListSection = useRef(null);
|
|
43
|
+
if (itemHasListSection.current === null) {
|
|
44
|
+
itemHasListSection.current = hasListSection(items);
|
|
45
|
+
}
|
|
46
|
+
// For multiselect we want to keep the initial value type consistent with later selections
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (props.multiselect && value !== undefined && !Array.isArray(value)) {
|
|
49
|
+
throw new Error('Value for multiselect should be a Variable instance of an array');
|
|
50
|
+
}
|
|
51
|
+
}, []);
|
|
52
|
+
if (itemHasListSection.current) {
|
|
53
|
+
const [selectedItem, setSelectedItem] = useState({ label: value, value });
|
|
54
|
+
const onSelect = useCallback((item) => {
|
|
55
|
+
setSelectedItem(item);
|
|
56
|
+
setValue(item.value);
|
|
57
|
+
}, [setValue]);
|
|
58
|
+
// Handle this way to prevent an infinite loop in the ui component due to referential comparison of selectedItem
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (value !== selectedItem.value) {
|
|
61
|
+
setSelectedItem({ label: value, value });
|
|
62
|
+
}
|
|
63
|
+
}, [value]);
|
|
64
|
+
return (_jsx(StyledSectionedList, { "$rawCss": css, items: items, onSelect: onSelect, selectedItem: selectedItem, style: style }));
|
|
65
|
+
}
|
|
66
|
+
// We need to redefine items as the type is not known at this point
|
|
67
|
+
const itemArray = items;
|
|
68
|
+
if (props.multiselect) {
|
|
69
|
+
const [selectedItems, setSelectedItems] = useState(getMultiselectItems(value, itemArray));
|
|
70
|
+
const onSelect = useCallback((_items) => {
|
|
71
|
+
const currentSelection = _items.map((item) => item.value);
|
|
72
|
+
setSelectedItems(getMultiselectItems(currentSelection, itemArray));
|
|
73
|
+
setValue(currentSelection);
|
|
74
|
+
onChangeAction(currentSelection);
|
|
75
|
+
formCtx.updateForm(currentSelection);
|
|
76
|
+
}, [setValue]);
|
|
77
|
+
// The loop up to the value in recoil state is too slow for downshift and leads to a race condition that makes
|
|
78
|
+
// it fail to update the value sometimes. By keeping a local copy of the value and updating it like this we fix
|
|
79
|
+
// the race condition and respect the main value if it is updated elsewhere.
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
setSelectedItems(getMultiselectItems(value, itemArray));
|
|
82
|
+
}, [items, value]);
|
|
83
|
+
return (_jsx(StyledMultiSelect, { "$rawCss": css, className: props.className, items: itemArray, maxRows: props.max_rows, onSelect: onSelect, placeholder: props.placeholder, selectedItems: selectedItems, style: style }));
|
|
84
|
+
}
|
|
85
|
+
const [selectedItem, setSelectedItem] = useState(itemArray.find((item) => String(item.value) === String(value)));
|
|
86
|
+
const onSelect = useCallback((item) => {
|
|
87
|
+
if (item) {
|
|
88
|
+
setSelectedItem(item);
|
|
89
|
+
setValue(item.value);
|
|
90
|
+
onChangeAction(item.value);
|
|
91
|
+
formCtx.updateForm(item.value);
|
|
92
|
+
}
|
|
93
|
+
}, [setValue, onChangeAction]);
|
|
94
|
+
// See explanation above
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
const selected = itemArray.find((item) => item.value === value);
|
|
97
|
+
setSelectedItem(selected !== undefined ? selected : null);
|
|
98
|
+
}, [items, value]);
|
|
99
|
+
if (props.searchable) {
|
|
100
|
+
return (_jsx(StyledComboBox, { "$rawCss": css, className: props.className, items: itemArray, onSelect: onSelect, placeholder: props.placeholder, selectedItem: selectedItem, style: style }));
|
|
101
|
+
}
|
|
102
|
+
return (_jsx(StyledSelect, { "$rawCss": css, className: props.className, items: itemArray, onSelect: onSelect, placeholder: props.placeholder, selectedItem: selectedItem, style: style }));
|
|
103
|
+
}
|
|
104
|
+
export default Select;
|
|
105
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../js/common/select/select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,EAIH,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,WAAW,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EACH,QAAQ,EAIR,WAAW,EACX,aAAa,EACb,MAAM,IAAI,QAAQ,GACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,MAAM,UAAU,mBAAmB,CAAC,MAAkB,EAAE,KAAkB;IACtE,IA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eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Variable } from '@darajs/core';
|
|
2
|
+
import { FormComponentProps } from '../types';
|
|
3
|
+
interface SliderProps extends FormComponentProps {
|
|
4
|
+
/** An optional flag to disable the input alternative switch render, its false by default */
|
|
5
|
+
disable_input_alternative?: boolean;
|
|
6
|
+
/** The range of the slider */
|
|
7
|
+
domain: [number, number];
|
|
8
|
+
/** Draw track from leftmost handle to start */
|
|
9
|
+
rail_from_start?: boolean;
|
|
10
|
+
/** Track labels */
|
|
11
|
+
rail_labels?: Array<string>;
|
|
12
|
+
/** Draw track from rightmost handle to end */
|
|
13
|
+
rail_to_end: boolean;
|
|
14
|
+
/** Slider step size */
|
|
15
|
+
step?: number;
|
|
16
|
+
/** Slider tick positions */
|
|
17
|
+
ticks?: Array<number>;
|
|
18
|
+
/** Slider handle values - interactive */
|
|
19
|
+
value?: Variable<Array<number> | number>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A component for rendering a slider bar with handles. This component is interactive, so the value of each handle
|
|
23
|
+
* is updated when they are moved.
|
|
24
|
+
*
|
|
25
|
+
* @param props - the component props
|
|
26
|
+
*/
|
|
27
|
+
declare function Slider(props: SliderProps): JSX.Element;
|
|
28
|
+
export default Slider;
|
|
29
|
+
//# sourceMappingURL=slider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../js/common/slider/slider.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAyD,MAAM,cAAc,CAAC;AAI/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,UAAU,WAAY,SAAQ,kBAAkB;IAC5C,4FAA4F;IAC5F,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,8BAA8B;IAC9B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,+CAA+C;IAC/C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB;IACnB,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,8CAA8C;IAC9C,WAAW,EAAE,OAAO,CAAC;IACrB,uBAAuB;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,yCAAyC;IAEzC,KAAK,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;CAC5C;AAID;;;;;GAKG;AACH,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CA2C/C;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import _debounce from 'lodash/debounce';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { injectCss, useAction, useComponentStyles, useVariable } from '@darajs/core';
|
|
5
|
+
import { Slider as UISlider } from '@darajs/ui-components';
|
|
6
|
+
import { useFormContext } from '../context';
|
|
7
|
+
const StyledSlider = injectCss(UISlider);
|
|
8
|
+
/**
|
|
9
|
+
* A component for rendering a slider bar with handles. This component is interactive, so the value of each handle
|
|
10
|
+
* is updated when they are moved.
|
|
11
|
+
*
|
|
12
|
+
* @param props - the component props
|
|
13
|
+
*/
|
|
14
|
+
function Slider(props) {
|
|
15
|
+
const formCtx = useFormContext(props);
|
|
16
|
+
const [style, css] = useComponentStyles(props);
|
|
17
|
+
const [value, setValue] = useVariable(formCtx.resolveInitialValue(props.domain[0]));
|
|
18
|
+
const [onTrack] = useAction(props.onchange);
|
|
19
|
+
const debouncedSetValue = useMemo(() => _debounce(setValue, 300), [setValue]);
|
|
20
|
+
const debouncedOnTrack = useMemo(() => _debounce(onTrack, 300), [onTrack]);
|
|
21
|
+
const debouncedUpdateForm = useMemo(() => _debounce(formCtx.updateForm, 300), [formCtx.updateForm]);
|
|
22
|
+
const isOutputNumber = typeof value === 'number';
|
|
23
|
+
function onChange(values) {
|
|
24
|
+
let serialisedValues = values;
|
|
25
|
+
// if we're supposed to output a number, unwrap the array
|
|
26
|
+
if (isOutputNumber) {
|
|
27
|
+
[serialisedValues] = values;
|
|
28
|
+
}
|
|
29
|
+
debouncedSetValue(serialisedValues);
|
|
30
|
+
debouncedOnTrack === null || debouncedOnTrack === void 0 ? void 0 : debouncedOnTrack(serialisedValues);
|
|
31
|
+
debouncedUpdateForm(serialisedValues);
|
|
32
|
+
}
|
|
33
|
+
// Values passed to the UI component must always be an array
|
|
34
|
+
const parsedValues = isOutputNumber ? [value] : value;
|
|
35
|
+
return (_jsx(StyledSlider, { "$rawCss": css, disableInputAlternative: props.disable_input_alternative, domain: props.domain, onChange: onChange, step: props.step, style: style, ticks: props.ticks, trackLabels: props.rail_labels, trackToEnd: props.rail_to_end, trackToStart: props.rail_from_start, values: parsedValues }));
|
|
36
|
+
}
|
|
37
|
+
export default Slider;
|
|
38
|
+
//# sourceMappingURL=slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../js/common/slider/slider.tsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAY,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAuB5C,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEzC;;;;;GAKG;AACH,SAAS,MAAM,CAAC,KAAkB;IAC9B,MAAM,OAAO,GAAG,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CAAC,KAAK,CAAC;IAEtD,OAAO,CACH,KAAC,YAAY,eACA,GAAG,EACZ,uBAAuB,EAAE,KAAK,CAAC,yBAAyB,EACxD,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,UAAU,EAAE,KAAK,CAAC,WAAW,EAC7B,YAAY,EAAE,KAAK,CAAC,eAAe,EACnC,MAAM,EAAE,YAAY,GACtB,CACL,CAAC;AACN,CAAC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StyledComponentProps } from '@darajs/core';
|
|
2
|
+
interface SpacerProps extends StyledComponentProps {
|
|
3
|
+
className: string;
|
|
4
|
+
inset: string;
|
|
5
|
+
line: boolean;
|
|
6
|
+
size: string;
|
|
7
|
+
}
|
|
8
|
+
declare function Spacer(props: SpacerProps): JSX.Element;
|
|
9
|
+
export default Spacer;
|
|
10
|
+
//# sourceMappingURL=spacer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spacer.d.ts","sourceRoot":"","sources":["../../../js/common/spacer/spacer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAc,oBAAoB,EAAiC,MAAM,cAAc,CAAC;AAG/F,UAAU,WAAY,SAAQ,oBAAoB;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB;AAiCD,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAS/C;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { DisplayCtx, injectCss, useComponentStyles } from '@darajs/core';
|
|
4
|
+
import styled from '@darajs/styled-components';
|
|
5
|
+
const StyledLine = styled.div `
|
|
6
|
+
flex: 0 0 auto;
|
|
7
|
+
|
|
8
|
+
width: ${(p) => (p.isHStack ? '1px' : `calc(100% - 2*${p.inset})`)};
|
|
9
|
+
height: ${(p) => (p.isHStack ? `calc(100% - 2*${p.inset})` : '1px')};
|
|
10
|
+
margin: ${(p) => (p.isHStack ? `${p.inset} 0` : `0 ${p.inset}`)};
|
|
11
|
+
|
|
12
|
+
background-color: ${(p) => p.theme.colors.grey3};
|
|
13
|
+
`;
|
|
14
|
+
const _StyledSpacer = styled.div `
|
|
15
|
+
display: flex;
|
|
16
|
+
flex: 0 0 auto !important;
|
|
17
|
+
align-items: center;
|
|
18
|
+
|
|
19
|
+
${(p) => p.isHStack && 'flex-direction: column; align-self: stretch'};
|
|
20
|
+
${(p) => (p.isHStack ? `width: ${p.size}` : `height:${p.size}`)};
|
|
21
|
+
`;
|
|
22
|
+
const StyledSpacer = injectCss(_StyledSpacer);
|
|
23
|
+
function Spacer(props) {
|
|
24
|
+
const [style, css] = useComponentStyles(props);
|
|
25
|
+
const displayCtx = useContext(DisplayCtx);
|
|
26
|
+
const isHStack = displayCtx.direction === 'horizontal';
|
|
27
|
+
return (_jsx(StyledSpacer, { "$rawCss": css, className: props.className, isHStack: isHStack, size: props.size, style: style, children: props.line && _jsx(StyledLine, { inset: props.inset, isHStack: isHStack }) }));
|
|
28
|
+
}
|
|
29
|
+
export default Spacer;
|
|
30
|
+
//# sourceMappingURL=spacer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spacer.js","sourceRoot":"","sources":["../../../js/common/spacer/spacer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnC,OAAO,EAAE,UAAU,EAAwB,SAAS,EAAE,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AS,KAAK,YAAY,CAAC;IACvD,OAAO,CACH,KAAC,YAAY,eAAU,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,YACrG,KAAK,CAAC,IAAI,IAAI,KAAC,UAAU,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,GAC1D,CAClB,CAAC;AACN,CAAC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentInstance, StyledComponentProps, Variable } from '@darajs/core';
|
|
3
|
+
interface StackProps extends StyledComponentProps {
|
|
4
|
+
children: Array<ComponentInstance>;
|
|
5
|
+
className: string;
|
|
6
|
+
collapsed: Variable<boolean>;
|
|
7
|
+
direction: 'horizontal' | 'vertical';
|
|
8
|
+
hug?: boolean;
|
|
9
|
+
justify?: string;
|
|
10
|
+
scroll: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: import("react").ForwardRefExoticComponent<Omit<StackProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../../js/common/stack/stack.tsx"],"names":[],"mappings":";AAGA,OAAO,EACH,iBAAiB,EAGjB,oBAAoB,EACpB,QAAQ,EAIX,MAAM,cAAc,CAAC;AAKtB,UAAU,UAAW,SAAQ,oBAAoB;IAC7C,QAAQ,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7B,SAAS,EAAE,YAAY,GAAG,UAAU,CAAC;IACrC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACnB;;AAiFD,wBAAiC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
4
|
+
import { DisplayCtx, DynamicComponent, injectCss, useComponentStyles, useVariable, } from '@darajs/core';
|
|
5
|
+
import styled from '@darajs/styled-components';
|
|
6
|
+
function alignStyle(props) {
|
|
7
|
+
if (props.align === 'start') {
|
|
8
|
+
return 'flex-start';
|
|
9
|
+
}
|
|
10
|
+
if (props.align === 'end') {
|
|
11
|
+
return 'flex-end';
|
|
12
|
+
}
|
|
13
|
+
return props.align;
|
|
14
|
+
}
|
|
15
|
+
function getCollapseStyles(collapsed) {
|
|
16
|
+
if (collapsed) {
|
|
17
|
+
return {
|
|
18
|
+
display: 'none',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
const StyledStack = injectCss(styled.div `
|
|
24
|
+
display: flex;
|
|
25
|
+
flex: 1 1 100%;
|
|
26
|
+
flex-direction: ${(props) => (props.direction === 'horizontal' ? 'row' : 'column')};
|
|
27
|
+
gap: 0.75rem;
|
|
28
|
+
|
|
29
|
+
width: ${(props) => (props.direction === 'horizontal' ? undefined : '100%')};
|
|
30
|
+
height: ${(props) => (props.direction === 'horizontal' ? '100%' : undefined)};
|
|
31
|
+
`);
|
|
32
|
+
function Stack(props, ref) {
|
|
33
|
+
const [collapsed] = useVariable(props.collapsed);
|
|
34
|
+
const [style, css] = useComponentStyles(props);
|
|
35
|
+
const stackContent = (_jsx(DisplayCtx.Provider, { value: { component: 'stack', direction: props.direction }, children: props.children.map((child, idx) => (_jsx(DynamicComponent, { component: child }, `stack-${idx}-${child.uid}`))) }));
|
|
36
|
+
return (_jsx(StyledStack, { "$rawCss": css, className: props.className, "data-type": "children-wrapper", direction: props.direction, ref: ref, style: Object.assign(Object.assign({ alignItems: alignStyle(props), justifyContent: props.justify }, getCollapseStyles(collapsed)), style), children: props.scroll ? (_jsx(AutoSizer, { children: ({ height, width }) => {
|
|
37
|
+
var _a;
|
|
38
|
+
return (_jsx("div", { style: {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
flexDirection: props.direction === 'horizontal' ? 'row' : 'column',
|
|
41
|
+
gap: (_a = style.gap) !== null && _a !== void 0 ? _a : '0.75rem',
|
|
42
|
+
height,
|
|
43
|
+
overflow: 'auto',
|
|
44
|
+
width,
|
|
45
|
+
}, children: stackContent }));
|
|
46
|
+
} })) : (stackContent) }));
|
|
47
|
+
}
|
|
48
|
+
export default forwardRef(Stack);
|
|
49
|
+
//# sourceMappingURL=stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../js/common/stack/stack.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AAErD,OAAO,EAEH,UAAU,EACV,gBAAgB,EAGhB,SAAS,EACT,kBAAkB,EAClB,WAAW,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAc/C,SAAS,UAAU,CAAC,KAAiB;IACjC,IAAI,KAAK,CAAC,KAAK,KAAK,OAAO,EAAE;QACzB,OAAO,YAAY,CAAC;KACvB;IACD,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,EAAE;QACvB,OAAO,UAAU,CAAC;KACrB;IACD,OAAO,KAAK,CAAC,KAAK,CAAC;AACvB,CAAC;AAED,SAAS,iBAAiB,CAAC,SAAkB;IACzC,IAAI,SAAS,EAAE;QACX,OAAO;YACH,OAAO,EAAE,MAAM;SAClB,CAAC;KACL;IACD,OAAO,EAAE,CAAC;AACd,CA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AAC,EAC7B,cAAc,EAAE,KAAK,CAAC,OAAO,IAC1B,iBAAiB,CAAC,SAAS,CAAC,GAC5B,KAAK,aAGX,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CACZ,KAAC,SAAS,cACL,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;;gBAAC,OAAA,CACpB,cACI,KAAK,EAAE;wBACH,OAAO,EAAE,MAAM;wBACf,aAAa,EAAE,KAAK,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;wBAClE,GAAG,EAAE,MAAA,KAAK,CAAC,GAAG,mCAAI,SAAS;wBAC3B,MAAM;wBACN,QAAQ,EAAE,MAAM;wBAChB,KAAK;qBACR,YAEA,YAAY,GACX,CACT,CAAA;aAAA,GACO,CACf,CAAC,CAAC,CAAC,CACA,YAAY,CACf,GACS,CACjB,CAAC;AACN,CAAC;AAED,eAAe,UAAU,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Variable } from '@darajs/core';
|
|
2
|
+
import { FormComponentProps } from '../types';
|
|
3
|
+
interface SwitchProps extends FormComponentProps {
|
|
4
|
+
/** Switch position - interactive */
|
|
5
|
+
value?: Variable<boolean>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A component for rendering a switch. Takes an optional label that will be rendered to its left.
|
|
9
|
+
*
|
|
10
|
+
* @param props - the component props
|
|
11
|
+
*/
|
|
12
|
+
declare function Switch(props: SwitchProps): JSX.Element;
|
|
13
|
+
export default Switch;
|
|
14
|
+
//# sourceMappingURL=switch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../js/common/switch/switch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyD,MAAM,cAAc,CAAC;AAK/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAS9C,UAAU,WAAY,SAAQ,kBAAkB;IAC5C,oCAAoC;IAEpC,KAAK,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC7B;AACD;;;;GAIG;AACH,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAiB/C;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { injectCss, useAction, useComponentStyles, useVariable } from '@darajs/core';
|
|
3
|
+
import styled from '@darajs/styled-components';
|
|
4
|
+
import { Switch as UISwitch } from '@darajs/ui-components';
|
|
5
|
+
import { useFormContext } from '../context';
|
|
6
|
+
const _SwitchDiv = styled.div `
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
align-items: center;
|
|
10
|
+
`;
|
|
11
|
+
const SwitchDiv = injectCss(_SwitchDiv);
|
|
12
|
+
/**
|
|
13
|
+
* A component for rendering a switch. Takes an optional label that will be rendered to its left.
|
|
14
|
+
*
|
|
15
|
+
* @param props - the component props
|
|
16
|
+
*/
|
|
17
|
+
function Switch(props) {
|
|
18
|
+
const formCtx = useFormContext(props);
|
|
19
|
+
const [style, css] = useComponentStyles(props);
|
|
20
|
+
const [value, setValue] = useVariable(formCtx.resolveInitialValue());
|
|
21
|
+
const [onChangeAction] = useAction(props.onchange);
|
|
22
|
+
function onChange(enabled) {
|
|
23
|
+
setValue(enabled);
|
|
24
|
+
onChangeAction(enabled);
|
|
25
|
+
formCtx.updateForm(enabled);
|
|
26
|
+
}
|
|
27
|
+
return (_jsx(SwitchDiv, { "$rawCss": css, style: style, children: _jsx(UISwitch, { onChange: onChange, value: value }) }));
|
|
28
|
+
}
|
|
29
|
+
export default Switch;
|
|
30
|
+
//# sourceMappingURL=switch.js.map
|