listpage-next 0.0.125 → 0.0.127

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.
@@ -11,7 +11,8 @@ export interface FilterFormOption {
11
11
  export interface FilterFormProps<FormValue = any> {
12
12
  options: FilterFormOption[];
13
13
  initialValues?: FormValue;
14
+ labelInline?: boolean;
14
15
  onSubmit?: (values?: FormValue) => void;
15
16
  onReset?: () => void;
16
17
  }
17
- export declare const FilterForm: <T = any>({ options, initialValues, onSubmit, onReset, }: FilterFormProps<T>) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const FilterForm: <T = any>({ options, initialValues, onSubmit, onReset, labelInline, }: FilterFormProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -6,13 +6,14 @@ import { FilterGridLayout } from "../FilterGridLayout/index.js";
6
6
  import { FilterItem } from "../FilterItem/index.js";
7
7
  import { getComponent } from "../../utils/getComponent.js";
8
8
  import { cleanUpFormValues } from "../../utils/format.js";
9
- const FilterForm = ({ options, initialValues, onSubmit, onReset })=>{
9
+ const FilterForm = ({ options, initialValues, onSubmit, onReset, labelInline })=>{
10
10
  const formRef = useRef(null);
11
11
  const items = useMemo(()=>(options ?? []).map(({ colSpan, component, label, ...props })=>{
12
12
  const renderComponent = getComponent(component);
13
13
  return {
14
14
  key: props.name,
15
15
  node: /*#__PURE__*/ jsx(FilterItem, {
16
+ labelInline: labelInline,
16
17
  label: label,
17
18
  formItemProps: props,
18
19
  children: renderComponent
@@ -4,8 +4,8 @@ import styled_components from "styled-components";
4
4
  const GridContainer = styled_components.div`
5
5
  display: grid;
6
6
  grid-template-columns: repeat(12, 1fr);
7
- row-gap: 0;
8
7
  column-gap: 1rem;
8
+ row-gap: 1rem;
9
9
  `;
10
10
  const GridItem = styled_components.div`
11
11
  grid-column: span ${(props)=>props.$colSpan};
@@ -4,5 +4,6 @@ export interface FilterItemProps {
4
4
  label?: ReactNode;
5
5
  children: ReactElement;
6
6
  formItemProps: FormItemProps;
7
+ labelInline?: boolean;
7
8
  }
8
9
  export declare const FilterItem: (props: FilterItemProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,10 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Form, Input } from "antd";
3
- import { LabelWrapper } from "../LabelWrapper/index.js";
3
+ import { LabelInline, LabelWrapper } from "../LabelWrapper/index.js";
4
4
  import { cloneElement, useState } from "react";
5
5
  import { omit } from "lodash";
6
6
  const FilterItem = (props)=>{
7
- const { label, children, formItemProps } = props;
7
+ const { label, children, formItemProps, labelInline } = props;
8
8
  const [focus, setFocus] = useState(false);
9
9
  return /*#__PURE__*/ jsxs(Fragment, {
10
10
  children: [
@@ -37,6 +37,12 @@ const FilterItem = (props)=>{
37
37
  });
38
38
  const disabled = children.props.disabled;
39
39
  const status = disabled ? 'disabled' : focus ? 'focused' : errors?.length ? 'error' : void 0;
40
+ if (labelInline) return /*#__PURE__*/ jsx(LabelInline, {
41
+ status: status,
42
+ errors: errors,
43
+ label: label,
44
+ children: realChildren
45
+ });
40
46
  return /*#__PURE__*/ jsx(LabelWrapper, {
41
47
  status: status,
42
48
  errors: errors,
@@ -6,3 +6,4 @@ export interface LabelWrapperProps<V = any> {
6
6
  errors?: string[];
7
7
  }
8
8
  export declare const LabelWrapper: <T = any>({ label, status, children, errors, }: LabelWrapperProps<T>) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const LabelInline: <T = any>({ label, status, children, errors, }: LabelWrapperProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,39 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Tooltip } from "antd";
2
3
  import styled_components from "styled-components";
3
4
  const WrapperContainer = styled_components.div`
4
5
  position: relative;
5
- margin-bottom: 1.5rem;
6
+ // margin-bottom: 1.5rem;
6
7
  `;
7
8
  const ChildrenContainer = styled_components.div`
8
9
  & > div {
9
10
  width: 100%;
10
11
  }
11
12
  `;
13
+ const InlineLabelWrapperContainer = styled_components.div`
14
+ display: flex;
15
+ gap: 0.5rem;
16
+ align-items: center;
17
+ `;
18
+ const InlineLabelChildrenContainer = styled_components.div`
19
+ flex-grow: 1;
20
+ flex-shrink: 1;
21
+
22
+ & > * {
23
+ width: 100%;
24
+ }
25
+ `;
26
+ const InlineLabel = styled_components.label`
27
+ font-size: 14px;
28
+ font-weight: 400;
29
+ flex-shrink: 0;
30
+ color: ${(props)=>{
31
+ if ('disabled' === props.$status) return '#9ca3af';
32
+ if ('error' === props.$status) return '#ef4444';
33
+ if ('focused' === props.$status) return '#3b82f6';
34
+ return '#374151';
35
+ }};
36
+ `;
12
37
  const Label = styled_components.label`
13
38
  position: absolute;
14
39
  left: 1rem;
@@ -62,4 +87,21 @@ const LabelWrapper = ({ label, status, children, errors = [] })=>/*#__PURE__*/ j
62
87
  })
63
88
  ]
64
89
  });
65
- export { LabelWrapper };
90
+ const LabelInline = ({ label, status, children, errors = [] })=>/*#__PURE__*/ jsxs(InlineLabelWrapperContainer, {
91
+ children: [
92
+ /*#__PURE__*/ jsx(Tooltip, {
93
+ title: errors?.length > 0 && /*#__PURE__*/ jsx(ErrorMessage, {
94
+ children: errors.join(', ')
95
+ }),
96
+ children: /*#__PURE__*/ jsx(InlineLabel, {
97
+ htmlFor: "label",
98
+ $status: status,
99
+ children: label
100
+ })
101
+ }),
102
+ /*#__PURE__*/ jsx(InlineLabelChildrenContainer, {
103
+ children: children
104
+ })
105
+ ]
106
+ });
107
+ export { LabelInline, LabelWrapper };
@@ -37,6 +37,7 @@ const Demo1 = ()=>{
37
37
  console.log(values);
38
38
  };
39
39
  return /*#__PURE__*/ jsx(FilterForm, {
40
+ labelInline: true,
40
41
  options: options,
41
42
  onSubmit: onSubmit
42
43
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.125",
3
+ "version": "0.0.127",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",