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

perf: formApi added validateAndSubmitForm & filedMapToTime renamed fieldMappingTime #4842

Merged
merged 3 commits into from
Nov 9, 2024

Conversation

anncwb
Copy link
Collaborator

@anncwb anncwb commented Nov 9, 2024

Description

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced fieldMappingTime configuration for enhanced date handling in forms.
    • Added submitAndValidateForm method for improved form submission with validation.
  • Improvements

    • Updated documentation for the Vben Form component, including new examples and clearer explanations.
    • Enhanced date formatting utilities with formatDate and formatDateTime functions.
  • Bug Fixes

    • Corrected import path for the FormModalDemo component to ensure proper functionality.
  • Refactor

    • Renamed variables for clarity and improved consistency in the form actions component.

@anncwb anncwb requested review from vince292007 and a team as code owners November 9, 2024 06:48
Copy link

changeset-bot bot commented Nov 9, 2024

⚠️ No Changeset found

Latest commit: 348d0ee

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Nov 9, 2024

Warning

Rate limit exceeded

@anncwb has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 48 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between caf2cc4 and 348d0ee.

Walkthrough

The changes in this pull request primarily focus on enhancing the documentation and functionality of the Vben Form component, along with updates to related utilities and components. Key modifications include the addition of new properties and methods, such as fieldMappingTime and submitAndValidateForm, improvements to date formatting utilities, and refinements in the handling of form submissions and validations. The documentation has been expanded to provide clearer guidance on using these features, along with example code snippets to aid developers.

Changes

File Change Summary
docs/src/components/common-ui/vben-form.md Updated documentation for Vben Form component, added explanations for adapters, example code snippets, expanded API section, and clarified form validation and dependencies.
packages/@core/base/shared/package.json Added new dependency: "dayjs": "^1.11.13" under dependencies.
packages/@core/base/shared/src/utils/date.ts Introduced formatDate and formatDateTime functions for enhanced date formatting using dayjs.
packages/@core/base/shared/src/utils/index.ts Added export for date utilities: export * from './date';.
packages/@core/ui-kit/form-ui/src/components/form-actions.vue Added formatDate utility, renamed variable fieldMapToTime to fieldMappingTime, updated reset logic, and removed formatTime function.
packages/@core/ui-kit/form-ui/src/form-api.ts Added submitAndValidateForm method to FormApi, modified submitForm for event handling, and refined updateState method.
packages/@core/ui-kit/form-ui/src/types.ts Renamed type FieldMapToTime to FieldMappingTime and added fieldMappingTime property to VbenFormProps interface.
packages/effects/plugins/src/vxe-table/extends.ts Updated date formatting in extendsDefaultFormatter to use formatDate and formatDateTime instead of dayjs.
playground/src/views/examples/form/basic.vue Introduced fieldMappingTime configuration in useVbenForm call for BaseForm.
playground/src/views/examples/modal/form-modal-demo.vue Updated modal form submission to use submitAndValidateForm instead of submitForm.
playground/src/views/examples/modal/index.vue Corrected import path for FormModalDemo component.
playground/src/views/examples/vxe-table/form.vue Removed fieldMapToTime property and eliminated dateRangePicker schema entry, simplifying the form.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • vince292007

🐰 In the meadow where forms do play,
New features hop in, brightening the day.
With fieldMappingTime and validation so neat,
Our forms dance and twirl, oh what a treat!
So gather 'round, let the changes unfold,
In the world of Vben, new stories are told! 🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (11)
packages/@core/base/shared/src/utils/date.ts (3)

1-1: Consider optimizing the dayjs import.

For better tree-shaking and reduced bundle size, consider importing only the required functionality from dayjs.

-import dayjs from 'dayjs';
+import dayjs from 'dayjs/esm';

7-9: Consider making the datetime format configurable.

The function provides a good standard format, but consider making it configurable through an optional parameter for flexibility.

-export function formatDateTime(time: number | string) {
-  return formatDate(time, 'YYYY-MM-DD HH:mm:ss');
+export function formatDateTime(
+  time: number | string,
+  format = 'YYYY-MM-DD HH:mm:ss'
+) {
+  return formatDate(time, format);
 }

1-9: Add JSDoc documentation and unit tests.

While the implementation is clean, please consider adding:

  1. JSDoc documentation for both functions describing parameters, return values, and examples
  2. Unit tests covering various scenarios including edge cases

Would you like me to help generate the documentation and unit test templates?

packages/@core/base/shared/package.json (1)

87-87: Consider using catalog versioning for dayjs.

While adding dayjs is appropriate for date formatting utilities, consider using "catalog:" instead of "^1.11.13" to maintain consistent version management with other dependencies in the monorepo.

packages/@core/ui-kit/form-ui/src/components/form-actions.vue (2)

86-92: Consider making the date format more configurable.

The hardcoded default format 'YYYY-MM-DD' might be too restrictive. Consider:

  1. Moving it to a constant or configuration
  2. Making it injectable through props

105-108: LGTM! Consider memoizing formatted dates.

The date formatting implementation is clean and consistent. However, for performance optimization, consider memoizing the formatted dates if they're used in multiple places or if the component re-renders frequently.

playground/src/views/examples/form/basic.vue (1)

19-22: Add documentation for the fieldMappingTime configuration.

While the configuration is valid, adding a comment would improve maintainability by explaining:

  • The purpose of the mapping
  • The expected input/output format
  • The relationship between rangePicker and the mapped fields

Consider applying this change:

+  // Maps the rangePicker field to separate startTime and endTime fields
+  // Input: rangePicker array with 2 dates
+  // Output: { startTime: 'YYYY-MM-DD', endTime: 'YYYY-MM-DD' }
   fieldMappingTime: [['rangePicker', ['startTime', 'endTime'], 'YYYY-MM-DD']],

Additionally, consider extracting the date format string into a constant to maintain consistency across the codebase.

packages/@core/ui-kit/form-ui/src/types.ts (1)

Line range hint 209-213: Add JSDoc comments to improve type documentation.

The FieldMappingTime type appears to be used for mapping time-related fields, but its purpose and structure could be clearer with proper documentation.

Add JSDoc comments to explain the purpose and structure:

+/**
+ * Type for mapping a single field into two time fields (e.g., start/end times)
+ * @example
+ * [
+ *   // Maps 'timeRange' field into 'startTime' and 'endTime' with 'HH:mm' format
+ *   ['timeRange', ['startTime', 'endTime'], ['HH:mm', 'HH:mm']]
+ * ]
+ */
export type FieldMappingTime = [
  string,
  [string, string],
  ([string, string] | string)?,
][];
packages/@core/ui-kit/form-ui/src/form-api.ts (1)

245-252: LGTM! Consider adding JSDoc documentation.

The implementation of submitAndValidateForm is clean and follows good practices by validating before submission. However, it would benefit from JSDoc documentation to describe its purpose, return type, and behavior.

Add documentation like this:

+/**
+ * Validates the form and submits it if validation passes.
+ * @returns {Promise<Record<string, any> | undefined>} The form values if validation and submission succeed, undefined otherwise.
+ */
async submitAndValidateForm() {
docs/src/components/common-ui/vben-form.md (2)

283-283: Enhance documentation for submitAndValidateForm method.

The description for the new submitAndValidateForm method could be more detailed. Consider:

  1. Explaining how it differs from the existing submitForm method
  2. Clarifying the validation process and when it occurs
  3. Providing an example usage snippet
  4. Documenting the expected behavior when validation fails

Consider expanding the description like this:

-| submitAndValidateForm | 提交并校验表单 | `(e:Event)=>Promise<Record<string,any>>` |
+| submitAndValidateForm | 提交并校验表单。在提交前进行表单验证,只有验证通过才会提交表单。验证失败时会返回rejected promise。 | `(e:Event)=>Promise<Record<string,any>>` |

313-313: Improve documentation for fieldMappingTime property.

The description and type information for the new fieldMappingTime property needs enhancement:

  1. The type [string, [string, string], string?][] is complex and needs explanation
  2. The current description doesn't fully explain the mapping behavior
  3. Missing example usage

Consider expanding the documentation like this:

-| fieldMappingTime | 用于将表单内时间区域的应设成 2 个字段 | `[string, [string, string], string?][]` | - |
+| fieldMappingTime | 用于将表单内时间区域映射成 2 个独立字段。每个映射配置包含:源字段名、目标字段名数组[开始时间字段, 结束时间字段]、可选的日期格式。例如:`[['dateRange', ['startDate', 'endDate'], 'YYYY-MM-DD']]` 会将 dateRange 字段的值分别映射到 startDate 和 endDate 字段。 | `[string, [string, string], string?][]` | - |

Also consider adding a code example in the documentation:

// Example usage
const [Form, formApi] = useVbenForm({
  fieldMappingTime: [
    // Maps dateRange field to startDate and endDate
    ['dateRange', ['startDate', 'endDate'], 'YYYY-MM-DD'],
    // Maps timeRange field to from and to
    ['timeRange', ['from', 'to'], 'HH:mm:ss']
  ]
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 632081e and caf2cc4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • docs/src/components/common-ui/vben-form.md (2 hunks)
  • packages/@core/base/shared/package.json (1 hunks)
  • packages/@core/base/shared/src/utils/date.ts (1 hunks)
  • packages/@core/base/shared/src/utils/index.ts (1 hunks)
  • packages/@core/ui-kit/form-ui/src/components/form-actions.vue (4 hunks)
  • packages/@core/ui-kit/form-ui/src/form-api.ts (1 hunks)
  • packages/@core/ui-kit/form-ui/src/types.ts (2 hunks)
  • packages/effects/plugins/src/vxe-table/extends.ts (2 hunks)
  • playground/src/views/examples/form/basic.vue (1 hunks)
  • playground/src/views/examples/modal/form-modal-demo.vue (1 hunks)
  • playground/src/views/examples/modal/index.vue (1 hunks)
  • playground/src/views/examples/vxe-table/form.vue (0 hunks)
💤 Files with no reviewable changes (1)
  • playground/src/views/examples/vxe-table/form.vue
✅ Files skipped from review due to trivial changes (1)
  • playground/src/views/examples/modal/index.vue
🔇 Additional comments (12)
packages/@core/base/shared/src/utils/index.ts (2)

2-2: LGTM! Export statement follows proper conventions.

The new export statement is correctly placed in alphabetical order and follows the same pattern as other exports.


2-2: Verify the date module integration.

Let's verify the existence of the date module and its usage in the form API changes.

✅ Verification successful

Let me check the actual content of these files to verify the integration properly.


Date module integration is properly implemented and used

The date module exports two utility functions (formatDate and formatDateTime) and is correctly integrated in the codebase:

  • The module exists at the correct location
  • It provides date formatting functionality using dayjs
  • It's properly imported and used in form-actions.vue for formatting start and end times
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the date module integration

# Test 1: Check if date.ts exists in the utils directory
echo "Checking for date.ts file..."
fd --type f "date.ts" "packages/@core/base/shared/src/utils"

# Test 2: Search for usage of date formatting functions in form-related files
echo "Checking usage of date formatting functions..."
rg -l "formatDate|formatDateTime" "packages" | grep -i "form"

Length of output: 395


Script:

#!/bin/bash
# Check the content of date.ts and its usage in form-actions.vue
echo "Content of date.ts:"
cat packages/@core/base/shared/src/utils/date.ts

echo -e "\nUsage in form-actions.vue:"
rg "formatDate|formatDateTime" packages/@core/ui-kit/form-ui/src/components/form-actions.vue -C 2

Length of output: 800

packages/effects/plugins/src/vxe-table/extends.ts (2)

54-56: Verify date format consistency with previous implementation.

The implementation is cleaner, but we should ensure that formatDate and formatDateTime maintain the same format as before (YYYY-MM-DD and YYYY-MM-DD HH:mm:ss respectively).

Let's verify the format strings used in these utility functions:

#!/bin/bash
# Description: Verify the date format strings used in the utility functions

# Test: Search for format string definitions in the utility functions
rg -B 5 -A 5 'YYYY-MM-DD' --type ts

Also applies to: 60-62


5-5: LGTM! Verify utility function implementations.

The change to use utility functions instead of direct dayjs usage is a good architectural decision that can help reduce bundle size and provide better abstraction.

Let's verify the implementation of these utility functions:

✅ Verification successful

Verified: Date formatting utilities are properly implemented

The verification shows that:

  • The formatDate and formatDateTime functions are properly implemented in packages/@core/base/shared/src/utils/date.ts
  • They use dayjs internally with correct format patterns
  • The functions are correctly exported from @vben/utils and imported in the VXE table extension
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of formatDate and formatDateTime utilities

# Test: Check the implementation of date formatting utilities
rg -A 10 "export function format(Date|DateTime)" --type ts

Length of output: 2586


Script:

#!/bin/bash
# Let's verify the implementation of formatDate and formatDateTime utilities with a more precise search
rg -A 5 "^export function format(Date|DateTime)" --type ts

# Also check where these utilities are imported from @vben/utils
rg -A 2 "from '@vben/utils'" --type ts

Length of output: 6108

playground/src/views/examples/modal/form-modal-demo.vue (2)

60-61: Clarify the intention behind commented modal close.

The modalApi.close() is commented out, which might lead to a poor user experience as the modal will stay open even after successful submission. If this is intentional (e.g., for showing submission feedback), consider adding a comment explaining the rationale. Otherwise, it should be uncommented and wrapped in proper error handling as suggested above.


60-61: Verify the existence of submitAndValidateForm method.

Let's ensure this new method is properly exported from the form API.

✅ Verification successful

The submitAndValidateForm method exists and is properly implemented

The method is correctly implemented in the FormApi class and performs validation before submission:

  1. It first validates the form using form.validate()
  2. If validation passes, it calls submitForm()
  3. If validation fails, it returns early

The commented-out modalApi.close() should be handled based on the submission result:

  • On success: Modal should close
  • On validation failure: Modal should stay open

Example usage:

const result = await formApi.submitAndValidateForm();
if (result) {
  modalApi.close();
}
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and implementation of submitAndValidateForm
# Expected: Find the method definition in the form API files

# Search for the method definition
ast-grep --pattern 'submitAndValidateForm' 

Length of output: 42


Script:

#!/bin/bash
# Let's try a more comprehensive search using ripgrep to find any occurrences
# of submitAndValidateForm in the codebase
rg -l "submitAndValidateForm"

# Also search for similar method names that might be related
rg -l "submitForm|validateForm"

# Let's also check the actual implementation of the form API
fd -e ts -e js -e vue "form.*api" 

Length of output: 551


Script:

#!/bin/bash
# Let's check the implementation of submitAndValidateForm in the form API
cat packages/@core/ui-kit/form-ui/src/form-api.ts

# Also check the test file to understand the expected behavior
cat packages/@core/ui-kit/form-ui/__tests__/form-api.test.ts

Length of output: 13096

packages/@core/base/shared/package.json (1)

87-87: Verify the impact on bundle size.

The addition of dayjs as a new dependency might affect the bundle size. Consider using tree-shaking to import only the required functionality.

✅ Verification successful

Let me analyze the import patterns and dependency versions to better understand the tree-shaking situation and provide a more informed response.


Tree-shaking is already properly implemented for dayjs

The codebase shows proper tree-shaking practices for dayjs:

  • Dynamic imports are used for locale files (import('dayjs/locale/en'))
  • Specific plugin imports when needed (import timezone from 'dayjs/plugin/timezone')
  • Simple imports for basic functionality (import dayjs from 'dayjs')

Additionally, dayjs is already a dependency across multiple packages in the monorepo, and this addition in @core/base/shared follows the established pattern. The library itself is relatively lightweight (~2KB gzipped), and the current usage demonstrates good practices for minimizing bundle size.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the size impact of dayjs
# Look for existing dayjs imports in the codebase to understand usage patterns
rg -l 'import.*dayjs' 

# Check if dayjs is already a dependency in other packages
fd -t f 'package.json' -x grep -l 'dayjs'

Length of output: 593


Script:

#!/bin/bash
# Check how dayjs is being imported in the files to verify tree-shaking usage
rg 'import.*dayjs' -A 2

# Check the specific dayjs dependencies in package.json files
fd -t f 'package.json' -x grep -A 1 -B 1 '"dayjs"'

Length of output: 4585

packages/@core/ui-kit/form-ui/src/components/form-actions.vue (2)

6-11: LGTM! Good consolidation of date formatting utilities.

The change to use formatDate from shared utils promotes consistency across the codebase.


72-74: Verify consistent renaming across the codebase.

The renaming from fieldMapToTime to fieldMappingTime looks correct here.

✅ Verification successful

Based on the results, I can generate the final response as we have sufficient information. The search results show that:

  1. There are no remaining instances of the old name fieldMapToTime
  2. The new name fieldMappingTime is consistently used across documentation, types, and component files

Renaming from fieldMapToTime to fieldMappingTime is consistently applied

The variable has been renamed consistently throughout the codebase, including:

  • Type definitions in packages/@core/ui-kit/form-ui/src/types.ts
  • Component logic in packages/@core/ui-kit/form-ui/src/components/form-actions.vue
  • Documentation in docs/src/components/common-ui/vben-form.md
  • Example usage in playground/src/views/examples/form/basic.vue
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify consistent renaming across the codebase
echo "Checking for any remaining instances of old name 'fieldMapToTime':"
rg "fieldMapToTime"

echo -e "\nChecking usage of new name 'fieldMappingTime':"
rg "fieldMappingTime"

Length of output: 1209

playground/src/views/examples/form/basic.vue (1)

19-22: Verify the integration with form submission and value setting.

Please ensure that:

  1. The mapped fields (startTime, endTime) are correctly populated in the form submission
  2. The handleSetFormValue function correctly handles the mapping when setting rangePicker values

Let's verify the integration:

✅ Verification successful

Based on the gathered information, I can now provide the final response:

The rangePicker integration with fieldMappingTime is properly configured

The code shows correct integration between the rangePicker and form submission:

  • The fieldMappingTime is properly configured to map rangePicker values to startTime and endTime fields with the correct date format
  • The handleSetFormValue function correctly sets rangePicker values using dayjs objects
  • The onSubmit handler receives and processes the mapped form values
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of fieldMappingTime to ensure consistent format
rg "fieldMappingTime.*YYYY-MM-DD" --type ts --type vue

# Search for form submission handlers to verify they handle the mapped fields
rg "startTime.*endTime" --type ts --type vue

Length of output: 159


Script:

#!/bin/bash
# Search for fieldMappingTime usage with correct file type
rg "fieldMappingTime.*YYYY-MM-DD"

# Search for rangePicker and related field mappings
rg "rangePicker.*startTime.*endTime"

# Search for form submission handling
rg "handleSubmit|onSubmit" -A 5

# Look for handleSetFormValue implementation
ast-grep --pattern 'handleSetFormValue($$$) {
  $$$
}'

Length of output: 38755


Script:

#!/bin/bash
# Search for the form implementation in the basic.vue file
rg -A 20 "fieldMappingTime.*YYYY-MM-DD" playground/src/views/examples/form/basic.vue

# Search for onSubmit implementation in the same file
rg -A 10 "function onSubmit" playground/src/views/examples/form/basic.vue

# Look for form schema implementation
ast-grep --pattern 'schema: [
  $$$
]'

Length of output: 881


Script:

#!/bin/bash
# Get the complete implementation of handleSetFormValue
rg -A 15 "function handleSetFormValue" playground/src/views/examples/form/basic.vue

# Look for rangePicker component in the schema
rg -B 5 -A 10 "component: .*rangePicker" playground/src/views/examples/form/basic.vue

Length of output: 557


Script:

#!/bin/bash
# Search for the complete schema array to find rangePicker configuration
rg -A 50 "schema: \[" playground/src/views/examples/form/basic.vue

# Look for any imports or utility functions related to field mapping
rg "fieldMapping|useVbenForm" playground/src/views/examples/form/basic.vue

Length of output: 2387

packages/@core/ui-kit/form-ui/src/types.ts (1)

314-317: Enhance property documentation and verify rename impact.

The documentation for this property could be more descriptive to help developers understand its usage.

Let's verify the rename from fieldMapToTime to fieldMappingTime:

Add more detailed JSDoc comments:

  /**
   * 表单字段映射成时间格式
+  * Maps a single field into two time fields (e.g., for time range inputs)
+  * @example
+  * fieldMappingTime: [
+  *   ['timeRange', ['startTime', 'endTime'], 'HH:mm']
+  * ]
   */
  fieldMappingTime?: FieldMappingTime;
✅ Verification successful

Let me gather more information to verify if this is truly a rename or a new property addition by checking the git history and searching for any usage patterns.


Let me search for any implementations or usages of both the old and new property to ensure there are no remaining references that need updating.


Property rename has been properly implemented

The verification shows that:

  1. The rename from fieldMapToTime to fieldMappingTime was done correctly in commit caf2cc4
  2. All implementations in form-actions.vue are using the new property name
  3. No remaining references to the old property name exist in the codebase
  4. Type definitions are properly updated

The suggested documentation improvement is still valid but not critical since the implementation in form-actions.vue clearly shows the property's purpose for handling time range fields.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to the old name
echo "Checking for old property name usage..."
rg "fieldMapToTime" --type ts

# Search for new property name usage to ensure consistency
echo "Checking new property name usage..."
rg "fieldMappingTime" --type ts

Length of output: 313


Script:

#!/bin/bash
# Check git history for the file to verify the rename
git log -p packages/@core/ui-kit/form-ui/src/types.ts | grep -A 5 -B 5 "fieldMap.*Time"

# Search for any form-related components or utilities that might use this property
echo "Checking form-related files..."
fd "form" -e ts -e tsx --exec rg -l "fieldMap.*Time" {}

# Search for test files that might reference this property
echo "Checking test files..."
fd "test|spec" -e ts -e tsx --exec rg -l "fieldMap.*Time" {}

Length of output: 1407


Script:

#!/bin/bash
# Search for implementations and usages in the form-ui directory
echo "Checking form-ui directory for implementations..."
rg -A 5 -B 5 "fieldMapToTime|fieldMappingTime" packages/@core/ui-kit/form-ui/

# Search for any type references or imports
echo "Checking for type references..."
rg -l "FieldMapToTime|FieldMappingTime" --type ts

# Check if there are any schema or configuration files that might reference these properties
echo "Checking for config files..."
fd . -e json -e yaml -e yml --exec rg -l "fieldMapToTime|fieldMappingTime" {}

Length of output: 3697

packages/@core/ui-kit/form-ui/src/form-api.ts (1)

245-252: Verify integration with modal forms.

Let's verify that this new method is properly integrated with modal forms as mentioned in the AI summary.

packages/@core/base/shared/src/utils/date.ts Outdated Show resolved Hide resolved
playground/src/views/examples/modal/form-modal-demo.vue Outdated Show resolved Hide resolved
@anncwb anncwb changed the title perf: formApi added submitAndValidateForm & filedMapToTime renamed fieldMappingTime perf: formApi added validateAndSubmitForm & filedMapToTime renamed fieldMappingTime Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant