Skip to content

fix:ssr构建失败#10

Merged
kagol merged 1 commit intoopentiny:mainfrom
discreted66:lk709
Jul 14, 2025
Merged

fix:ssr构建失败#10
kagol merged 1 commit intoopentiny:mainfrom
discreted66:lk709

Conversation

@discreted66
Copy link
Collaborator

@discreted66 discreted66 commented Jul 10, 2025

fix:ssr构建失败

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive date utility module with functions for date parsing, formatting, timezone handling, and date manipulation.
  • Bug Fixes

    • Improved client-side rendering by wrapping all search box documentation examples in a client-only component to prevent server-side rendering issues.
    • Enhanced stability by adding runtime checks before manipulating the DOM or adding document event listeners.
  • Documentation

    • Clarified and standardized property and attribute names, descriptions, and usage examples throughout the documentation for better accuracy and readability.
    • Updated dependency declarations for more precise package usage.
  • Refactor

    • Simplified and cleaned up component templates and imports, removing unnecessary logic and ensuring consistent formatting.
    • Replaced custom modal warnings with native alerts for input length exceed notifications.

@coderabbitai
Copy link

coderabbitai bot commented Jul 10, 2025

Walkthrough

This update introduces a comprehensive date utility module, enhances client-side rendering control for search box documentation components, and improves documentation clarity by updating property names and descriptions. It also refines dropdown and event handling logic, adjusts dependencies, and ensures style imports are handled in the correct files. Several code and documentation files are updated for consistency and maintainability.

Changes

Files/Groups Change Summary
packages/search-box/src/utils/date.ts Added a new date utility module with parsing, formatting, timezone, and validation functions.
packages/search-box/src/composables/use-dropdown.ts
.../use-init.ts
.../use-match.ts
Refined dropdown, popover, and loading logic; improved event handling and runtime checks.
packages/search-box/src/index.vue Guarded document event listeners, enabled dropdown close-on-click-outside, and improved formatting.
packages/docs/search-box/*.vue Wrapped all <tiny-search-box> usages in <ClientOnly> to enforce client-side rendering.
packages/docs/search-box/custom-panel.vue Removed all autocomplete logic and state; replaced dynamic content with static placeholders; adjusted imports.
packages/docs/search-box/combination-panel.vue Updated imports for TinyInput, cleaned icon imports, normalized indentation, added <ClientOnly>.
packages/docs/search-box/max-length.vue Replaced Modal.message with native alert for warnings; removed Modal import; added <ClientOnly>.
packages/docs/search-box/split-input-value.vue Changed prop to bound syntax (`:split-input-value="'
packages/docs/examples/*.md Updated and clarified property names, descriptions, and formatting for consistency and accuracy.
packages/docs/package.json Replaced @opentiny/vue dependency with @opentiny/vue-button and @opentiny/vue-input.
packages/docs/.vitepress/theme/index.ts
index.less
Moved dark theme CSS import from TypeScript to LESS stylesheet.
packages/search-box/package.json Removed @opentiny/utils dependency.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DocsComponent
    participant ClientOnly
    participant TinySearchBox

    User->>DocsComponent: Load documentation page
    DocsComponent->>ClientOnly: Render wrapper
    alt On client-side
        ClientOnly->>TinySearchBox: Render component
    else On server-side
        ClientOnly-->>TinySearchBox: Do not render
    end
Loading
sequenceDiagram
    participant App
    participant DateUtils

    App->>DateUtils: toDate(value, format, minDate)
    DateUtils->>DateUtils: Parse and validate value
    DateUtils-->>App: Return Date or undefined

    App->>DateUtils: format(date, format)
    DateUtils->>DateUtils: Format date string
    DateUtils-->>App: Return formatted string
Loading

Poem

In the warren where code and dates entwine,
A bunny hops to tweak each doc and line.
With client-only wraps and dates parsed right,
The dropdowns gleam, the docs are bright.
Dependencies pruned, descriptions clear—
🐰 Cheers to the code, let’s all give a thump and cheer!

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this 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.

@github-actions github-actions bot added the bug Something isn't working label Jul 10, 2025
Copy link

@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: 3

🧹 Nitpick comments (8)
packages/docs/examples/events.md (1)

3-3: Minor style nit – consider inline code formatting for key terms

Although no property name is mentioned here, referring to “事件” or typical event names (e.g. first-level-select) in back-ticks usually improves readability and keeps style consistent with other docs.

packages/docs/examples/potential-match.md (1)

3-3: Consistency & formatting

  1. Add “属性” to mirror the wording of other example files.
  2. Wrap the attribute name in back-ticks for clarity.
-通过 potentialOptions 配置潜在匹配项
+通过 `potentialOptions` 属性配置潜在匹配项
packages/docs/examples/panel-max-height.md (1)

3-3: Use back-ticks around attribute name

Follow the same formatting convention adopted elsewhere.

-通过 panelMaxHeight 属性可以设置下拉面板的最大高度
+通过 `panelMaxHeight` 属性可以设置下拉面板的最大高度
packages/docs/examples/empty-placeholder.md (1)

3-3: Inline-code formatting for attribute

-通过 emptyPlaceholder 属性可以设置没有筛选项时的占位文本
+通过 `emptyPlaceholder` 属性可以设置没有筛选项时的占位文本
packages/docs/examples/group-key.md (1)

3-3: Apply back-ticks to attribute name

-通过 groupKey 属性可以自定义属性分组
+通过 `groupKey` 属性可以自定义属性分组
packages/docs/search-box/editable.vue (1)

63-65: Systematic SSR fix completion.

The <ClientOnly> wrapper correctly completes the systematic fix across all documentation files. The approach consistently addresses SSR build failures while preserving component functionality.

Consider adding a brief comment in the documentation explaining why <ClientOnly> is used, to help future developers understand the SSR considerations:

<template>
+  <!-- Wrapped in ClientOnly to prevent SSR issues -->
  <ClientOnly>
    <tiny-search-box v-model="tags" :items="items" editable />
  </ClientOnly>
</template>
packages/search-box/src/composables/use-init.ts (1)

32-32: Simplify redundant condition in showDropdown call

The condition item.field === state.prevItem.field && item !== state.prevItem is already checked by the parent if statement on line 15, making this expression always evaluate to true within this block.

-        showDropdown(state, item.field === state.prevItem.field && item !== state.prevItem)
+        showDropdown(state, true)

Or even simpler since true is the default:

-        showDropdown(state, item.field === state.prevItem.field && item !== state.prevItem)
+        showDropdown(state)
packages/docs/search-box/custom-panel.vue (1)

42-47: Remove unused scope parameters from template slots

The scope parameters in the template slots are not being used after the simplification.

-      <template #autocomplete="scope">
+      <template #autocomplete>
         <div class="tvp-search-box__date-wrap">
           <div class="tvp-search-box__dropdown-title">选择人员</div>
           我是人员自定义面板
         </div>
       </template>

Apply similar changes to other template slots that don't use the scope parameter.

Also applies to: 49-51, 53-58, 60-62

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8949adf and f2e2e75.

📒 Files selected for processing (40)
  • packages/docs/.vitepress/theme/index.less (1 hunks)
  • packages/docs/.vitepress/theme/index.ts (0 hunks)
  • packages/docs/examples/auto-match.md (1 hunks)
  • packages/docs/examples/default-field.md (1 hunks)
  • packages/docs/examples/empty-placeholder.md (1 hunks)
  • packages/docs/examples/events.md (1 hunks)
  • packages/docs/examples/group-key.md (1 hunks)
  • packages/docs/examples/help.md (1 hunks)
  • packages/docs/examples/id-map-key.md (1 hunks)
  • packages/docs/examples/item-placeholder.md (1 hunks)
  • packages/docs/examples/max-length.md (1 hunks)
  • packages/docs/examples/panel-max-height.md (1 hunks)
  • packages/docs/examples/potential-match.md (1 hunks)
  • packages/docs/examples/split-input-value.md (1 hunks)
  • packages/docs/examples/v-model.md (1 hunks)
  • packages/docs/package.json (2 hunks)
  • packages/docs/search-box/auto-match.vue (1 hunks)
  • packages/docs/search-box/basic-usage.vue (1 hunks)
  • packages/docs/search-box/combination-panel.vue (2 hunks)
  • packages/docs/search-box/custom-panel.vue (2 hunks)
  • packages/docs/search-box/default-field.vue (1 hunks)
  • packages/docs/search-box/editable.vue (1 hunks)
  • packages/docs/search-box/empty-placeholder.vue (1 hunks)
  • packages/docs/search-box/events.vue (1 hunks)
  • packages/docs/search-box/group-key.vue (1 hunks)
  • packages/docs/search-box/help.vue (1 hunks)
  • packages/docs/search-box/id-map-key.vue (1 hunks)
  • packages/docs/search-box/item-placeholder.vue (1 hunks)
  • packages/docs/search-box/max-length.vue (1 hunks)
  • packages/docs/search-box/max-time-length.vue (1 hunks)
  • packages/docs/search-box/merge-tag.vue (1 hunks)
  • packages/docs/search-box/panel-max-height.vue (1 hunks)
  • packages/docs/search-box/potential-match.vue (1 hunks)
  • packages/docs/search-box/split-input-value.vue (1 hunks)
  • packages/docs/search-box/v-model.vue (1 hunks)
  • packages/search-box/src/composables/use-dropdown.ts (0 hunks)
  • packages/search-box/src/composables/use-init.ts (1 hunks)
  • packages/search-box/src/composables/use-match.ts (1 hunks)
  • packages/search-box/src/index.vue (4 hunks)
  • packages/search-box/src/utils/date.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/docs/.vitepress/theme/index.ts
  • packages/search-box/src/composables/use-dropdown.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/search-box/src/composables/use-init.ts (1)
packages/search-box/src/utils/dropdown.ts (1)
  • showDropdown (6-16)
🪛 Biome (1.9.4)
packages/search-box/src/utils/date.ts

[error] 51-51: Do not shadow the global "toString" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)


[error] 171-171: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.

(lint/suspicious/noGlobalIsFinite)

🔇 Additional comments (36)
packages/docs/.vitepress/theme/index.less (1)

1-1: Clarify LESS import mode to avoid accidental parsing issues

LESS treats @import 'something.css' as a regular LESS file unless you explicitly mark it as CSS.
To guarantee the file is included verbatim and to prevent mis-parsing or duplicated CSS when the loader configuration changes, consider adding the (css) modifier:

-@import '@opentiny/vue-theme/dark-theme-index.css';
+@import (css) '@opentiny/vue-theme/dark-theme-index.css';

Please run a quick SSR build to verify there are no new style compilation warnings.

packages/docs/examples/events.md (1)

5-5: LGTM – preview tag fix

Removing the superfluous space brings this tag in line with the other examples.

packages/docs/examples/default-field.md (1)

3-3: Good documentation improvement!

The change from "default-field" to "defaultField" aligns with JavaScript camelCase conventions and clarifies the property's purpose. This consistency improvement supports better developer understanding.

packages/docs/examples/item-placeholder.md (1)

3-3: Documentation simplification improves clarity.

The updated text focuses on the core functionality of itemPlaceholder rather than internal implementation details, making it more user-friendly and accessible.

packages/docs/examples/max-length.md (1)

3-3: Good generalization of the documentation.

Removing the specific "8-character limit" and generalizing the description makes the documentation more flexible and applicable to different use cases.

packages/docs/examples/help.md (1)

3-3: Excellent documentation improvement.

The change to camelCase "showHelp" and the clear explanation of default behavior (true) and false value behavior makes this documentation more precise and user-friendly.

packages/search-box/src/composables/use-match.ts (1)

40-45: Excellent SSR compatibility fix!

The addition of the typeof document !== 'undefined' check before creating the loading instance properly addresses SSR build failures. This prevents DOM access in server-side environments while maintaining full functionality in client-side environments.

packages/docs/examples/id-map-key.md (1)

3-3: Documentation improvement looks good!

The update from id-map-key to idMapKey aligns with JavaScript camelCase naming conventions, and the clarification about the default value and usage improves the documentation.

packages/docs/examples/auto-match.md (1)

5-5: LGTM!

Minor formatting improvement.

packages/docs/search-box/basic-usage.vue (1)

9-11: Good fix for SSR compatibility!

Wrapping the search box component in <ClientOnly> correctly prevents server-side rendering issues, which aligns with the PR objective of fixing SSR build failures.

packages/docs/examples/v-model.md (1)

3-5: Documentation improvements look good!

The clarification about using v-model for default filter items improves clarity, and the formatting fix maintains consistency.

packages/docs/search-box/potential-match.vue (1)

42-44: LGTM! Proper SSR fix implementation.

The <ClientOnly> wrapper correctly prevents server-side rendering of the search box component, which addresses the SSR build failure mentioned in the PR objectives. This is especially important for this component since it contains async logic that could cause hydration mismatches.

packages/docs/search-box/empty-placeholder.vue (1)

9-11: LGTM! Consistent SSR fix implementation.

The <ClientOnly> wrapper is correctly applied, following the same pattern as other files in this PR. This ensures consistent client-side rendering for the search box component across all documentation examples.

packages/docs/search-box/group-key.vue (1)

10-12: LGTM! Consistent implementation.

The <ClientOnly> wrapper is properly implemented and maintains consistency with the overall PR approach. The reactive data handling will work correctly with client-side rendering.

packages/docs/search-box/merge-tag.vue (1)

55-57: LGTM! Proper SSR fix with event handling.

The <ClientOnly> wrapper correctly addresses the SSR issue while preserving the component's functionality, including the @change event handler. The complex reactive data structure with merge tag functionality will work properly with client-side rendering.

packages/docs/search-box/id-map-key.vue (1)

127-129: LGTM! Systematic SSR fix completion.

The <ClientOnly> wrapper is correctly implemented for the most complex component in the set, handling nested data structures and map types. This completes the systematic application of the SSR fix across all documentation examples, ensuring consistent client-side rendering behavior.

packages/docs/search-box/item-placeholder.vue (1)

117-119: Action Required: Confirm <ClientOnly> Registration

I’ve verified that there’s no nuxt.config.js/ts at the repo root and a global search didn’t reveal any imports or registrations of ClientOnly. Please ensure that the <ClientOnly> wrapper you added will actually work:

• If this is a Nuxt project, confirm that nuxt.config.js or nuxt.config.ts exists (Nuxt provides <ClientOnly> out of the box).
• If you’re on a standard Vue setup, import and register ClientOnly either globally or locally:

– Local registration in item-placeholder.vue:

<script setup lang="ts">
+ import ClientOnly from 'vue-client-only'
// …
</script>

– Global registration in your entry file (main.js/main.ts):

import { createApp } from 'vue'
import App from './App.vue'
import ClientOnly from 'vue-client-only'

const app = createApp(App)
app.component('ClientOnly', ClientOnly)
app.mount('#app')

Once confirmed, the SSR fix is good to go.

packages/docs/search-box/default-field.vue (1)

10-12: Consistent SSR fix implementation.

The <ClientOnly> wrapper is correctly applied, maintaining consistency with the SSR fix approach across documentation files.

packages/docs/search-box/help.vue (1)

12-15: Efficient grouping of related components.

Both search box components are correctly wrapped in a single <ClientOnly> wrapper, which is efficient and maintains their functional relationship while fixing SSR issues.

packages/docs/search-box/auto-match.vue (1)

11-13: Consistent SSR fix pattern.

The <ClientOnly> wrapper is correctly applied, maintaining the established pattern for addressing SSR build failures across documentation components.

packages/docs/search-box/v-model.vue (1)

21-23: LGTM! Proper SSR fix implementation.

The <ClientOnly> wrapper correctly prevents server-side rendering of the search box component, which addresses the SSR build failure mentioned in the PR objectives.

packages/docs/search-box/panel-max-height.vue (1)

11-13: LGTM! Consistent SSR fix implementation.

The <ClientOnly> wrapper is properly implemented and consistent with the SSR fix pattern used across other search box components.

packages/docs/search-box/split-input-value.vue (1)

11-13: LGTM! SSR fix with improved prop binding.

The <ClientOnly> wrapper addresses the SSR build failure, and the change from split-input-value="|" to :split-input-value="'|'" improves the prop binding by using proper Vue syntax for string literal binding.

packages/docs/examples/split-input-value.md (1)

3-3: LGTM! Documentation correctly reflects component usage.

The updated documentation properly explains the splitInputValue property and its default behavior, which aligns with the prop binding improvements made in the corresponding Vue component.

packages/docs/search-box/max-time-length.vue (1)

45-47: LGTM! Consistent SSR fix pattern.

The <ClientOnly> wrapper properly addresses the SSR build failure while preserving all existing functionality including the complex date/time configuration and event handling.

packages/docs/search-box/events.vue (1)

149-160: LGTM - Correct SSR fix implementation.

The <ClientOnly> wrapper correctly prevents server-side rendering of the tiny-search-box component, which aligns with the PR objective of fixing SSR build failures. This is a standard pattern for components that require browser-specific APIs.

packages/docs/search-box/max-length.vue (2)

20-20: Good simplification - using native alert instead of Modal.

Replacing Modal.message with native alert reduces dependencies and eliminates potential SSR issues with the Modal component. This is a practical approach for simple notifications in documentation examples.


25-27: LGTM - Consistent SSR fix implementation.

The <ClientOnly> wrapper ensures client-side-only rendering, preventing SSR build failures. This matches the pattern applied across other search-box documentation components.

packages/docs/package.json (1)

12-13: Good modularization - replacing broad dependency with specific packages.

Replacing @opentiny/vue with specific packages (@opentiny/vue-button and @opentiny/vue-autocomplete) improves tree-shaking and reduces bundle size. This granular approach also helps minimize potential SSR compatibility issues.

packages/search-box/src/index.vue (4)

277-281: Essential SSR fix - document availability check.

Adding typeof document !== 'undefined' guards prevents runtime errors in server-side environments where document is not available. This is a critical fix for SSR compatibility.


285-289: Consistent SSR protection for cleanup.

The document check in onBeforeUnmount ensures safe cleanup of event listeners, maintaining consistency with the mounted lifecycle hook guards.


353-353: UX improvement - enable click-outside to close dropdown.

Adding close-on-click-outside="true" provides better user experience by allowing users to close the dropdown by clicking outside of it, which is expected behavior.


392-396: Improved readability with multi-line formatting.

The multi-line formatting of component attributes improves code readability and maintainability without affecting functionality.

packages/docs/search-box/combination-panel.vue (2)

4-5: Consistent with dependency modularization.

The import changes align with the package.json updates, using specific packages instead of the broad @opentiny/vue package. This supports better tree-shaking and reduces potential SSR issues.


62-90: Proper SSR prevention with ClientOnly wrapper.

The <ClientOnly> wrapper ensures the search-box component and its slot templates render only on the client side, preventing SSR build failures. This is consistent with the pattern applied across other documentation components.

packages/docs/search-box/custom-panel.vue (1)

39-40: Good use of ClientOnly wrapper for SSR compatibility

Wrapping the search box component in <ClientOnly> effectively prevents SSR-related issues, which aligns with the PR's objective to fix SSR build failures.

Also applies to: 64-64

*
* isNumber(369) // true
*/
export const isNumber = (value: any) => typeof value === 'number' && isFinite(value)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use Number.isFinite for safer type checking.

isFinite performs type coercion which can lead to unexpected behavior. Number.isFinite is safer as it doesn't coerce the value.

Apply this diff:

-export const isNumber = (value: any) => typeof value === 'number' && isFinite(value)
+export const isNumber = (value: any) => typeof value === 'number' && Number.isFinite(value)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const isNumber = (value: any) => typeof value === 'number' && isFinite(value)
export const isNumber = (value: any) => typeof value === 'number' && Number.isFinite(value)
🤖 Prompt for AI Agents
In packages/search-box/src/utils/date.ts at line 156, replace the use of the
global isFinite function with Number.isFinite to avoid type coercion issues.
Update the isNumber function to use Number.isFinite(value) instead of
isFinite(value) for safer and more accurate finite number checking.

}
}

export const toString = Object.prototype.toString
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Rename toString to avoid shadowing the global property.

The variable shadows the global toString property, which can cause confusion about its origin.

Apply this diff:

-export const toString = Object.prototype.toString
+export const objectToString = Object.prototype.toString

Also update all references to use objectToString:

  • Line 92: class2type[objectToString.call(obj)]
  • Line 118: objectToString.call(obj) !== '[object Object]'

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/search-box/src/utils/date.ts at line 47, rename the exported
constant from `toString` to `objectToString` to avoid shadowing the global
`toString` property. Then update all references to this constant accordingly,
specifically at line 92 and line 118, replacing `toString.call(obj)` with
`objectToString.call(obj)`.

Comment on lines +2 to +4
import { reactive, ref, shallowRef } from 'vue'
import TinyAutocomplete from '@opentiny/vue-autocomplete' // 改为动态加载

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove unused imports

The imports shallowRef and TinyAutocomplete are not used anywhere in the component. Additionally, the comment mentions "dynamic loading" but the import is still static.

-import { reactive, ref, shallowRef } from 'vue'
-import TinyAutocomplete from '@opentiny/vue-autocomplete' // 改为动态加载
+import { reactive, ref } from 'vue'

If dynamic loading is intended for the future, consider using dynamic imports when actually needed:

const TinyAutocomplete = () => import('@opentiny/vue-autocomplete')
🤖 Prompt for AI Agents
In packages/docs/search-box/custom-panel.vue lines 2 to 4, remove the unused
imports shallowRef and TinyAutocomplete since they are not used in the
component. If dynamic loading of TinyAutocomplete is intended, replace the
static import with a dynamic import using a function that returns
import('@opentiny/vue-autocomplete') when needed.

Copy link

@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: 0

♻️ Duplicate comments (3)
packages/docs/search-box/custom-panel.vue (1)

2-4: Remove unused imports

The imports shallowRef and TinyAutocomplete are not used anywhere in the component. The comment mentions "改为动态加载" (change to dynamic loading) but the import is still static.

packages/search-box/src/utils/date.ts (2)

47-47: Rename toString to avoid shadowing the global property.

The variable shadows the global toString property, which can cause confusion about its origin.


156-156: Use Number.isFinite for safer type checking.

isFinite performs type coercion which can lead to unexpected behavior. Number.isFinite is safer as it doesn't coerce the value.

🧹 Nitpick comments (1)
packages/search-box/src/utils/date.ts (1)

184-184: Add missing type annotation for consistency.

The value parameter is missing a type annotation, which is inconsistent with other similar functions in the file.

-export const isDate = (value) => typeOf(value) === 'date'
+export const isDate = (value: any) => typeOf(value) === 'date'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2e2e75 and 439b0d2.

📒 Files selected for processing (40)
  • packages/docs/.vitepress/theme/index.less (1 hunks)
  • packages/docs/.vitepress/theme/index.ts (0 hunks)
  • packages/docs/examples/auto-match.md (1 hunks)
  • packages/docs/examples/default-field.md (1 hunks)
  • packages/docs/examples/empty-placeholder.md (1 hunks)
  • packages/docs/examples/events.md (1 hunks)
  • packages/docs/examples/group-key.md (1 hunks)
  • packages/docs/examples/help.md (1 hunks)
  • packages/docs/examples/id-map-key.md (1 hunks)
  • packages/docs/examples/item-placeholder.md (1 hunks)
  • packages/docs/examples/max-length.md (1 hunks)
  • packages/docs/examples/panel-max-height.md (1 hunks)
  • packages/docs/examples/potential-match.md (1 hunks)
  • packages/docs/examples/split-input-value.md (1 hunks)
  • packages/docs/examples/v-model.md (1 hunks)
  • packages/docs/package.json (2 hunks)
  • packages/docs/search-box/auto-match.vue (1 hunks)
  • packages/docs/search-box/basic-usage.vue (1 hunks)
  • packages/docs/search-box/combination-panel.vue (2 hunks)
  • packages/docs/search-box/custom-panel.vue (2 hunks)
  • packages/docs/search-box/default-field.vue (1 hunks)
  • packages/docs/search-box/editable.vue (1 hunks)
  • packages/docs/search-box/empty-placeholder.vue (1 hunks)
  • packages/docs/search-box/events.vue (1 hunks)
  • packages/docs/search-box/group-key.vue (1 hunks)
  • packages/docs/search-box/help.vue (1 hunks)
  • packages/docs/search-box/id-map-key.vue (1 hunks)
  • packages/docs/search-box/item-placeholder.vue (1 hunks)
  • packages/docs/search-box/max-length.vue (1 hunks)
  • packages/docs/search-box/max-time-length.vue (1 hunks)
  • packages/docs/search-box/merge-tag.vue (1 hunks)
  • packages/docs/search-box/panel-max-height.vue (1 hunks)
  • packages/docs/search-box/potential-match.vue (1 hunks)
  • packages/docs/search-box/split-input-value.vue (1 hunks)
  • packages/docs/search-box/v-model.vue (1 hunks)
  • packages/search-box/src/composables/use-dropdown.ts (0 hunks)
  • packages/search-box/src/composables/use-init.ts (1 hunks)
  • packages/search-box/src/composables/use-match.ts (1 hunks)
  • packages/search-box/src/index.vue (4 hunks)
  • packages/search-box/src/utils/date.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/docs/.vitepress/theme/index.ts
  • packages/search-box/src/composables/use-dropdown.ts
✅ Files skipped from review due to trivial changes (4)
  • packages/docs/search-box/id-map-key.vue
  • packages/docs/examples/split-input-value.md
  • packages/docs/search-box/merge-tag.vue
  • packages/docs/examples/panel-max-height.md
🚧 Files skipped from review as they are similar to previous changes (32)
  • packages/docs/examples/group-key.md
  • packages/docs/examples/auto-match.md
  • packages/docs/search-box/item-placeholder.vue
  • packages/docs/search-box/auto-match.vue
  • packages/docs/search-box/group-key.vue
  • packages/docs/search-box/potential-match.vue
  • packages/docs/search-box/basic-usage.vue
  • packages/docs/.vitepress/theme/index.less
  • packages/docs/search-box/editable.vue
  • packages/docs/examples/v-model.md
  • packages/docs/examples/events.md
  • packages/docs/examples/potential-match.md
  • packages/docs/search-box/panel-max-height.vue
  • packages/docs/search-box/default-field.vue
  • packages/docs/examples/max-length.md
  • packages/docs/search-box/max-time-length.vue
  • packages/docs/search-box/split-input-value.vue
  • packages/docs/examples/default-field.md
  • packages/docs/examples/empty-placeholder.md
  • packages/docs/search-box/help.vue
  • packages/docs/package.json
  • packages/docs/search-box/v-model.vue
  • packages/docs/search-box/events.vue
  • packages/docs/search-box/combination-panel.vue
  • packages/docs/search-box/max-length.vue
  • packages/docs/examples/help.md
  • packages/search-box/src/composables/use-match.ts
  • packages/docs/examples/id-map-key.md
  • packages/docs/search-box/empty-placeholder.vue
  • packages/docs/examples/item-placeholder.md
  • packages/search-box/src/composables/use-init.ts
  • packages/search-box/src/index.vue
🧰 Additional context used
🪛 Biome (1.9.4)
packages/search-box/src/utils/date.ts

[error] 51-51: Do not shadow the global "toString" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)


[error] 171-171: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.

(lint/suspicious/noGlobalIsFinite)

🔇 Additional comments (5)
packages/docs/search-box/custom-panel.vue (2)

39-64: Good use of ClientOnly for SSR compatibility!

Wrapping the search box component in <ClientOnly> is the correct approach to prevent SSR build failures.


42-58: Verify the removal of autocomplete functionality

The custom panels have been simplified to show only static text ("我是人员自定义面板"). According to the changes, all autocomplete functionality including the input field, suggestion fetching, and confirm/cancel buttons have been removed.

Please confirm if this simplification is intentional for the documentation example or if the functionality should be preserved.

packages/search-box/src/utils/date.ts (3)

285-371: Comprehensive date parsing logic handles multiple formats correctly.

The three date parsers (yyyymmdd, mmddyyyy, and ISO8601) properly handle different date formats, timezone conversions, leap years, and invalid date validation. The complex logic is well-structured and covers edge cases appropriately.


546-675: Well-designed main utility functions provide comprehensive date handling.

The toDate, format, getDateWithNewTimezone, and toDateStr functions offer flexible APIs with proper error handling, type checking, and edge case management. The implementation efficiently handles various input formats and timezone conversions.


1-724: Date utility usage confirmed

The date.ts module is actively used within the Search-Box package:

• In packages/search-box/src/composables/use-dropdown.ts – calls format(...)
• In packages/search-box/src/composables/use-edit.ts – calls format(...)

No other date-handling utilities exist in the codebase, so this comprehensive module is necessary for parsing and formatting dates in these components.

Copy link

@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: 0

♻️ Duplicate comments (2)
packages/search-box/src/utils/date.ts (2)

47-47: Rename toString to avoid shadowing the global property.

The variable shadows the global toString property, which can cause confusion about its origin.


156-156: Use Number.isFinite for safer type checking.

isFinite performs type coercion which can lead to unexpected behavior. Number.isFinite is safer as it doesn't coerce the value.

🧹 Nitpick comments (1)
packages/docs/examples/events.md (1)

3-3: Use back-ticks to highlight event identifiers.

Wrapping the event names in inline code markers improves readability and keeps the style consistent with other docs (first-level-select, search, etc.).

-通过first-level-select、search、change、clear、tag-click等事件可以监听组件的各种状态变化
+通过 `first-level-select`、`search`、`change`、`clear`、`tag-click` 等事件可以监听组件的各种状态变化
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 439b0d2 and 596abaa.

📒 Files selected for processing (41)
  • packages/docs/.vitepress/theme/index.less (1 hunks)
  • packages/docs/.vitepress/theme/index.ts (0 hunks)
  • packages/docs/examples/auto-match.md (1 hunks)
  • packages/docs/examples/default-field.md (1 hunks)
  • packages/docs/examples/empty-placeholder.md (1 hunks)
  • packages/docs/examples/events.md (1 hunks)
  • packages/docs/examples/group-key.md (1 hunks)
  • packages/docs/examples/help.md (1 hunks)
  • packages/docs/examples/id-map-key.md (1 hunks)
  • packages/docs/examples/item-placeholder.md (1 hunks)
  • packages/docs/examples/max-length.md (1 hunks)
  • packages/docs/examples/panel-max-height.md (1 hunks)
  • packages/docs/examples/potential-match.md (1 hunks)
  • packages/docs/examples/split-input-value.md (1 hunks)
  • packages/docs/examples/v-model.md (1 hunks)
  • packages/docs/package.json (2 hunks)
  • packages/docs/search-box/auto-match.vue (1 hunks)
  • packages/docs/search-box/basic-usage.vue (1 hunks)
  • packages/docs/search-box/combination-panel.vue (2 hunks)
  • packages/docs/search-box/custom-panel.vue (2 hunks)
  • packages/docs/search-box/default-field.vue (1 hunks)
  • packages/docs/search-box/editable.vue (1 hunks)
  • packages/docs/search-box/empty-placeholder.vue (1 hunks)
  • packages/docs/search-box/events.vue (1 hunks)
  • packages/docs/search-box/group-key.vue (1 hunks)
  • packages/docs/search-box/help.vue (1 hunks)
  • packages/docs/search-box/id-map-key.vue (1 hunks)
  • packages/docs/search-box/item-placeholder.vue (1 hunks)
  • packages/docs/search-box/max-length.vue (1 hunks)
  • packages/docs/search-box/max-time-length.vue (1 hunks)
  • packages/docs/search-box/merge-tag.vue (1 hunks)
  • packages/docs/search-box/panel-max-height.vue (1 hunks)
  • packages/docs/search-box/potential-match.vue (1 hunks)
  • packages/docs/search-box/split-input-value.vue (1 hunks)
  • packages/docs/search-box/v-model.vue (1 hunks)
  • packages/search-box/package.json (1 hunks)
  • packages/search-box/src/composables/use-dropdown.ts (0 hunks)
  • packages/search-box/src/composables/use-init.ts (1 hunks)
  • packages/search-box/src/composables/use-match.ts (1 hunks)
  • packages/search-box/src/index.vue (4 hunks)
  • packages/search-box/src/utils/date.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/docs/.vitepress/theme/index.ts
  • packages/search-box/src/composables/use-dropdown.ts
✅ Files skipped from review due to trivial changes (4)
  • packages/search-box/package.json
  • packages/docs/search-box/split-input-value.vue
  • packages/docs/examples/split-input-value.md
  • packages/docs/search-box/merge-tag.vue
🚧 Files skipped from review as they are similar to previous changes (33)
  • packages/docs/examples/auto-match.md
  • packages/docs/search-box/basic-usage.vue
  • packages/docs/package.json
  • packages/docs/search-box/v-model.vue
  • packages/docs/search-box/events.vue
  • packages/docs/.vitepress/theme/index.less
  • packages/docs/examples/max-length.md
  • packages/docs/search-box/max-time-length.vue
  • packages/docs/search-box/default-field.vue
  • packages/docs/examples/item-placeholder.md
  • packages/docs/search-box/item-placeholder.vue
  • packages/docs/examples/id-map-key.md
  • packages/docs/search-box/auto-match.vue
  • packages/docs/examples/empty-placeholder.md
  • packages/search-box/src/composables/use-init.ts
  • packages/docs/search-box/max-length.vue
  • packages/docs/examples/group-key.md
  • packages/docs/search-box/custom-panel.vue
  • packages/docs/examples/potential-match.md
  • packages/docs/examples/panel-max-height.md
  • packages/search-box/src/composables/use-match.ts
  • packages/docs/search-box/help.vue
  • packages/docs/search-box/combination-panel.vue
  • packages/docs/search-box/potential-match.vue
  • packages/docs/search-box/editable.vue
  • packages/search-box/src/index.vue
  • packages/docs/search-box/id-map-key.vue
  • packages/docs/examples/help.md
  • packages/docs/search-box/group-key.vue
  • packages/docs/examples/v-model.md
  • packages/docs/search-box/empty-placeholder.vue
  • packages/docs/search-box/panel-max-height.vue
  • packages/docs/examples/default-field.md
🧰 Additional context used
🪛 LanguageTool
packages/docs/examples/events.md

[grammar] ~3-~3: Ensure spelling is correct
Context: ...st-level-select、search、change、clear、tag-click等事件可以监听组件的各种状态变化

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🪛 Biome (1.9.4)
packages/search-box/src/utils/date.ts

[error] 51-51: Do not shadow the global "toString" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)


[error] 171-171: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.

(lint/suspicious/noGlobalIsFinite)

🔇 Additional comments (8)
packages/docs/examples/events.md (1)

5-5: 👍 Removed stray space inside <preview> tag.

The cleanup avoids potential path-parsing edge cases in the docs tooling.

packages/search-box/src/utils/date.ts (7)

1-45: LGTM! Well-implemented string padding utility.

The fillChar function is correctly implemented with proper parameter validation and handles both append and prepend modes efficiently.


50-149: Excellent type checking utilities implementation.

The type checking functions are well-designed with comprehensive documentation and handle edge cases properly. The isPlainObject function correctly distinguishes between plain objects and other object types.


158-200: Robust numeric and type validation functions.

The isNumeric, isDate, isSame, isRegExp, and isPromise functions are well-implemented with proper handling of edge cases like NaN comparison.


202-387: Comprehensive date parsing infrastructure.

The regex patterns for different date formats (yyyy/mm/dd, mm/dd/yyyy, ISO8601) are well-constructed, and the parsing functions handle timezone conversions and validation correctly. The leap year calculation and date validation logic are mathematically sound.


389-561: Sophisticated date conversion logic.

The toDate function and its supporting utilities provide robust date parsing with support for multiple formats and custom date formats. The implementation correctly handles edge cases and provides fallback behavior.


563-629: Flexible and well-documented date formatting.

The format function provides comprehensive date formatting capabilities with support for various format tokens and proper timezone handling. The implementation is robust and handles both Date objects and string inputs.


631-723: Solid timezone and week calculation utilities.

The timezone conversion functions and getWeekOfFirstDay utility are well-implemented with proper parameter validation and handling of different timezone formats. The week calculation correctly handles both Monday and Sunday as the first day of the week.

Copy link

@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: 3

♻️ Duplicate comments (3)
packages/docs/search-box/custom-panel.vue (1)

2-2: Remove unused import shallowRef

The shallowRef import is not used anywhere in the component and should be removed to clean up the code.

packages/search-box/src/utils/date.ts (2)

47-47: Rename toString to avoid shadowing the global property.


156-156: Use Number.isFinite for safer type checking.

🧹 Nitpick comments (3)
packages/docs/examples/events.md (1)

3-3: Add code-style back-ticks & polish wording for clarity.

Event names stand out better when wrapped in back-ticks and the sentence flows more naturally in Chinese; see the diff below.

-通过first-level-select、search、change、clear、tag-click等可以监听组件的各种事件。
+通过 `first-level-select`、`search`、`change`、`clear`、`tag-click` 等事件可以监听组件的各种状态变化。
packages/search-box/src/utils/date.ts (2)

194-195: Consider using Object.is() for complete same-value equality.

The current implementation doesn't handle all edge cases, such as -0 === 0 (which should be false for same-value equality). Consider using Object.is() for a more comprehensive check.

-export const isSame = (x: any, y: any) =>
-  x === y || (typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y))
+export const isSame = (x: any, y: any) => Object.is(x, y)

709-723: Clarify timezone offset calculation.

The multiplication of a number with a template literal string is confusing and relies on implicit type conversion.

-    value = minoffset * `${match[1]}1`
+    value = minoffset * (match[1] === '-' ? -1 : 1)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 596abaa and 8cb2291.

📒 Files selected for processing (41)
  • packages/docs/.vitepress/theme/index.less (1 hunks)
  • packages/docs/.vitepress/theme/index.ts (0 hunks)
  • packages/docs/examples/auto-match.md (1 hunks)
  • packages/docs/examples/default-field.md (1 hunks)
  • packages/docs/examples/empty-placeholder.md (1 hunks)
  • packages/docs/examples/events.md (1 hunks)
  • packages/docs/examples/group-key.md (1 hunks)
  • packages/docs/examples/help.md (1 hunks)
  • packages/docs/examples/id-map-key.md (1 hunks)
  • packages/docs/examples/item-placeholder.md (1 hunks)
  • packages/docs/examples/max-length.md (1 hunks)
  • packages/docs/examples/panel-max-height.md (1 hunks)
  • packages/docs/examples/potential-match.md (1 hunks)
  • packages/docs/examples/split-input-value.md (1 hunks)
  • packages/docs/examples/v-model.md (1 hunks)
  • packages/docs/package.json (2 hunks)
  • packages/docs/search-box/auto-match.vue (1 hunks)
  • packages/docs/search-box/basic-usage.vue (1 hunks)
  • packages/docs/search-box/combination-panel.vue (2 hunks)
  • packages/docs/search-box/custom-panel.vue (2 hunks)
  • packages/docs/search-box/default-field.vue (1 hunks)
  • packages/docs/search-box/editable.vue (1 hunks)
  • packages/docs/search-box/empty-placeholder.vue (1 hunks)
  • packages/docs/search-box/events.vue (1 hunks)
  • packages/docs/search-box/group-key.vue (1 hunks)
  • packages/docs/search-box/help.vue (1 hunks)
  • packages/docs/search-box/id-map-key.vue (1 hunks)
  • packages/docs/search-box/item-placeholder.vue (1 hunks)
  • packages/docs/search-box/max-length.vue (1 hunks)
  • packages/docs/search-box/max-time-length.vue (1 hunks)
  • packages/docs/search-box/merge-tag.vue (1 hunks)
  • packages/docs/search-box/panel-max-height.vue (1 hunks)
  • packages/docs/search-box/potential-match.vue (1 hunks)
  • packages/docs/search-box/split-input-value.vue (1 hunks)
  • packages/docs/search-box/v-model.vue (1 hunks)
  • packages/search-box/package.json (1 hunks)
  • packages/search-box/src/composables/use-dropdown.ts (0 hunks)
  • packages/search-box/src/composables/use-init.ts (1 hunks)
  • packages/search-box/src/composables/use-match.ts (1 hunks)
  • packages/search-box/src/index.vue (4 hunks)
  • packages/search-box/src/utils/date.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/docs/.vitepress/theme/index.ts
  • packages/search-box/src/composables/use-dropdown.ts
✅ Files skipped from review due to trivial changes (5)
  • packages/docs/search-box/empty-placeholder.vue
  • packages/search-box/package.json
  • packages/docs/search-box/id-map-key.vue
  • packages/docs/search-box/split-input-value.vue
  • packages/docs/search-box/events.vue
🚧 Files skipped from review as they are similar to previous changes (31)
  • packages/docs/examples/potential-match.md
  • packages/docs/.vitepress/theme/index.less
  • packages/docs/search-box/basic-usage.vue
  • packages/docs/search-box/potential-match.vue
  • packages/docs/examples/group-key.md
  • packages/docs/search-box/merge-tag.vue
  • packages/docs/search-box/v-model.vue
  • packages/docs/examples/auto-match.md
  • packages/docs/examples/panel-max-height.md
  • packages/docs/search-box/max-time-length.vue
  • packages/docs/search-box/default-field.vue
  • packages/docs/search-box/group-key.vue
  • packages/docs/search-box/item-placeholder.vue
  • packages/docs/examples/empty-placeholder.md
  • packages/docs/examples/v-model.md
  • packages/docs/examples/help.md
  • packages/docs/search-box/panel-max-height.vue
  • packages/docs/search-box/max-length.vue
  • packages/docs/examples/item-placeholder.md
  • packages/docs/examples/max-length.md
  • packages/docs/search-box/help.vue
  • packages/docs/search-box/auto-match.vue
  • packages/docs/search-box/combination-panel.vue
  • packages/docs/search-box/editable.vue
  • packages/search-box/src/composables/use-match.ts
  • packages/docs/examples/default-field.md
  • packages/docs/examples/id-map-key.md
  • packages/search-box/src/index.vue
  • packages/docs/examples/split-input-value.md
  • packages/search-box/src/composables/use-init.ts
  • packages/docs/package.json
🧰 Additional context used
🪛 Biome (1.9.4)
packages/search-box/src/utils/date.ts

[error] 51-51: Do not shadow the global "toString" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)


[error] 171-171: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.

(lint/suspicious/noGlobalIsFinite)

🪛 LanguageTool
packages/docs/examples/events.md

[grammar] ~3-~3: Ensure spelling is correct
Context: ...st-level-select、search、change、clear、tag-click等可以监听组件的各种事件。 <preview path="../search-box/events.v...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (2)
packages/docs/examples/events.md (1)

5-5: Preview path looks good – no further changes needed.

packages/docs/search-box/custom-panel.vue (1)

37-62: Excellent SSR fix implementation

Wrapping the search box component in <ClientOnly> is the correct approach to resolve SSR build failures. This ensures the component only renders on the client side, preventing server-side rendering issues while maintaining the component's functionality.

let textPos = 0

for (let i = 0, len = str.length; i < len; i++) {
const charValue = str.substr(i, 1)
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use substring instead of substr for consistency.

The function uses both substr and substring. Stick to substring for consistency since substr is deprecated.

-    const charValue = str.substr(i, 1)
+    const charValue = str.substring(i, i + 1)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const charValue = str.substr(i, 1)
const charValue = str.substring(i, i + 1)
🤖 Prompt for AI Agents
In packages/search-box/src/utils/date.ts at line 438, replace the use of the
deprecated `substr` method with `substring` to maintain consistency. Change the
code to use `str.substring(i, i + 1)` instead of `str.substr(i, 1)` to extract
the single character at position `i`.

Comment on lines +358 to +360
if (!timeZone.includes(':')) {
timeZone = timeZone.substr(0, 3) + ':' + timeZone.substr(3)
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace deprecated substr with substring.

The substr method is deprecated.

-        timeZone = timeZone.substr(0, 3) + ':' + timeZone.substr(3)
+        timeZone = timeZone.substring(0, 3) + ':' + timeZone.substring(3)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!timeZone.includes(':')) {
timeZone = timeZone.substr(0, 3) + ':' + timeZone.substr(3)
}
if (!timeZone.includes(':')) {
timeZone = timeZone.substring(0, 3) + ':' + timeZone.substring(3)
}
🤖 Prompt for AI Agents
In packages/search-box/src/utils/date.ts around lines 358 to 360, the code uses
the deprecated substr method to manipulate the timeZone string. Replace all
instances of substr with substring to avoid using deprecated methods.
Specifically, change timeZone.substr(0, 3) to timeZone.substring(0, 3) and
timeZone.substr(3) to timeZone.substring(3).

Comment on lines +26 to +45
export const fillChar = (string, length, append, chr = '0') => {
if (typeof string === 'string' && typeof chr === 'string' && isNumber(length)) {
let len = string.length - length

if (len > 0) {
return append ? string.substr(0, length) : string.substr(len, length)
} else {
const appendStr = []
len = Math.abs(len) / chr.length

for (; len > 0; len--) {
appendStr.push(chr)
}

const s = appendStr.join('')

return append ? string + s : s + string
}
}
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace deprecated substr with substring.

The substr method is deprecated. Replace it with substring for better compatibility.

-      return append ? string.substr(0, length) : string.substr(len, length)
+      return append ? string.substring(0, length) : string.substring(len, length)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const fillChar = (string, length, append, chr = '0') => {
if (typeof string === 'string' && typeof chr === 'string' && isNumber(length)) {
let len = string.length - length
if (len > 0) {
return append ? string.substr(0, length) : string.substr(len, length)
} else {
const appendStr = []
len = Math.abs(len) / chr.length
for (; len > 0; len--) {
appendStr.push(chr)
}
const s = appendStr.join('')
return append ? string + s : s + string
}
}
}
export const fillChar = (string, length, append, chr = '0') => {
if (typeof string === 'string' && typeof chr === 'string' && isNumber(length)) {
let len = string.length - length
if (len > 0) {
return append
? string.substring(0, length)
: string.substring(len, length)
} else {
const appendStr = []
len = Math.abs(len) / chr.length
for (; len > 0; len--) {
appendStr.push(chr)
}
const s = appendStr.join('')
return append ? string + s : s + string
}
}
}
🤖 Prompt for AI Agents
In packages/search-box/src/utils/date.ts between lines 26 and 45, the code uses
the deprecated substr method to extract parts of a string. Replace all instances
of substr with substring, adjusting the parameters accordingly since substring
takes a start index and an end index (exclusive), unlike substr which takes a
start index and length. This will ensure better compatibility and avoid
deprecated method usage.

Copy link

@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: 0

♻️ Duplicate comments (6)
packages/search-box/src/utils/date.ts (5)

26-45: Replace deprecated substr with substring.

The substr method is deprecated and should be replaced with substring for better compatibility.


47-47: Rename toString to avoid shadowing the global property.

The variable shadows the global toString property, which can cause confusion about its origin.


156-156: Use Number.isFinite for safer type checking.

isFinite performs type coercion which can lead to unexpected behavior. Number.isFinite is safer as it doesn't coerce the value.


358-360: Replace deprecated substr with substring.

The substr method is deprecated.


438-438: Use substring instead of substr for consistency.

The function uses both substr and substring. Stick to substring for consistency since substr is deprecated.

packages/docs/search-box/custom-panel.vue (1)

2-2: Remove unused imports.

The imports shallowRef and TinyAutocomplete are not used anywhere in the component.

🧹 Nitpick comments (1)
packages/docs/examples/events.md (1)

3-3: Wrap event literals in back-ticks for clarity

Inline-code formatting helps readers quickly distinguish event names from surrounding Chinese text.

-通过first-level-select、search、change、clear、tag-click等可以监听组件的各种事件。
+通过 `first-level-select`、`search`、`change`、`clear`、`tag-click` 等可以监听组件的各种事件。
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8cb2291 and 465c093.

📒 Files selected for processing (41)
  • packages/docs/.vitepress/theme/index.less (1 hunks)
  • packages/docs/.vitepress/theme/index.ts (0 hunks)
  • packages/docs/examples/auto-match.md (1 hunks)
  • packages/docs/examples/default-field.md (1 hunks)
  • packages/docs/examples/empty-placeholder.md (1 hunks)
  • packages/docs/examples/events.md (1 hunks)
  • packages/docs/examples/group-key.md (1 hunks)
  • packages/docs/examples/help.md (1 hunks)
  • packages/docs/examples/id-map-key.md (1 hunks)
  • packages/docs/examples/item-placeholder.md (1 hunks)
  • packages/docs/examples/max-length.md (1 hunks)
  • packages/docs/examples/panel-max-height.md (1 hunks)
  • packages/docs/examples/potential-match.md (1 hunks)
  • packages/docs/examples/split-input-value.md (1 hunks)
  • packages/docs/examples/v-model.md (1 hunks)
  • packages/docs/package.json (2 hunks)
  • packages/docs/search-box/auto-match.vue (1 hunks)
  • packages/docs/search-box/basic-usage.vue (1 hunks)
  • packages/docs/search-box/combination-panel.vue (2 hunks)
  • packages/docs/search-box/custom-panel.vue (2 hunks)
  • packages/docs/search-box/default-field.vue (1 hunks)
  • packages/docs/search-box/editable.vue (1 hunks)
  • packages/docs/search-box/empty-placeholder.vue (1 hunks)
  • packages/docs/search-box/events.vue (1 hunks)
  • packages/docs/search-box/group-key.vue (1 hunks)
  • packages/docs/search-box/help.vue (1 hunks)
  • packages/docs/search-box/id-map-key.vue (1 hunks)
  • packages/docs/search-box/item-placeholder.vue (1 hunks)
  • packages/docs/search-box/max-length.vue (1 hunks)
  • packages/docs/search-box/max-time-length.vue (1 hunks)
  • packages/docs/search-box/merge-tag.vue (1 hunks)
  • packages/docs/search-box/panel-max-height.vue (1 hunks)
  • packages/docs/search-box/potential-match.vue (1 hunks)
  • packages/docs/search-box/split-input-value.vue (1 hunks)
  • packages/docs/search-box/v-model.vue (1 hunks)
  • packages/search-box/package.json (1 hunks)
  • packages/search-box/src/composables/use-dropdown.ts (0 hunks)
  • packages/search-box/src/composables/use-init.ts (1 hunks)
  • packages/search-box/src/composables/use-match.ts (1 hunks)
  • packages/search-box/src/index.vue (5 hunks)
  • packages/search-box/src/utils/date.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/docs/.vitepress/theme/index.ts
  • packages/search-box/src/composables/use-dropdown.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/search-box/package.json
  • packages/docs/search-box/id-map-key.vue
🚧 Files skipped from review as they are similar to previous changes (34)
  • packages/docs/examples/panel-max-height.md
  • packages/docs/examples/potential-match.md
  • packages/docs/.vitepress/theme/index.less
  • packages/docs/search-box/potential-match.vue
  • packages/docs/examples/v-model.md
  • packages/docs/search-box/basic-usage.vue
  • packages/docs/search-box/group-key.vue
  • packages/docs/search-box/auto-match.vue
  • packages/docs/search-box/panel-max-height.vue
  • packages/docs/examples/split-input-value.md
  • packages/docs/examples/auto-match.md
  • packages/docs/search-box/item-placeholder.vue
  • packages/docs/examples/group-key.md
  • packages/docs/examples/help.md
  • packages/docs/examples/item-placeholder.md
  • packages/docs/examples/empty-placeholder.md
  • packages/docs/search-box/merge-tag.vue
  • packages/docs/search-box/default-field.vue
  • packages/docs/examples/default-field.md
  • packages/docs/search-box/max-time-length.vue
  • packages/docs/search-box/editable.vue
  • packages/docs/search-box/empty-placeholder.vue
  • packages/docs/search-box/help.vue
  • packages/docs/search-box/events.vue
  • packages/docs/examples/max-length.md
  • packages/docs/search-box/max-length.vue
  • packages/docs/search-box/split-input-value.vue
  • packages/docs/examples/id-map-key.md
  • packages/search-box/src/index.vue
  • packages/docs/search-box/combination-panel.vue
  • packages/docs/search-box/v-model.vue
  • packages/search-box/src/composables/use-init.ts
  • packages/search-box/src/composables/use-match.ts
  • packages/docs/package.json
🧰 Additional context used
🪛 LanguageTool
packages/docs/examples/events.md

[grammar] ~3-~3: Ensure spelling is correct
Context: ...st-level-select、search、change、clear、tag-click等可以监听组件的各种事件。 <preview path="../search-box/events.v...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🪛 Biome (1.9.4)
packages/search-box/src/utils/date.ts

[error] 51-51: Do not shadow the global "toString" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)


[error] 171-171: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.

(lint/suspicious/noGlobalIsFinite)

🔇 Additional comments (14)
packages/docs/examples/events.md (1)

5-5: Preview tag spacing fix LGTM

The removal of the extraneous space aligns this <preview> tag with others across the docs.

packages/search-box/src/utils/date.ts (12)

2-12: LGTM: Comprehensive copyright header and documentation.

The file includes proper copyright attribution and MIT license declaration, which is good for open source compliance.


48-65: LGTM: Well-structured type mapping and utility constants.

The class2type mapping and Object prototype references are properly organized for type checking utilities.


67-129: LGTM: Comprehensive type checking utilities.

The type checking functions (isNull, typeOf, isObject, isFunction, isPlainObject) are well-implemented with proper documentation and examples.


131-149: LGTM: Efficient empty object checking.

The isEmptyObject function correctly handles both objects and arrays with proper hasOwnProperty checks.


176-200: LGTM: Additional type checking utilities are well-implemented.

The isNumeric, isDate, isSame, isRegExp, and isPromise functions provide comprehensive type checking with proper logic.


202-257: LGTM: Comprehensive date constants and timezone handling.

The date validation constants, timezone definitions, and timezone calculation logic are well-structured and thorough.


259-283: LGTM: Accurate leap year and date validation logic.

The isLeapYear function correctly implements the leap year algorithm, and the date validation functions properly handle edge cases.


285-387: LGTM: Robust date parsing implementations.

The date parsers for different formats (yyyy-mm-dd, mm-dd-yyyy, ISO8601) are comprehensive and handle various edge cases properly.


389-465: LGTM: Comprehensive date array matching and parsing.

The date array matching logic properly handles various date format patterns and extracts components correctly.


467-515: LGTM: Robust date validation and parsing logic.

The validation functions properly check date ranges and the parsing logic handles different format scenarios correctly.


517-675: LGTM: Comprehensive date conversion and formatting utilities.

The toDate, format, getDateWithNewTimezone, and toDateStr functions provide extensive date manipulation capabilities with proper error handling.


677-723: LGTM: Useful additional date utilities.

The getWeekOfFirstDay function and timezone utilities provide valuable functionality for date manipulation and timezone handling.

packages/docs/search-box/custom-panel.vue (1)

37-62: LGTM: ClientOnly wrapper addresses SSR build failure.

The ClientOnly wrapper properly restricts the search-box component to client-side rendering only, which aligns with the PR objective to fix SSR build failures. The simplified template content with static placeholders is appropriate for documentation purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants