diff --git a/src/primevue/index.ts b/src/primevue/index.ts index af3a38f..1dc283b 100644 --- a/src/primevue/index.ts +++ b/src/primevue/index.ts @@ -15,6 +15,7 @@ import radioButton from "./radioButton/radioButton"; import autocomplete from "./autocomplete/autocomplete"; import textarea from "./textarea/textarea"; import toast from "./toast/toast"; +import inputMask from "./inputMask/inputMask"; import { deDE } from "@/config/locale"; @@ -34,6 +35,7 @@ export const RisUiTheme = { textarea, toast, autocomplete, + inputMask, }; export const RisUiLocale = { diff --git a/src/primevue/inputMask/inputMask.stories.ts b/src/primevue/inputMask/inputMask.stories.ts new file mode 100644 index 0000000..ee2c326 --- /dev/null +++ b/src/primevue/inputMask/inputMask.stories.ts @@ -0,0 +1,189 @@ +import { Meta, StoryObj } from "@storybook/vue3"; +import InputMask from "primevue/inputmask"; +import { html } from "@/lib/tags"; +import Fluid from "primevue/fluid"; +import { ref } from "vue"; +import ErrorOutline from "~icons/material-symbols/error-outline"; + +const meta: Meta = { + component: InputMask, + + tags: ["autodocs"], + + args: { + disabled: false, + fluid: false, + placeholder: "TT.MM.JJJJ", + mask: "99.99.9999", + readOnly: false, + invalid: false, + }, +}; + +export default meta; +type Story = StoryObj; + +export const Default: StoryObj = { + args: { + modelValue: "12.12.2023", + }, + render: (args) => ({ + components: { InputMask }, + setup() { + return { args }; + }, + template: html` `, + }), +}; + +export const WithLabelAndHint: StoryObj = { + render: (args) => ({ + components: { InputMask }, + setup() { + return { args }; + }, + template: html`
+ + + Additional hint text +
`, + }), +}; + +export const WithHorizontalLabel: StoryObj = { + render: (args) => ({ + components: { InputMask }, + setup() { + return { args }; + }, + template: html`
+ + +
`, + }), +}; + +export const Disabled: StoryObj = { + args: { + disabled: true, + }, + + render: (args) => ({ + components: { InputMask }, + setup() { + return { args }; + }, + template: html``, + }), +}; + +export const Readonly: StoryObj = { + args: { + readonly: true, + }, + + render: (args) => ({ + components: { InputMask }, + setup() { + return { args }; + }, + template: html``, + }), +}; + +export const Invalid: StoryObj = { + args: { + invalid: true, + }, + + render: (args) => ({ + components: { InputMask, ErrorOutline }, + setup() { + return { args }; + }, + template: html`
+ + Invalid date +
`, + }), +}; + +export const StartWithEndDate: Story = { + render: (args) => ({ + components: { InputMask }, + setup() { + const startDate = ref(""); + const endDate = ref(""); + return { args, startDate, endDate }; + }, + template: html` +
+
+ +
+ +
+ +
+
+ `, + }), +}; + +export const ThreeFields: StoryObj = { + render: (args) => ({ + components: { InputMask }, + setup() { + const day = ref(""); + const month = ref(""); + const year = ref(""); + + return { args, day, month, year }; + }, + template: html` +
+ +
+
+ +
+
+ +
+ +
+ +
+
+
+ `, + }), +}; +export const FluidProp: StoryObj = { + args: { + fluid: true, + }, + + render: (args) => ({ + components: { InputMask, Fluid }, + setup() { + return { args }; + }, + template: html``, + }), +}; diff --git a/src/primevue/inputMask/inputMask.ts b/src/primevue/inputMask/inputMask.ts new file mode 100644 index 0000000..0f913f4 --- /dev/null +++ b/src/primevue/inputMask/inputMask.ts @@ -0,0 +1,21 @@ +import { InputMaskPassThroughOptions } from "primevue/inputmask"; +import { tw } from "@/lib/tags.ts"; +import { base, small } from "../inputText/inputText"; + +const fluid = tw`w-full`; + +const inputMask: InputMaskPassThroughOptions = { + pcInputText: { + root: ({ props }) => { + return { + class: { + [base]: true, + [small]: true, + [fluid]: !!props.fluid, + }, + }; + }, + }, +}; + +export default inputMask; diff --git a/src/primevue/inputText/inputText.ts b/src/primevue/inputText/inputText.ts index 695751d..369cb79 100644 --- a/src/primevue/inputText/inputText.ts +++ b/src/primevue/inputText/inputText.ts @@ -2,7 +2,7 @@ import { tw } from "@/lib/tags"; import { InputTextPassThroughOptions } from "primevue/inputtext"; import "./inputText.css"; // Base -export const base = tw`border-2 border-blue-800 bg-white outline-4 -outline-offset-4 outline-blue-800 placeholder:text-gray-900 read-only:cursor-not-allowed read-only:border-blue-300 read-only:bg-blue-300 hover:outline focus:outline disabled:border-blue-500 disabled:bg-white disabled:text-blue-500 disabled:outline-none aria-[invalid]:border-red-800 aria-[invalid]:bg-red-200 aria-[invalid]:outline-red-800 aria-[invalid]:disabled:outline-none`; +export const base = tw`border-2 border-blue-800 bg-white outline-4 -outline-offset-4 outline-blue-800 placeholder:text-gray-600 read-only:cursor-not-allowed read-only:border-blue-300 read-only:bg-blue-300 hover:outline focus:outline disabled:border-blue-500 disabled:bg-white disabled:text-blue-500 disabled:outline-none aria-[invalid]:border-red-800 aria-[invalid]:bg-red-200 aria-[invalid]:outline-red-800 aria-[invalid]:disabled:outline-none`; // Sizes export const small = tw`ris-body2-regular h-48 px-16 py-4`;