Skip to content

Commit

Permalink
Merge pull request #1187 from Wizleap-Inc/feat/1184_input
Browse files Browse the repository at this point in the history
(Vue, React) base-inputを内部で使っているコンポーネントから、ComponentProps<"input">のプロパティを公開する
  • Loading branch information
ichi-h authored Jan 25, 2024
2 parents d63ece2 + 3548d63 commit ad75b4c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/slow-insects-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wizleap-inc/wiz-ui-react": patch
"@wizleap-inc/wiz-ui-next": patch
---

[#1184] base-input の focusin, focusout の Event を受け取れるように修正
15 changes: 13 additions & 2 deletions packages/wiz-ui-next/src/components/base/inputs/base/base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
:placeholder="placeholder"
:disabled="disabled"
:type="type"
@focusin="hasFocus = true"
@focusout="hasFocus = false"
@focusin="onFocusIn"
@focusout="onFocusOut"
v-model="textValue"
:id="id"
:autocomplete="autocomplete"
Expand Down Expand Up @@ -80,6 +80,8 @@ const props = defineProps({
interface Emit {
(e: "update:modelValue", value: string): void;
(e: "focusin", value: FocusEvent): void;
(e: "focusout", value: FocusEvent): void;
}
const emit = defineEmits<Emit>();
Expand All @@ -98,4 +100,13 @@ const state = computed(() => {
if (hasFocus.value) return "active";
return "default";
});
const onFocusIn = (e: FocusEvent) => {
hasFocus.value = true;
emit("focusin", e);
};
const onFocusOut = (e: FocusEvent) => {
hasFocus.value = false;
emit("focusout", e);
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
:type="isPasswordVisible ? 'text' : 'password'"
:autocomplete="autocomplete"
space-type="right"
@focusin="onFocusIn"
@focusout="onFocusOut"
/>
<button
type="button"
Expand Down Expand Up @@ -48,6 +50,8 @@ defineOptions({
interface Emit {
(e: "update:modelValue", value: string): void;
(e: "focusin", value: FocusEvent): void;
(e: "focusout", value: FocusEvent): void;
}
const props = defineProps({
Expand Down Expand Up @@ -98,4 +102,8 @@ const computedExpand = computed(() => (props.expand ? "expand" : "default"));
// Form Control
const form = inject(formControlKey);
const isError = computed(() => (form ? form.isError.value : false));
const onFocusIn = (e: FocusEvent) => emit("focusin", e);
const onFocusOut = (e: FocusEvent) => emit("focusout", e);
</script>
7 changes: 7 additions & 0 deletions packages/wiz-ui-next/src/components/base/inputs/text/text.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
type="text"
:space-type="icon ? 'left' : 'none'"
:autocomplete="autocomplete"
@focusin="onFocusIn"
@focusout="onFocusOut"
/>
</div>
</template>
Expand Down Expand Up @@ -72,6 +74,8 @@ const props = defineProps({
});
interface Emit {
(e: "update:modelValue", value: string): void;
(e: "focusin", value: FocusEvent): void;
(e: "focusout", value: FocusEvent): void;
}
const emit = defineEmits<Emit>();
Expand All @@ -86,4 +90,7 @@ const form = inject(formControlKey);
const isError = computed(() => (form ? form.isError.value : false));
const computedExpand = computed(() => (props.expand ? "expand" : "default"));
const onFocusIn = (e: FocusEvent) => emit("focusin", e);
const onFocusOut = (e: FocusEvent) => emit("focusout", e);
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {
} from "@wizleap-inc/wiz-ui-constants";
import * as styles from "@wizleap-inc/wiz-ui-styles/bases/password-input.css";
import clsx from "clsx";
import { forwardRef, useContext, useState } from "react";
import { ComponentProps, forwardRef, useContext, useState } from "react";

import { WizIEye } from "@/components";
import { FormControlContext } from "@/components/custom/form/components/form-control-context";
import { BaseProps } from "@/types";

import { PrivateBaseInput } from "../../base";

type PrivateBaseInputProps = ComponentProps<typeof PrivateBaseInput>;
type Props = BaseProps & {
id?: string;
value: string;
Expand All @@ -23,7 +24,7 @@ type Props = BaseProps & {
autocomplete?: Extract<AutoCompleteKeys, "currentPassword" | "newPassword">;
error?: boolean;
onChange: (value: string) => void;
};
} & Omit<PrivateBaseInputProps, "onChange">;

const PasswordInput = forwardRef<HTMLInputElement, Props>(
(
Expand All @@ -39,6 +40,7 @@ const PasswordInput = forwardRef<HTMLInputElement, Props>(
autocomplete = "off",
error,
onChange,
...props
},
ref
) => {
Expand Down Expand Up @@ -69,6 +71,7 @@ const PasswordInput = forwardRef<HTMLInputElement, Props>(
autoComplete={autocomplete}
space-type="right"
onChange={(e) => onChange(e.target.value)}
{...props}
/>
<button
type="button"
Expand Down

2 comments on commit ad75b4c

@vercel
Copy link

@vercel vercel bot commented on ad75b4c Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wiz-ui-react – ./packages/wiz-ui-react

wiz-ui-react-git-main-wizleap.vercel.app
wiz-ui-react-wizleap.vercel.app
wiz-ui-react.vercel.app

@vercel
Copy link

@vercel vercel bot commented on ad75b4c Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wiz-ui-next – ./packages/wiz-ui-next

wiz-ui-next-wizleap.vercel.app
wiz-ui-next-git-main-wizleap.vercel.app
wiz-ui-next.vercel.app

Please sign in to comment.