@bone-ui/checkbox
Advanced tools
Comparing version 0.36.0 to 0.37.0
@@ -10,3 +10,2 @@ 'use strict'; | ||
var utils = require('@bone-ui/utils'); | ||
var core = require('@fower/core'); | ||
var react = require('@fower/react'); | ||
@@ -185,3 +184,3 @@ var hooks = require('@bone-ui/hooks'); | ||
ref: ref, | ||
className: utils.cx('bone-checkbox-input', core.css('square0', 'opacity-0', 'hidden')), | ||
className: utils.cx('bone-checkbox-input', react.css('square0', 'opacity-0', 'hidden')), | ||
type: "checkbox", | ||
@@ -188,0 +187,0 @@ value: value |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),r=(e=n)&&"object"==typeof e&&"default"in e?e.default:e,o=require("@bone-ui/utils"),t=require("@fower/core"),l=require("@fower/react"),a=require("@bone-ui/hooks"),u=require("@bone-ui/iconify");function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}function i(e,n){if(null==e)return{};var r,o,t={},l=Object.keys(e);for(o=0;o<l.length;o++)n.indexOf(r=l[o])>=0||(t[r]=e[r]);return t}var d=n.createContext(null),s=d.Provider;function h(){return n.useContext(d)}function f(e,n){var r=e.target,o=r.value;return r.checked?[].concat(n,[o]):n.filter((function(e){return e!==o}))}function v(e){var r,o,t={},l=n.useState(null!=(r=e.disabled)&&r),u=l[0],c=l[1],i=h();null!=i&&i.controlled&&(e.checked=null==(o=i.value)?void 0:o.includes(e.value));var d=n.useState((function(){if(!i)return e.defaultChecked;var n=i.value;return null==n?void 0:n.includes(e.value)})),s=d[1],v=a.useControlledInfo(e.checked,d[0]),b=v.controlled,C=v.value;return a.useSafeLayoutEffect((function(){"boolean"==typeof e.disabled&&c(!!e.disabled)}),[e.disabled]),t.onChange=function(n){if(!i)return b||s(n.target.checked),void(null==e||null==e.onChange||e.onChange(n));var r=i.value,o=void 0===r?[]:r,t=n.target,l=t.value;if(b)s(t.checked);else{var a=f(n,o);s(a.includes(l))}null==e.onChange||e.onChange(n)},t.disabled=u,b&&(t.checked=C),{inputProps:t,state:{disabled:u,checked:C}}}var b=u.iconify({displayName:"CheckOutline",fill:"none",d:"M4.5 12.75L10.5 18.75L19.5 5.25"}),C=function(e){var n=e.checked,o=e.colorScheme,t={};return n&&(t.borderColor=o,t.bg=o),r.createElement(l.Box,Object.assign({toCenter:!0,"square-20":!0,"border-2":!0,"rounded-4":!0,borderGray400:!n},t),r.createElement(b,{white:!0,"square-20":!0,strokeWidth:4,hidden:!n}))},k=["children","colorScheme","render","value","defaultChecked","disabled","onChange"],p=o.forwardRef((function(e,n){var a=e.children,u=e.colorScheme,d=void 0===u?"brand500":u,s=e.render,f=void 0===s?C:s,b=e.value,p=e.defaultChecked,g=i(e,k),x=h(),m=v(c({},e,{onChange:function(n){return null==x||x.onChange(n),null==e||null==e.onChange?void 0:e.onChange(n)}})),y=m.inputProps,O=m.state,j=O.disabled,q={};return Reflect.has(e,"defaultChecked")?q.defaultChecked=p:q.checked=O.checked,r.createElement(l.Box,Object.assign({as:"label",className:"bone-checkbox",inlineFlex:!0,toCenterY:!0,toLeft:!0,cursorPointer:!j,cursorNotAllowed:j,"opacity-50":j},g),r.createElement("input",Object.assign({ref:n,className:o.cx("bone-checkbox-input",t.css("square0","opacity-0","hidden")),type:"checkbox",value:b},q,y)),f(c({},O,{children:a,colorScheme:d})),a&&r.createElement(l.Box,{className:"bone-checkbox-label","ml-8":!0,"leading-1em":!0},a))})),g=["defaultValue","value","onChange","options","name","children"],x=o.forwardRef((function(e,o){var t=e.children,u=i(e,g),c=function(e){var r=e.defaultValue,o=e.onChange,t=n.useState(void 0===r?[]:r),l=t[1],u=a.useControlledInfo(e.value,t[0]),c=u.controlled,i=u.value,d=void 0===i?[]:i,s=n.useCallback((function(e){c||l(e),null==o||o(e)}),[c,o]),h=n.useCallback((function(e){var n=f(e,d);s(n)}),[d,s]);return{controlled:c,value:d,onChange:h,setValue:s}}(e),d=c.value,h=c.onChange,v=c.setValue,b=c.controlled,C=n.useMemo((function(){return{controlled:b,onChange:h,value:d,setValue:v}}),[b,d,h,v]);return r.createElement(s,{value:C},r.createElement(l.Box,Object.assign({ref:o,toLeft:!0,"spaceX-8":!0},u),t))}));exports.Checkbox=p,exports.CheckboxGroup=x,exports.CheckboxGroupProvider=s,exports.checkboxGroupContext=d,exports.useCheckbox=v,exports.useCheckboxGroupContext=h; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),t=(e=n)&&"object"==typeof e&&"default"in e?e.default:e,o=require("@bone-ui/utils"),r=require("@fower/react"),l=require("@bone-ui/hooks"),a=require("@bone-ui/iconify");function u(){return(u=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}function c(e,n){if(null==e)return{};var t,o,r={},l=Object.keys(e);for(o=0;o<l.length;o++)n.indexOf(t=l[o])>=0||(r[t]=e[t]);return r}var i=n.createContext(null),d=i.Provider;function s(){return n.useContext(i)}function h(e,n){var t=e.target,o=t.value;return t.checked?[].concat(n,[o]):n.filter((function(e){return e!==o}))}function f(e){var t,o,r={},a=n.useState(null!=(t=e.disabled)&&t),u=a[0],c=a[1],i=s();null!=i&&i.controlled&&(e.checked=null==(o=i.value)?void 0:o.includes(e.value));var d=n.useState((function(){if(!i)return e.defaultChecked;var n=i.value;return null==n?void 0:n.includes(e.value)})),f=d[1],v=l.useControlledInfo(e.checked,d[0]),b=v.controlled,C=v.value;return l.useSafeLayoutEffect((function(){"boolean"==typeof e.disabled&&c(!!e.disabled)}),[e.disabled]),r.onChange=function(n){if(!i)return b||f(n.target.checked),void(null==e||null==e.onChange||e.onChange(n));var t=i.value,o=void 0===t?[]:t,r=n.target,l=r.value;if(b)f(r.checked);else{var a=h(n,o);f(a.includes(l))}null==e.onChange||e.onChange(n)},r.disabled=u,b&&(r.checked=C),{inputProps:r,state:{disabled:u,checked:C}}}var v=a.iconify({displayName:"CheckOutline",fill:"none",d:"M4.5 12.75L10.5 18.75L19.5 5.25"}),b=function(e){var n=e.checked,o=e.colorScheme,l={};return n&&(l.borderColor=o,l.bg=o),t.createElement(r.Box,Object.assign({toCenter:!0,"square-20":!0,"border-2":!0,"rounded-4":!0,borderGray400:!n},l),t.createElement(v,{white:!0,"square-20":!0,strokeWidth:4,hidden:!n}))},C=["children","colorScheme","render","value","defaultChecked","disabled","onChange"],k=o.forwardRef((function(e,n){var l=e.children,a=e.colorScheme,i=void 0===a?"brand500":a,d=e.render,h=void 0===d?b:d,v=e.value,k=e.defaultChecked,p=c(e,C),g=s(),x=f(u({},e,{onChange:function(n){return null==g||g.onChange(n),null==e||null==e.onChange?void 0:e.onChange(n)}})),m=x.inputProps,y=x.state,O=y.disabled,j={};return Reflect.has(e,"defaultChecked")?j.defaultChecked=k:j.checked=y.checked,t.createElement(r.Box,Object.assign({as:"label",className:"bone-checkbox",inlineFlex:!0,toCenterY:!0,toLeft:!0,cursorPointer:!O,cursorNotAllowed:O,"opacity-50":O},p),t.createElement("input",Object.assign({ref:n,className:o.cx("bone-checkbox-input",r.css("square0","opacity-0","hidden")),type:"checkbox",value:v},j,m)),h(u({},y,{children:l,colorScheme:i})),l&&t.createElement(r.Box,{className:"bone-checkbox-label","ml-8":!0,"leading-1em":!0},l))})),p=["defaultValue","value","onChange","options","name","children"],g=o.forwardRef((function(e,o){var a=e.children,u=c(e,p),i=function(e){var t=e.defaultValue,o=e.onChange,r=n.useState(void 0===t?[]:t),a=r[1],u=l.useControlledInfo(e.value,r[0]),c=u.controlled,i=u.value,d=void 0===i?[]:i,s=n.useCallback((function(e){c||a(e),null==o||o(e)}),[c,o]),f=n.useCallback((function(e){var n=h(e,d);s(n)}),[d,s]);return{controlled:c,value:d,onChange:f,setValue:s}}(e),s=i.value,f=i.onChange,v=i.setValue,b=i.controlled,C=n.useMemo((function(){return{controlled:b,onChange:f,value:s,setValue:v}}),[b,s,f,v]);return t.createElement(d,{value:C},t.createElement(r.Box,Object.assign({ref:o,toLeft:!0,"spaceX-8":!0},u),a))}));exports.Checkbox=k,exports.CheckboxGroup=g,exports.CheckboxGroupProvider=d,exports.checkboxGroupContext=i,exports.useCheckbox=f,exports.useCheckboxGroupContext=s; | ||
//# sourceMappingURL=checkbox.cjs.production.min.js.map |
import React, { createContext, useContext, useState, useCallback, useMemo } from 'react'; | ||
import { forwardRef, cx } from '@bone-ui/utils'; | ||
import { css } from '@fower/core'; | ||
import { Box } from '@fower/react'; | ||
import { Box, css } from '@fower/react'; | ||
import { useControlledInfo, useSafeLayoutEffect } from '@bone-ui/hooks'; | ||
@@ -6,0 +5,0 @@ import { iconify } from '@bone-ui/iconify'; |
@@ -1,2 +0,2 @@ | ||
import { FowerColor, FowerHTMLProps } from '@fower/core'; | ||
import { FowerColor, FowerHTMLProps } from '@fower/react'; | ||
import { ReactNode } from 'react'; | ||
@@ -3,0 +3,0 @@ declare type InputProps = React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>; |
{ | ||
"name": "@bone-ui/checkbox", | ||
"version": "0.36.0", | ||
"version": "0.37.0", | ||
"license": "MIT", | ||
@@ -23,4 +23,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@bone-ui/utils": "^0.36.0" | ||
"@bone-ui/utils": "^0.37.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { FowerColor, FowerHTMLProps } from '@fower/core' | ||
import { FowerColor, FowerHTMLProps } from '@fower/react' | ||
import { ReactNode } from 'react' | ||
@@ -3,0 +3,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76585
859
+ Added@bone-ui/utils@0.37.0(transitive)
- Removed@bone-ui/utils@0.36.0(transitive)
Updated@bone-ui/utils@^0.37.0