Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(admin-ui): AutoComplete + MultiAutoComplete components #4459

Open
wants to merge 39 commits into
base: feat/new-admin-ui
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bbaddda
wip: create Command component
leopuleo Dec 3, 2024
5a36aaa
Merge branch 'feat/new-admin-ui' into leo/feat/ui-autocomplete
leopuleo Dec 3, 2024
2c17070
wip: autocomplete
leopuleo Dec 5, 2024
852d882
wip: autocomplete
leopuleo Dec 6, 2024
fbf255e
wip: autocomplete
leopuleo Dec 6, 2024
285bd4f
wip: autocomplete
leopuleo Dec 6, 2024
744d433
wip: autocomplete
leopuleo Dec 6, 2024
6e4d8d3
wip: add generic item and item renderer
leopuleo Dec 6, 2024
01f2901
wip: add xxs and xs button
leopuleo Dec 6, 2024
69cd045
wip: autocomplete compatibility
leopuleo Dec 7, 2024
0c478d0
wip: autocomplete loading
leopuleo Dec 9, 2024
81cbd6c
wip: autocomplete separator
leopuleo Dec 9, 2024
a1c5a1b
feat(admin-ui): add MultiAutoComplete component
leopuleo Dec 9, 2024
3a59ad3
refactor: export component prop types for better reuse
leopuleo Dec 9, 2024
a300707
refactor: update Command import and props usage
leopuleo Dec 9, 2024
87cc5f1
refactor: rename Icon to InputIcon and update styling
leopuleo Dec 9, 2024
64a133f
refactor: reorganize MultiAutoComplete component structure
leopuleo Dec 9, 2024
a487346
refactor: restructure feature files
leopuleo Dec 10, 2024
dfe8200
refactor: update MultiAutoComplete feature for free input
leopuleo Dec 10, 2024
1005fcb
feat(admin-ui): enable custom option creation in MultiAutoComplete
leopuleo Dec 11, 2024
6bad989
refactor(admin-ui): remove unused MultiAutoComplete code
leopuleo Dec 13, 2024
5c80568
feat: add support for temporary options
leopuleo Dec 14, 2024
21ca481
refactor: simplify component naming and structure
leopuleo Dec 14, 2024
df72487
refactor: reorganize primitives into subfolders
leopuleo Dec 14, 2024
778f9dd
feat: extract AutoComplete and MultiAutoComplete lists
leopuleo Dec 14, 2024
e14465d
feat: add support for free input options
leopuleo Dec 14, 2024
de73c77
refactor: add sub-presenters to autocomplete
leopuleo Dec 16, 2024
8227147
feat: add empty list message
leopuleo Dec 16, 2024
255b7f4
Merge branch 'feat/new-admin-ui' into leo/feat/ui-autocomplete
leopuleo Dec 19, 2024
1ffae94
wip: autocomplete
leopuleo Dec 19, 2024
c8338f8
Merge branch 'feat/new-admin-ui' into leo/feat/ui-autocomplete
leopuleo Dec 19, 2024
ecb560c
chore: various + docs
leopuleo Dec 20, 2024
8091244
chore: revert changes
leopuleo Dec 20, 2024
6b68f20
chore: various
leopuleo Dec 20, 2024
f64b8a1
chore: fix build
leopuleo Dec 20, 2024
f3f8a70
chore: various
leopuleo Dec 20, 2024
124ff30
chore: various
leopuleo Dec 20, 2024
a1acaa1
chore: various
leopuleo Dec 20, 2024
b552831
chore: various
leopuleo Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@webiny/utils": "0.0.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"cmdk": "^1.0.4",
"mobx": "^6.9.0",
"react": "18.2.0",
"tailwind-merge": "^2.4.0",
Expand Down
106 changes: 106 additions & 0 deletions packages/admin-ui/src/AutoComplete/AutoComplete.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import React, { useState } from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { AutoComplete } from "./AutoComplete";

const meta: Meta<typeof AutoComplete> = {
title: "Components/Form/AutoComplete",
component: AutoComplete,
tags: ["autodocs"],
argTypes: {
onValueChange: { action: "onValueChange" },
onOpenChange: { action: "onOpenChange" }
},
parameters: {
layout: "padded"
},
render: args => {
const [value, setValue] = useState(args.value);
return <AutoComplete {...args} value={value} onValueChange={setValue} />;
}
};

export default meta;
type Story = StoryObj<typeof AutoComplete>;

export const Default: Story = {
args: {
options: [
"Eastern Standard Time (EST)",
"Central Standard Time (CST)",
"Pacific Standard Time (PST)",
"Greenwich Mean Time (GMT)",
"Central European Time (CET)",
"Central Africa Time (CAT)",
"India Standard Time (IST)",
"China Standard Time (CST)",
"Japan Standard Time (JST)",
"Australian Western Standard Time (AWST)",
"New Zealand Standard Time (NZST)",
"Fiji Time (FJT)",
"Argentina Time (ART)",
"Bolivia Time (BOT)",
"Brasilia Time (BRT)"
]
}
};

export const WithLabel: Story = {
args: {
...Default.args,
label: "Any field label"
}
};

export const WithRequiredLabel: Story = {
args: {
...Default.args,
label: "Any field label",
required: true
}
};

export const WithDescription: Story = {
args: {
...Default.args,
description: "Provide the required information for processing your request."
}
};

export const WithNotes: Story = {
args: {
...Default.args,
note: "Note: Ensure your selection or input is accurate before proceeding."
}
};

export const WithErrors: Story = {
args: {
...Default.args,
validation: {
isValid: false,
message: "This field is required."
}
}
};

export const Disabled: Story = {
args: {
...Default.args,
label: "Any field label",
disabled: true
}
};

export const FullExample: Story = {
args: {
...Default.args,
label: "Any field label",
required: true,
description: "Provide the required information for processing your request.",
note: "Note: Ensure your selection or input is accurate before proceeding.",
validation: {
isValid: false,
message: "This field is required."
}
}
};
42 changes: 42 additions & 0 deletions packages/admin-ui/src/AutoComplete/AutoComplete.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { useMemo } from "react";
import { makeDecoratable } from "~/utils";
import {
AutoCompletePrimitive,
AutoCompletePrimitiveProps
} from "./primitives/AutoCompletePrimitive";
import {
FormComponentDescription,
FormComponentErrorMessage,
FormComponentLabel,
FormComponentNote,
FormComponentProps
} from "~/FormComponent";

type AutoCompleteProps = AutoCompletePrimitiveProps & FormComponentProps;

const DecoratableAutoComplete = ({
label,
description,
note,
required,
disabled,
validation,
...props
}: AutoCompleteProps) => {
const { isValid: validationIsValid, message: validationMessage } = validation || {};
const invalid = useMemo(() => validationIsValid === false, [validationIsValid]);

return (
<div className={"w-full"}>
<FormComponentLabel text={label} required={required} disabled={disabled} />
<FormComponentDescription text={description} />
<AutoCompletePrimitive {...props} disabled={disabled} label={label} />
<FormComponentErrorMessage text={validationMessage} invalid={invalid} />
<FormComponentNote text={note} />
</div>
);
};

const AutoComplete = makeDecoratable("AutoComplete", DecoratableAutoComplete);

export { AutoComplete };
2 changes: 2 additions & 0 deletions packages/admin-ui/src/AutoComplete/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./AutoComplete";
export * from "./primitives/AutoCompletePrimitive";
Loading
Loading