Git Product home page Git Product logo

picker's Issues

Key events on Checkbox component

The onKeyPress and onKeyDown events do not work in the Checkbox component, apart from the onKeyUp event is not found, and is in the native html component

基于antd 4.x 封装组件库时报错 Invalid hook call.

  • I have searched the issues of this repository and believe that this is not a duplicate.

Steps to reproduce

  1. 利用lerna管理前端模块
root/
  ├── packages/
      ├── ui/
          ├── package.json
      ├── fe/
          ├── package.json
// root/packages/ui/package.json
{
  ...
  "name": "my-ui",
  "version": "0.0.0",
  "peerDependencies": {
    "react": "^16.9.0",
    "react-dom": "^16.9.0"
  },
  ...
}
// root/packages/fe/package.json
{
  ...
  "dependencies": {
    "my-ui": "^0.0.0",
    "react": "^16.9.0",
    "react-dom": "^16.9.0"
  },
  ...
}
  1. 运行项目时 报错 Invalid hook call.
  2. 通过 npm ls react 发现 react 被 rc-picker 依赖进来
> root/packages/ui $ npm ls react
@gogoal/[email protected] /Users/caoyujian/workspace/lts-probe/packages/lts-probe-ui
└─┬ [email protected]
  └─┬ [email protected]
    └── [email protected] 

What is expected?

rc-picker 中的 react 依赖从 dependencies 移动至 devDependencies

What is actually happening?

运行项目时 报错 Invalid hook call.

Environment Info
antd 4.5.4
React ^16.9.0
System Mac
Browser Chrome latest

Input customization

Add prop to customize input fields.

Example

<Picker inputRender={field => <div>{field}</div>}  />

Case example: Add mask

Uncaught TypeError: date.localeData is not a function

After upgrading antd from 4.4 to 4.5 which upgrades rc-picker to 1.11, this error shows up whenever I open the RangePicker panel.

It's thrown by getShortMonths and getWeekFirstDay, and even a zero configuration <RangePicker />(no props) throws such error.

I'm using moment included in antd and don't use any other date libraries. There's also no configs related to moment in webpack or babel.
I'm using "antd-dayjs-webpack-plugin": "0.0.8".

Support for pickerValue (similar to defaultPickerValue)

Howdy,

It would be nice if the displayed month could be better controlled to prevent situations like below when using the range picker:

  1. Assume the start and end dates are currently 2021-01-01
  2. Open picker to select start date
  3. Click previous month 12 times
  4. Select 2020-01-01
  5. My code sets defaultPickerValue to [2020-01-01, 2020-01-01]
  6. Panel now "focuses" back to 2021-01-01 for choosing the start date

Now I have click previous month 12 times again to select 2020-01-01 as the end date too

Similar issue was logged in Ant Design: ant-design/ant-design#15360

clone.weekday is not a function

dayjs <= 1.8.30 没有问题
dayjs > 1.8.30 点击日期选择器直接报错

TypeError: clone.weekday is not a function
    in DateBody (created by DatePanel)
    in div (created by DatePanel)
    in DatePanel (created by PickerPanel)
    in div (created by PickerPanel)
    in PickerPanel (created by InnerPicker)
    in div (created by InnerPicker)
    in div (created by PopupInner)
    in PopupInner (created by Align)
    in Align (created by CSSMotion)
    in CSSMotion (created by ForwardRef)
    in ForwardRef (created by Popup)
    in div (created by Popup)
    in Popup (created by Trigger)
    in Portal (created by Trigger)
    in Trigger (created by PickerTrigger)
    in PickerTrigger (created by InnerPicker)
    in InnerPicker (created by Picker)
    in Picker (created by Context.Consumer)
    in LocaleReceiver (created by Picker)
    in Picker (at Header.tsx:35)
    in header (at Header.tsx:33)
    in div (at Header.tsx:32)

NPM install fails

when I try to installl this from npm, I get this error:
npm ERR! Unexpected end of JSON input while parsing near '...mNz\n8oD5xcC77i86DFzj'

And this affects antdesign too, because it is dependent on this.

Uncaught TypeError: Cannot read property 'getNow' of undefined

Hi, I am getting this error after I installed the package via yarn add rc-picker.
The input is appearing on the screen when I click on the input I get this error.
any idea why is this happening?

Uncaught TypeError: Cannot read property 'getNow' of undefined
    at postState (PickerPanel.js:124)
    at useControlledState (useMergedState.js:28)
    at PickerPanel (PickerPanel.js:120)
    at renderWithHooks (react-dom.development.js:14985)
    at mountIndeterminateComponent (react-dom.development.js:17811)
    at beginWork (react-dom.development.js:19049)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
    at invokeGuardedCallback (react-dom.development.js:4056)
    at beginWork$1 (react-dom.development.js:23964)
    at performUnitOfWork (react-dom.development.js:22776)
    at workLoopSync (react-dom.development.js:22707)
    at renderRootSync (react-dom.development.js:22670)
    at performSyncWorkOnRoot (react-dom.development.js:22293)
    at react-dom.development.js:11327
    at unstable_runWithPriority (scheduler.development.js:646)
    at runWithPriority$1 (react-dom.development.js:11276)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11322)
    at flushSyncCallbackQueue (react-dom.development.js:11309)
    at discreteUpdates$1 (react-dom.development.js:22420)
    at discreteUpdates (react-dom.development.js:3756)
    at dispatchDiscreteEvent (react-dom.development.js:5889)

generateConfig for date-fns throws error for some locales

The generateConfig methods use dealLocal() function to get date-fns specific locale data for the provided language, but the implementation fails in some cases because rc-picker locales names do not exactly match with date-fns ones.

For example Italian:

  • rc-picker use it_IT as locale name;
  • dealLocal() converts it into itIT;
  • generateConfig.getWeekFirstDay() method tries to load date-fns locale data with an itIT key, but it does not exists and this leads to clone constant to be undefined.

The only solution is to replace the current dealLocal() implementation with a static map of locales names and prevent errors with a default value:

const DEFAULT_LOCALE = 'enUS';

const LOCALES_MAP = {
  'en_US': 'enUS',
  'it_IT': 'it',
  'es_ES': 'es',

  // and so on...
}

const dealLocal = (str: string): string => LOCALES_MAP[str] || DEFAULT_LOCALE;

Missing getShortWeekdays and getShortMonths for date-fns

I just switched to date-fns and this is what my antd datepicker looks like:
Screen Shot 2020-08-14 at 10 14 17 AM

This is what it looked like before the switch (was using Dayjs):
Screen Shot 2020-08-14 at 10 14 52 AM

This is how I generate the picker:

import generatePicker from 'antd/es/date-picker/generatePicker';
import dateFnsGenerateConfig from 'rc-picker/lib/generate/dateFns';

export default generatePicker<Date>(dateFnsGenerateConfig);

And here's an example of how I render it:

      <DatePicker.RangePicker
        bordered={false}
        onChange={dates => {
          this.setDates(dates || [null, null]);
        }}
        placeholder={['Start', 'End']}
        value={[minDate, maxDate]}
      />

Looks like the config for date-fns that's generated by rc-picker is missing the methods getShortWeekdays and getShortMonths.

I am using date-fns 2.15.0. I tried both rc-picker 1.15.3 and 2.0.5 but both gave the same (broken) results.

Can I customize the ok button?

When I use the showTime attr, the ok button will appear in any case. Is this a common usage ? Or is there a prop which can customize the ok button?

[Question/Bug] Defocus click behaviour change between versions 2.5.2 and >2.5.2

Hi,

There's a behaviour change between vs 2.5.2 and beyond.

Demonstrated in https://codesandbox.io/s/gifted-grass-cejvh?file=/src/App.tsx (which allows version toggle of rc-picker).

With the following picker:
image

In 2.5.2:
Change the date from 2021-05-27 to another valid date via keyboard input (e.g. 2021-05-28)
Click outside of picker
Date stays as 2021-05-28

Beyond 2.5.2:
Change the date from 2021-05-27 to another valid date via keyboard input (e.g. 2021-05-28)
Click outside of picker
Date resets to 2021-05-27

Is this change intentional? 2.5.2 behavior is preferable for our use case.

Dayjs is not peer dependency anymore, breaks registration of plugins in client app that has also the dependency

Hi,

We have a design system library we use to support our applications. This library uses ant which uses rc-picker. We re-generate the pickers using ant, with dayjs instead of moment. In this library, we mark dayjs as a peer dependency. We also install it in our main applications where we register multiple plugins on the singleton dayjs instance. This has been made possible through #214.

However, since #270 our workflow has been broken. Since dayjs is included as a dependency here, the build of our design system library causes a dayjs singleton to be created, as does our main app. Therefore we have two singletons, and the plugins are only registered on one of them.

Allow overriding of the color on cell hover

Hi Team,
On cell hover, I wanted to override the color. However, its specified with !important attribute which is not a good practice. Could you please remove it so that it can be overridden ?

file: index.less line 106

   &:hover {
        background: fade(blue, 30%) !important;
      }

Users can't reset their panel navigations

Use case:
The user opens the picker popup, clicks on the month (switches mode to month panel), clicks some arrows (year changes), the user panics and wants to get back to original calendar view. The user clicks outside of the picker popup, causing the popup to close. Now the user expects to reopen it again in its original state.

Problem:
The picker opens in the state it was left in. It opens the last used panel, not the default "date" panel. If defaultValue is unset, it opens the last year navigated to as well.
This is a usability regression in ant-design 4. It was working fine in ant3.

Expected:
When a user cancels date picking by closing and reopening a panel, all settings should be as they were before the user did anything. Users are easily confused and expect a complete cancel functionality.

Solution:
Picker should create a new PickerPanel (e.g. by generating a new component's key). Alternatively, PickerPanel could expose a 'reset' method to set panel mode and inner view date back to their default values.
The reset should be a side effect of Picker's 'triggerInnerOpen'. Same for RangePicker.

GenerateConfig is not undefined

Is there anyone find that, Generateconfig is passed in through props, but there is no API description. As a result, the value of generateconfig is undefined and an error will be reported when using it.

Use according to novice guidelines

`export default function IndexPage() {

return (

  <Picker />

);
}`

there will be a error,because Generateconfig is undefined
`TypeError: Cannot read property 'locale' of undefined
formatValue
./node_modules/rc-picker/es/utils/dateUtil.js:126
123 | var generateConfig = _ref.generateConfig,
124 | locale = _ref.locale,
125 | format = _ref.format;

126 | return typeof format === 'function' ? format(value) : generateConfig.locale.format(locale.locale, value, format);
127 | }
128 | export function parseValue(value, _ref2) {
129 | var generateConfig = _ref2.generateConfig,
View compiled`

Is that mean we should give Generateconfig a default value from generate

Add onKeyDown event

Hi,

I would like to know if it is possible to add onKeyDown event to the picker ?

defaultPickerValue is not working

Reproduction link

https://codesandbox.io/s/rc-picker-playground-870j6?file=/src/App.tsx

Steps to reproduce

Pass defaultPickerValue only to Picker component is not working. (not with defaultValue)

What is expected?

Pass defaultPickerValue only to Picker component is working.

What is actually happening?

Pass the same value to defaultPickerValue and defaultValue in Picker component is working.
But pass only defaultPickerValue would not work.

Environment Info
moment 2.29.1
React 16.13.1
rc-picker 2.3.0
rc-utils 5.4.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.