Skip to content

Derik/en/number input#3097

Merged
James-Baloyi merged 4 commits intoshesha-io:mainfrom
HackGenesis:derik/en/numberInput
Apr 2, 2025
Merged

Derik/en/number input#3097
James-Baloyi merged 4 commits intoshesha-io:mainfrom
HackGenesis:derik/en/numberInput

Conversation

@HackGenesis
Copy link
Copy Markdown
Contributor

@HackGenesis HackGenesis commented Apr 2, 2025

refactor number input

Summary by CodeRabbit

  • New Features

    • Introduced a high precision toggle in number input settings with conditional step options and a required field validation.
  • Refactor

    • Enhanced dropdown settings for more consistent input configurations.
    • Simplified number input change handling and improved default minimum and maximum values.
  • Style

    • Refined the visual presentation of number inputs with updated styling for improved consistency.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2025

Walkthrough

This pull request updates the settings logic and styling across multiple designer components. The dropdown settings now use a revised method and updated labels. The number field components are refactored to adopt a more robust styling and property-handling approach, including new dimension-based style utilities, default value adjustments, and a removal of custom change event handling. Additionally, the number field settings now include high precision options with conditional inputs and updated validation keys.

Changes

File(s) Change Summary
shesha-reactjs/src/designer-components/dropdown/settingsForm.ts Updated getSettings by replacing .addQueryBuilder with .addSettingsInput, and modified various label properties (e.g., 'Reference List item' → 'Reference list item', 'Param' → 'Label', 'param' → 'label').
shesha-reactjs/src/designer-components/numberField/control.tsx
shesha-reactjs/src/designer-components/numberField/numberField.tsx
In the number field component, removed the internal onChangeInternal function, updated style handling by replacing getSizeStyle with dimensionStyles, set default min as 0 and max as MAX_SAFE_INTEGER, and improved property access using optional chaining.
shesha-reactjs/src/designer-components/numberField/settingsForm.ts Added new settings inputs including a highPrecision switch; introduced conditional rows for stepNumeric (numeric) and stepString (text) based on the high precision selection; and updated validation property names from minLength/maxLength to minValue/maxValue along with a new required validation switch.
shesha-reactjs/src/designer-components/numberField/styles.ts
shesha-reactjs/src/designer-components/numberField/utils.ts
Modified CSS class names and selectors for the number input, added a function dimensionStyles to compute CSS properties from dimensions, and introduced the constant MAX_SAFE_INTEGER with a value of 9007199254740991.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant DS as Dropdown Settings Form
    participant NS as NumberField Settings Form
    participant NC as NumberField Control

    U->>DS: Interact with dropdown component
    DS->>DS: Generate settings using updated getSettings (new labels & input type)

    U->>NS: Toggle highPrecision switch
    alt High Precision Enabled
        NS->>NS: Display numeric input row (stepNumeric)
    else Disabled
        NS->>NS: Display text input row (stepString)
    end
    NS->>NC: Update number field configuration with new settings
Loading
sequenceDiagram
    participant U as User Input
    participant NC as NumberField Control
    participant OE as External onChange Handler

    U->>NC: Enter or clear a number value
    NC->>OE: Directly propagate the onChange event with the new value
Loading

Possibly related PRs

Suggested reviewers

  • James-Baloyi

Poem

In a field of code where bytes do play,
This rabbit hops with glee today,
New settings sprout in dropdown and number land,
With precision tuned by a careful hand,
Codes and styles dancing in a rhythmic spree,
A joyful leap for every PR, you see!
🐇🌟

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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
Copy Markdown
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: 0

🧹 Nitpick comments (3)
shesha-reactjs/src/designer-components/numberField/settingsForm.ts (3)

164-185: Fix inconsistent parent ID assignment

The parentId in the input field (line 178) doesn't match the parent container's ID.

-      parentId: 'jNmEKg7HtYXwaL9CylTOX',
+      parentId: 's4gmBg31azZC0UjZjpfTm',

164-185: Avoid duplicate ID values

Both settings input rows use the same ID (type-default-value-s4gmBg31azZC0UjZjpfTm), which could lead to conflicts. Consider using unique identifiers.

-  id: 'type-default-value-s4gmBg31azZC0UjZjpfTm',
+  id: 'stepNumeric-input-row',

And for the second row:

-  id: 'type-default-value-s4gmBg31azZC0UjZjpfTm',
+  id: 'stepString-input-row',

Also applies to: 187-208


187-208: Fix inconsistent parent ID in stepString input

The parentId in the input field (line 201) doesn't match the parent container's ID.

-      parentId: 'jNmEKg7HtYXwaL9CylTOX',
+      parentId: 's4gmBg31azZC0UjZjpfTm',
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 532787a and 3ef40ed.

📒 Files selected for processing (1)
  • shesha-reactjs/src/designer-components/numberField/settingsForm.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-and-test
🔇 Additional comments (3)
shesha-reactjs/src/designer-components/numberField/settingsForm.ts (3)

154-162: Good addition of high precision mode

Adding a high precision toggle with clear tooltip is a good enhancement. This allows users to explicitly choose whether they need high precision decimal support.


219-229: Good addition of required field validation

Adding the required validation switch to number fields is a good enhancement that aligns with form validation best practices.


237-239: Improved validation property naming

Changing from minLength/maxLength to minValue/maxValue is semantically more accurate for number fields.

Also applies to: 245-247

@James-Baloyi James-Baloyi merged commit d5f93ec into shesha-io:main Apr 2, 2025
2 of 4 checks passed
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.

2 participants