@gifcommit/golden-grids 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Gregory Edgerton
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # Golden Grids
2
+
3
+ How I Learned to Stop Worrying about Rows and Columns and Love the Golden Ratio
4
+
5
+ [Live Demo](https://gregoryedgerton.github.io/golden-grids/)
6
+
7
+ ## What is it?
8
+
9
+ Golden Grids is a responsive CSS Grid layout library driven by the Fibonacci Sequence. Instead of traditional rows and columns you get proportionally aligned boxes that follow the golden ratio. What you do with those boxes is your business, but at least you won't be boring.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @gifcommit/golden-grids
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```tsx
20
+ import { GoldenGrid, GoldenBox, GridProvider } from '@gifcommit/golden-grids'
21
+ // CSS is auto-injected — no separate import needed
22
+
23
+ // Transparent layout slots (no color):
24
+ <GoldenGrid from={1} to={5} />
25
+
26
+ // With HSL color progression:
27
+ <GoldenGrid from={1} to={5} color="#7f7ec7" />
28
+
29
+ // With outline:
30
+ <GoldenGrid from={1} to={5} color="#7f7ec7" outline="2px solid #000000" />
31
+
32
+ // Compound component — map your content into grid slots:
33
+ <GoldenGrid from={3} to={5} color="#7f7ec7">
34
+ <GoldenBox placeholder><p>Fills the skipped-range area</p></GoldenBox>
35
+ <GoldenBox><h1>First visible box</h1></GoldenBox>
36
+ <GoldenBox><p>Second visible box</p></GoldenBox>
37
+ <GoldenBox><p>Third visible box</p></GoldenBox>
38
+ </GoldenGrid>
39
+
40
+ // With provider for dynamic/interactive control:
41
+ <GridProvider initialConfig={myConfig}>
42
+ <GoldenGrid />
43
+ </GridProvider>
44
+ ```
45
+
46
+ Extra `<GoldenBox>` children beyond the visible slot count are silently ignored, so you can always declare the full set of 78 and let the config control what renders.
47
+
48
+ ## Configuration
49
+
50
+ | Prop | Type | Description |
51
+ | ----------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
52
+ | `from` | `number` | Index position (1–78) in the Fibonacci Sequence. The library sorts your range smallest to largest automatically. |
53
+ | `to` | `number` | Another index position (1–78). Together with `from` this defines your slice of the sequence. |
54
+ | `color` | `string` (hex) | Optional base color for the HSL progression. When omitted, boxes are transparent layout slots. |
55
+ | `outline` | `string` (CSS border) | Optional border applied to all box edges — e.g. `"2px solid #000000"`. Shared edges draw a single line (no doubling). |
56
+ | `placement` | `"right" \| "bottom" \| "left" \| "top"` | Starting direction of the spiral. Defaults to `"right"`. |
57
+ | `clockwise` | `boolean` | Spiral direction — `true` for clockwise, `false` for counter-clockwise. Defaults to `true`. |
58
+ | `children` | `GoldenBox` elements | Optional slot content. Each `<GoldenBox>` maps to a visible square in order. Use `<GoldenBox placeholder>` for the skipped area. |
59
+
60
+ ## How it works
61
+
62
+ Based on your `from` and `to` index positions, the library calculates the corresponding slice of the Fibonacci Sequence (`1`, `1`, `2`, `3`, `5`, `8`, `13`, `21`, `34`, `55`, ...) and creates a responsive grid based on the golden ratio. Each number in your selected range becomes a proportionally sized square box in the grid.
63
+
64
+ A `1, 1` grid gives you two equal squares (side by side or stacked depending on your `placement` value), while a `1, 3` grid produces 4 boxes where each gets progressively larger (`1`, `1`, `2`, `3`). The Fibonacci values are used as relative ratios for each box.
65
+
66
+ ### Skipping digits
67
+
68
+ Golden Grids lets you skip numbers in the sequence and that can add just the [right amount of flair](https://www.youtube.com/watch?v=F7SNEdjftno) to your grid. When your range doesn't start at the 1st digit, the preceding space is still accounted for — not as a perfect 1:1 square, but as a single irregular box that proportionally represents all the sequenced values that were skipped. This keeps the grid golden.
69
+
70
+ ### Placement and spiral direction
71
+
72
+ The `placement` prop determines which side the spiral builds out from (`"right"`, `"bottom"`, `"left"`, or `"top"`) and `clockwise` controls the spiral direction. Using these values you can create landscape and portrait grids. Think of how we declare `padding` or `margin` — we list values top, right, bottom, left. Golden Grids uses this same approach to place boxes which create our spiral. By default the first grid item is placed to the `"right"`, then the next box goes to the `"bottom"`, then `"left"`, then `"top"`, and repeat. With `placement` you shift that starting direction and `clockwise` reverses the flow.
73
+
74
+ ### Responsiveness
75
+
76
+ Golden Grids are responsive and fill 100% of their container width. The proportions of the grid shouldn't break but I intentionally do not clip the box. Overflow management is the importers responsiblity.
77
+
78
+ ## How big can I go?
79
+
80
+ The theoretical maximum is the 78th Fibonacci number: `8,944,394,323,791,464`. That's the largest value that fits within JavaScript's `Number.MAX_SAFE_INTEGER` (`9,007,199,254,740,991`). Beyond this threshold, integer arithmetic loses precision and the sequence values can't be trusted. The library generates all 78 valid stops automatically, giving you index positions 0 through 78 to work with.
81
+
82
+ To be honest it's less about the absolute number and more about controlling the range. After all, a similar range at the start and end of the sequence renders comparably — `8/16` is still `1/2`, same relative proportions. Shorter ranges are easier on the eyes and more practical to use. You can still reach for `5,702,887`, but pair it with the 32nd digit `2,178,309` for a lovely 4-box golden grid dawg.
83
+
84
+ ## Why did I make this?
85
+
86
+ Part of me doesn't accept myself as a true engineer. It's harsh, but It's how I feel. If I was a musician I would feel the same if I hadn't wrote a song. I'm not saying that's your life, but that's mine. While coding has been my trade for many years, there's one last hurtle I have yet to climb. One last mountain to climb. The release of an open-source project. I have a lot of things I want to make with this repo, but time is precisious. Better the community have it then keep it to myself and wait another decade.
87
+
88
+ This library is meant to challenge the status quo that all things web must submit to rows and columns. Fuck that, this isn't 1984, I was born in 83, [think different](https://www.youtube.com/watch?v=5sMBhDv4sik). Ask yourself [is Golden Grids for you?](https://youtu.be/pRIIwJh1DDQ?si=LHKhOkO-RctUPEGA&t=210).
89
+
90
+ ## A long standing obsession with the Golden Ratio
91
+
92
+ The golden ratio has been a passion of mine since Philly. The 1931 commercial piece [l'Atlantique](https://www.singulart.com/en/blog/2024/11/18/latlantique-by-a-m-cassandre-bc/) by A.M. Years later I would walk into a quaint shore antingue shop while scouting locations for a music video and saw a lithograph tucked away cover in dust, it now hangs on my wall at home produly framed. I first saw it in the pages of [The History of Graphic Design (3rd Edition)](https://www.amazon.com/History-Graphic-Design-Philip-Meggs/dp/0471291986) while at college, even then it reaced out. Hidden in the smoke stack, trailing off towards the tugboat in the lower frame, is the golden ratio. It spoke to me.
93
+
94
+ During the record label years I often made 1-off landing pages for album releases and always tried to sneak the golden ratio in, placing the album art as the dominant square and using the remaining space for navigation. My first attempt at a true layout based solely on the golden ratio was in May 2016 with flexbox — a `1` to `8` golden grid built from `100vw`. It was cool but it didn't do much. I tried to use jQuery to do an infinite inward spiral but I didn't have the chops to make it happen. From there the idea sat for a while.
95
+
96
+ It wasn't until September 2024 when I saw [Mads Stoumann](https://stoumann.dk/)'s post on [Golden Ratio with CSS Grid](https://dev.to/madsstoumann/the-golden-ratio-in-css-53d0) that I rekindled my curiosity. I began by sketching a 5 box grid in my notebook and having a moment of claity on what input variables would yield the most results. From their I built a basic example and did a lot of browser sessions with chatGPT where I provided it hard coded grids in vanilla HTML/JS/CSS then prompted the model to extend variable inputs. Around March copy/pasta was getting old and the models was hitting its complexity as I attempted to port my suprisly accurate vanilla file into a react library of substance. I got few days in and waived the white flag. I had hit The Tower of Hanoi problem, the work was going backwards.
97
+
98
+ Maybe it was the [the suber bowl](https://www.youtube.com/watch?v=kQRu7DdTTVA) commericals, maybe it was more usage at work, maybe it was the fact I was 3 months into a green-scare, but on Friday Feb 13th I decided that it was time to dive back into Golden Grids. Me and my son were going camping on a frozen lake (shout-out [Pack 137](https://www.hazletcubscouts.org/)) and I had taken off to prep. I finished early so I setup Claude Code in my IDE and proposed this simple question. Why was my vanilla version always a perfect fit but the ported library version not consitently accruate as input variables changed? Within seconds Claude identified the error in my logic, it was a simple bounding box issue. [Dillon!](https://www.youtube.com/watch?v=txuWGoZF3ew)
99
+
100
+ Ever since then I've been pushing the library forward. I try not to use Claude for everything, some of the commits we share, the harder ones I just direct but I still take the time to review. The multiple spelling-mistakes... all me. I have mixed feelings on AI and I still believe that creativity is sacred, but it's also an undeniable tool in our belts. Use it with purpose.
@@ -0,0 +1,81 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".golden-grid{margin:0;padding:0;position:relative;width:100%;box-sizing:border-box}.golden-grid>.golden-grid__box{position:absolute}.golden-grid--outlined>.golden-grid__box{box-sizing:border-box}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ie=require("react");var we={exports:{}},ue={};/**
3
+ * @license React
4
+ * react-jsx-runtime.production.min.js
5
+ *
6
+ * Copyright (c) Facebook, Inc. and its affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */var Le;function _t(){if(Le)return ue;Le=1;var n=ie,i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),x=Object.prototype.hasOwnProperty,h=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function l(u,v,R){var _,O={},M=null,U=null;R!==void 0&&(M=""+R),v.key!==void 0&&(M=""+v.key),v.ref!==void 0&&(U=v.ref);for(_ in v)x.call(v,_)&&!c.hasOwnProperty(_)&&(O[_]=v[_]);if(u&&u.defaultProps)for(_ in v=u.defaultProps,v)O[_]===void 0&&(O[_]=v[_]);return{$$typeof:i,type:u,key:M,ref:U,props:O,_owner:h.current}}return ue.Fragment=s,ue.jsx=l,ue.jsxs=l,ue}var fe={};/**
11
+ * @license React
12
+ * react-jsx-runtime.development.js
13
+ *
14
+ * Copyright (c) Facebook, Inc. and its affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */var We;function Et(){return We||(We=1,process.env.NODE_ENV!=="production"&&function(){var n=ie,i=Symbol.for("react.element"),s=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),u=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),U=Symbol.for("react.offscreen"),I=Symbol.iterator,a="@@iterator";function j(e){if(e===null||typeof e!="object")return null;var t=I&&e[I]||e[a];return typeof t=="function"?t:null}var w=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function p(e){{for(var t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];N("error",e,r)}}function N(e,t,r){{var o=w.ReactDebugCurrentFrame,g=o.getStackAddendum();g!==""&&(t+="%s",r=r.concat([g]));var m=r.map(function(d){return String(d)});m.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,m)}}var H=!1,ee=!1,oe=!1,J=!1,T=!1,Z;Z=Symbol.for("react.module.reference");function te(e){return!!(typeof e=="string"||typeof e=="function"||e===x||e===c||T||e===h||e===R||e===_||J||e===U||H||ee||oe||typeof e=="object"&&e!==null&&(e.$$typeof===M||e.$$typeof===O||e.$$typeof===l||e.$$typeof===u||e.$$typeof===v||e.$$typeof===Z||e.getModuleId!==void 0))}function Q(e,t,r){var o=e.displayName;if(o)return o;var g=t.displayName||t.name||"";return g!==""?r+"("+g+")":r}function E(e){return e.displayName||"Context"}function S(e){if(e==null)return null;if(typeof e.tag=="number"&&p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case x:return"Fragment";case s:return"Portal";case c:return"Profiler";case h:return"StrictMode";case R:return"Suspense";case _:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case u:var t=e;return E(t)+".Consumer";case l:var r=e;return E(r._context)+".Provider";case v:return Q(e,e.render,"ForwardRef");case O:var o=e.displayName||null;return o!==null?o:S(e.type)||"Memo";case M:{var g=e,m=g._payload,d=g._init;try{return S(d(m))}catch{return null}}}return null}var z=Object.assign,L=0,$,F,W,A,q,b,k;function D(){}D.__reactDisabledLog=!0;function V(){{if(L===0){$=console.log,F=console.info,W=console.warn,A=console.error,q=console.group,b=console.groupCollapsed,k=console.groupEnd;var e={configurable:!0,enumerable:!0,value:D,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}L++}}function K(){{if(L--,L===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:z({},e,{value:$}),info:z({},e,{value:F}),warn:z({},e,{value:W}),error:z({},e,{value:A}),group:z({},e,{value:q}),groupCollapsed:z({},e,{value:b}),groupEnd:z({},e,{value:k})})}L<0&&p("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var re=w.ReactCurrentDispatcher,y;function de(e,t,r){{if(y===void 0)try{throw Error()}catch(g){var o=g.stack.trim().match(/\n( *(at )?)/);y=o&&o[1]||""}return`
19
+ `+y+e}}var ye=!1,he;{var Ke=typeof WeakMap=="function"?WeakMap:Map;he=new Ke}function Pe(e,t){if(!e||ye)return"";{var r=he.get(e);if(r!==void 0)return r}var o;ye=!0;var g=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var m;m=re.current,re.current=null,V();try{if(t){var d=function(){throw Error()};if(Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(G){o=G}Reflect.construct(e,[],d)}else{try{d.call()}catch(G){o=G}e.call(d.prototype)}}else{try{throw Error()}catch(G){o=G}e()}}catch(G){if(G&&o&&typeof G.stack=="string"){for(var f=G.stack.split(`
20
+ `),Y=o.stack.split(`
21
+ `),C=f.length-1,P=Y.length-1;C>=1&&P>=0&&f[C]!==Y[P];)P--;for(;C>=1&&P>=0;C--,P--)if(f[C]!==Y[P]){if(C!==1||P!==1)do if(C--,P--,P<0||f[C]!==Y[P]){var B=`
22
+ `+f[C].replace(" at new "," at ");return e.displayName&&B.includes("<anonymous>")&&(B=B.replace("<anonymous>",e.displayName)),typeof e=="function"&&he.set(e,B),B}while(C>=1&&P>=0);break}}}finally{ye=!1,re.current=m,K(),Error.prepareStackTrace=g}var se=e?e.displayName||e.name:"",ne=se?de(se):"";return typeof e=="function"&&he.set(e,ne),ne}function Ze(e,t,r){return Pe(e,!1)}function Qe(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function ge(e,t,r){if(e==null)return"";if(typeof e=="function")return Pe(e,Qe(e));if(typeof e=="string")return de(e);switch(e){case R:return de("Suspense");case _:return de("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return Ze(e.render);case O:return ge(e.type,t,r);case M:{var o=e,g=o._payload,m=o._init;try{return ge(m(g),t,r)}catch{}}}return""}var le=Object.prototype.hasOwnProperty,Oe={},$e=w.ReactDebugCurrentFrame;function ve(e){if(e){var t=e._owner,r=ge(e.type,e._source,t?t.type:null);$e.setExtraStackFrame(r)}else $e.setExtraStackFrame(null)}function qe(e,t,r,o,g){{var m=Function.call.bind(le);for(var d in e)if(m(e,d)){var f=void 0;try{if(typeof e[d]!="function"){var Y=Error((o||"React class")+": "+r+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Y.name="Invariant Violation",Y}f=e[d](t,d,o,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(C){f=C}f&&!(f instanceof Error)&&(ve(g),p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",o||"React class",r,d,typeof f),ve(null)),f instanceof Error&&!(f.message in Oe)&&(Oe[f.message]=!0,ve(g),p("Failed %s type: %s",r,f.message),ve(null))}}}var et=Array.isArray;function me(e){return et(e)}function tt(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,r=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r}}function rt(e){try{return je(e),!1}catch{return!0}}function je(e){return""+e}function ke(e){if(rt(e))return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",tt(e)),je(e)}var ce=w.ReactCurrentOwner,nt={key:!0,ref:!0,__self:!0,__source:!0},Ie,De,be;be={};function it(e){if(le.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function ot(e){if(le.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function at(e,t){if(typeof e.ref=="string"&&ce.current&&t&&ce.current.stateNode!==t){var r=S(ce.current.type);be[r]||(p('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',S(ce.current.type),e.ref),be[r]=!0)}}function st(e,t){{var r=function(){Ie||(Ie=!0,p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}}function lt(e,t){{var r=function(){De||(De=!0,p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}}var ct=function(e,t,r,o,g,m,d){var f={$$typeof:i,type:e,key:t,ref:r,props:d,_owner:m};return f._store={},Object.defineProperty(f._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(f,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(f,"_source",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.freeze&&(Object.freeze(f.props),Object.freeze(f)),f};function ut(e,t,r,o,g){{var m,d={},f=null,Y=null;r!==void 0&&(ke(r),f=""+r),ot(t)&&(ke(t.key),f=""+t.key),it(t)&&(Y=t.ref,at(t,g));for(m in t)le.call(t,m)&&!nt.hasOwnProperty(m)&&(d[m]=t[m]);if(e&&e.defaultProps){var C=e.defaultProps;for(m in C)d[m]===void 0&&(d[m]=C[m])}if(f||Y){var P=typeof e=="function"?e.displayName||e.name||"Unknown":e;f&&st(d,P),Y&&lt(d,P)}return ct(e,f,Y,g,o,ce.current,d)}}var xe=w.ReactCurrentOwner,Me=w.ReactDebugCurrentFrame;function ae(e){if(e){var t=e._owner,r=ge(e.type,e._source,t?t.type:null);Me.setExtraStackFrame(r)}else Me.setExtraStackFrame(null)}var _e;_e=!1;function Ee(e){return typeof e=="object"&&e!==null&&e.$$typeof===i}function Fe(){{if(xe.current){var e=S(xe.current.type);if(e)return`
23
+
24
+ Check the render method of \``+e+"`."}return""}}function ft(e){{if(e!==void 0){var t=e.fileName.replace(/^.*[\\\/]/,""),r=e.lineNumber;return`
25
+
26
+ Check your code at `+t+":"+r+"."}return""}}var Ae={};function dt(e){{var t=Fe();if(!t){var r=typeof e=="string"?e:e.displayName||e.name;r&&(t=`
27
+
28
+ Check the top-level render call using <`+r+">.")}return t}}function Ye(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=dt(t);if(Ae[r])return;Ae[r]=!0;var o="";e&&e._owner&&e._owner!==xe.current&&(o=" It was passed a child from "+S(e._owner.type)+"."),ae(e),p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,o),ae(null)}}function Ge(e,t){{if(typeof e!="object")return;if(me(e))for(var r=0;r<e.length;r++){var o=e[r];Ee(o)&&Ye(o,t)}else if(Ee(e))e._store&&(e._store.validated=!0);else if(e){var g=j(e);if(typeof g=="function"&&g!==e.entries)for(var m=g.call(e),d;!(d=m.next()).done;)Ee(d.value)&&Ye(d.value,t)}}}function ht(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===v||t.$$typeof===O))r=t.propTypes;else return;if(r){var o=S(t);qe(r,e.props,"prop",o,e)}else if(t.PropTypes!==void 0&&!_e){_e=!0;var g=S(t);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",g||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function gt(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var o=t[r];if(o!=="children"&&o!=="key"){ae(e),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",o),ae(null);break}}e.ref!==null&&(ae(e),p("Invalid attribute `ref` supplied to `React.Fragment`."),ae(null))}}var Ne={};function ze(e,t,r,o,g,m){{var d=te(e);if(!d){var f="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(f+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Y=ft(g);Y?f+=Y:f+=Fe();var C;e===null?C="null":me(e)?C="array":e!==void 0&&e.$$typeof===i?(C="<"+(S(e.type)||"Unknown")+" />",f=" Did you accidentally export a JSX literal instead of a component?"):C=typeof e,p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",C,f)}var P=ut(e,t,r,g,m);if(P==null)return P;if(d){var B=t.children;if(B!==void 0)if(o)if(me(B)){for(var se=0;se<B.length;se++)Ge(B[se],e);Object.freeze&&Object.freeze(B)}else p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ge(B,e)}if(le.call(t,"key")){var ne=S(e),G=Object.keys(t).filter(function(xt){return xt!=="key"}),Re=G.length>0?"{key: someKey, "+G.join(": ..., ")+": ...}":"{key: someKey}";if(!Ne[ne+Re]){var bt=G.length>0?"{"+G.join(": ..., ")+": ...}":"{}";p(`A props object containing a "key" prop is being spread into JSX:
29
+ let props = %s;
30
+ <%s {...props} />
31
+ React keys must be passed directly to JSX without using spread:
32
+ let props = %s;
33
+ <%s key={someKey} {...props} />`,Re,ne,bt,ne),Ne[ne+Re]=!0}}return e===x?gt(P):ht(P),P}}function vt(e,t,r){return ze(e,t,r,!0)}function pt(e,t,r){return ze(e,t,r,!1)}var yt=pt,mt=vt;fe.Fragment=x,fe.jsx=yt,fe.jsxs=mt}()),fe}process.env.NODE_ENV==="production"?we.exports=_t():we.exports=Et();var X=we.exports;const Te=(()=>{const n=[0];let i=1,s=1;for(;i<=Number.MAX_SAFE_INTEGER;)n.push(i),[i,s]=[s,i+s];return n})();function Be(n){const i=[1,1];for(;i[i.length-1]<n;)i.push(i[i.length-1]+i[i.length-2]);return i.filter(s=>s<=n)}function Ce(n,i){let s=Math.min(n,i),x=Math.max(n,i);if(x===0)return null;s===0&&(s=1);const h=s-1,c=x-1,l=[1,1];for(;l.length<=c;)l.push(l[l.length-1]+l[l.length-2]);return{userSequence:l.slice(h,c+1),startIdx:h,endIdx:c}}const Ue=ie.createContext({inputControl:{from:1,to:1,color:"#7f7ec7",clockwise:!0,placement:"right"},setInputControl:()=>{}}),Rt=({children:n,initialConfig:i})=>{if(!n)return X.jsx(X.Fragment,{});const[s,x]=ie.useState({from:1,to:4,color:"#7f7ec7",clockwise:!0,placement:"right",...i}),h=c=>{const{from:l,to:u}=c;l<0||l>=Te.length||u<0||u>=Te.length||!Number.isInteger(l)||!Number.isInteger(u)||x(c)};return X.jsx(Ue.Provider,{value:{inputControl:s,setInputControl:h},children:n})},Ve=()=>{const n=ie.useContext(Ue);if(!n)throw new Error("useGrid must be used within a GridProvider");return n};function Xe(n,i,s){const h={right:0,bottom:90,left:180,top:270}[n];if(s<2)return(h+360)%360;const u=(i?[90,180,270,0]:[270,180,90,0])[(s-2)%4];return(h-u+360)%360}function Se(n,i=!0,s=0){if(n.length<2)throw new Error("Need at least two numbers in the sequence.");if(![0,90,180,270].includes(s))throw new Error(`Invalid rotation value: ${s}. Only 0, 90, 180, and 270 are allowed.`);const h=[];let c=1/0,l=-1/0,u=1/0,v=-1/0;function R(a){a.x<c&&(c=a.x),a.x+a.size-1>l&&(l=a.x+a.size-1),a.y<u&&(u=a.y),a.y+a.size-1>v&&(v=a.y+a.size-1)}function _(){c=1/0,l=-1/0,u=1/0,v=-1/0;for(const a of h)R(a)}h.push({size:n[0],x:0,y:0}),h.push({size:n[1],x:n[0],y:0}),R(h[0]),R(h[1]);const O=i?[{dx:0,dy:1},{dx:-1,dy:0},{dx:0,dy:-1},{dx:1,dy:0}]:[{dx:0,dy:-1},{dx:-1,dy:0},{dx:0,dy:1},{dx:1,dy:0}];let M=0;for(let a=2;a<n.length;a++){const j=n[a],w=O[M];let p,N;w.dx===0&&w.dy===1?(p=c,N=v+1):w.dx===-1&&w.dy===0?(p=c-j,N=v-j+1):w.dx===0&&w.dy===-1?(p=l-j+1,N=u-j):(p=l+1,N=u);const H={size:j,x:p,y:N};h.push(H),R(H),M=(M+1)%O.length}s&&(h.forEach(a=>{const j=a.x,w=a.y;s===90?(a.x=-w-a.size+1,a.y=j):s===180?(a.x=-j-a.size+1,a.y=-w-a.size+1):s===270&&(a.x=w,a.y=-j-a.size+1)}),_());const U=l-c+1,I=v-u+1;return{squares:h,width:U,height:I,minX:c,minY:u}}function He(n){n=n.replace(/^#/,"");let i=parseInt(n.substring(0,2),16)/255,s=parseInt(n.substring(2,4),16)/255,x=parseInt(n.substring(4,6),16)/255,h=Math.max(i,s,x),c=Math.min(i,s,x),l=0,u=0,v=(h+c)/2;if(h!==c){let R=h-c;switch(u=v>.5?R/(2-h-c):R/(h+c),h){case i:l=(s-x)/R+(s<x?6:0);break;case s:l=(x-i)/R+2;break;case x:l=(i-s)/R+4;break}l=l/6}return[l*360,u*100,v*100]}function pe(n,i,s){return`hsl(${n}, ${i}%, ${s}%)`}const Je=({children:n,className:i,style:s})=>X.jsx("div",{className:i,style:{width:"100%",height:"100%",position:"relative",...s},children:n});const wt=n=>{const{inputControl:i}=Ve(),s=n.from??i.from,x=n.to??i.to,h="color"in n?n.color:i.color,c=n.clockwise??i.clockwise,l=n.placement??i.placement,u="outline"in n?n.outline:void 0,v=!!u,R=u?{borderTop:u,borderLeft:u}:{},_=u?{borderRight:u,borderBottom:u}:{},O=ie.Children.toArray(n.children).filter(b=>ie.isValidElement(b)&&b.type===Je),M=O.find(b=>b.props.placeholder)??null,U=O.filter(b=>!b.props.placeholder);let I=s,a=x;I>a&&([I,a]=[a,I]);const j=Ce(I,a);if(!j)return X.jsx("div",{className:"golden-grid"});const{userSequence:w,startIdx:p,endIdx:N}=j,H=Xe(l,c,p),ee=Math.max(...w),oe=Be(ee),J=h||void 0,[T,Z,te]=J?He(J):[0,0,50],Q=`golden-grid${v?" golden-grid--outlined":""}`;if(p===0&&N===0){const b=J?pe(T,Z,te):void 0;return X.jsx("div",{className:Q,style:{aspectRatio:"1 / 1",...R},children:X.jsx("div",{className:"golden-grid__box",style:{left:0,top:0,width:"100%",height:"100%",background:b,..._},children:U[0]??null})})}const E=Se(oe,c,H),S=E.squares.slice(p,N+1),z=E.squares.slice(0,p),L=z.length>0;let $=null;if(L){let b=1/0,k=-1/0,D=1/0,V=-1/0;for(const y of z)y.x<b&&(b=y.x),y.x+y.size-1>k&&(k=y.x+y.size-1),y.y<D&&(D=y.y),y.y+y.size-1>V&&(V=y.y+y.size-1);const K=k-b+1,re=V-D+1;$={left:`${(b-E.minX)/E.width*100}%`,top:`${(D-E.minY)/E.height*100}%`,width:`${K/E.width*100}%`,height:`${re/E.height*100}%`,background:J??void 0,..._}}const F=S.length,W=Math.min(330,180+Math.max(0,F-4)*15),A=Math.min(50,F*3),q=S.map((b,k)=>{if(!J)return;let D=0;F>1?D=L?(k+1)/(F+1):k/(F-1):L&&(D=.5);const V=(T+W*D)%360,K=Math.max(10,Math.min(90,te+A/2-D*A));return pe(V,Z,K)});return X.jsxs("div",{className:Q,style:{aspectRatio:`${E.width} / ${E.height}`,...R},children:[L&&$&&X.jsx("div",{className:"golden-grid__box golden-grid__box--placeholder",style:$,children:M}),S.map((b,k)=>X.jsx("div",{className:"golden-grid__box",style:{left:`${(b.x-E.minX)/E.width*100}%`,top:`${(b.y-E.minY)/E.height*100}%`,width:`${b.size/E.width*100}%`,height:`${b.size/E.height*100}%`,background:q[k],..._},children:U[k]??null},k))]})};function Tt(n,i,s,x,h,c){let l=n,u=i;l>u&&([l,u]=[u,l]);const v=Ce(l,u);if(!v)return"<!-- No grid to render -->";const{userSequence:R,startIdx:_,endIdx:O}=v,M=Math.max(...R),U=Be(M),I=s||void 0,[a,j,w]=I?He(I):[0,0,50],p=!!c,N=`golden-grid${p?" golden-grid--outlined":""}`,H=c?` style="border-top: ${c}; border-left: ${c};"`:"",ee=c?` border-right: ${c}; border-bottom: ${c};`:"",oe=p?`
34
+ .golden-grid--outlined > .golden-grid__box { box-sizing: border-box; }`:"";if(_===0&&O===0){const $=I?` background: ${pe(a,j,w)};`:"";return`<!DOCTYPE html>
35
+ <html lang="en">
36
+ <head>
37
+ <meta charset="UTF-8">
38
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
39
+ <title>Golden Grid</title>
40
+ <style>
41
+ body { margin: 0; padding: 0; }
42
+ .golden-grid {
43
+ margin: 0; padding: 0;
44
+ position: relative; width: 100%; aspect-ratio: 1 / 1;
45
+ }
46
+ .golden-grid > .golden-grid__box { position: absolute; }${oe}
47
+ </style>
48
+ </head>
49
+ <body>
50
+ <div class="${N}"${H}>
51
+ <div class="golden-grid__box" style="left: 0; top: 0; width: 100%; height: 100%;${$}${ee}"></div>
52
+ </div>
53
+ </body>
54
+ </html>`}const J=Xe(h,x,_),T=Se(U,x,J),Z=T.squares.slice(_,O+1),te=T.squares.slice(0,_),Q=te.length>0,E=[];if(Q){let $=1/0,F=-1/0,W=1/0,A=-1/0;for(const y of te)y.x<$&&($=y.x),y.x+y.size-1>F&&(F=y.x+y.size-1),y.y<W&&(W=y.y),y.y+y.size-1>A&&(A=y.y+y.size-1);const q=F-$+1,b=A-W+1,k=($-T.minX)/T.width*100,D=(W-T.minY)/T.height*100,V=q/T.width*100,K=b/T.height*100,re=I?` background: ${I};`:"";E.push(` <div class="golden-grid__box golden-grid__box--placeholder" style="left: ${k}%; top: ${D}%; width: ${V}%; height: ${K}%;${re}${ee}"></div>`)}const S=Z.length,z=Math.min(330,180+Math.max(0,S-4)*15),L=Math.min(50,S*3);return Z.forEach(($,F)=>{let W=a,A=0;S>1?(Q?A=(F+1)/(S+1):A=F/(S-1),W=(a+z*A)%360):Q&&(A=.5,W=(a+z*.5)%360);const q=Math.max(10,Math.min(90,w+L/2-A*L)),b=($.x-T.minX)/T.width*100,k=($.y-T.minY)/T.height*100,D=$.size/T.width*100,V=$.size/T.height*100,K=I?` background: ${pe(W,j,q)};`:"";E.push(` <div class="golden-grid__box" style="left: ${b}%; top: ${k}%; width: ${D}%; height: ${V}%;${K}${ee}"></div>`)}),`<!DOCTYPE html>
55
+ <html lang="en">
56
+ <head>
57
+ <meta charset="UTF-8">
58
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
59
+ <title>Golden Grid</title>
60
+ <style>
61
+ body { margin: 0; padding: 0; }
62
+ .golden-grid {
63
+ margin: 0;
64
+ padding: 0;
65
+ position: relative;
66
+ width: 100%;
67
+ box-sizing: border-box;
68
+ aspect-ratio: ${T.width} / ${T.height};
69
+ }
70
+ .golden-grid > .golden-grid__box {
71
+ position: absolute;
72
+ }${oe}
73
+ </style>
74
+ </head>
75
+ <body>
76
+ <div class="${N}"${H}>
77
+ ${E.join(`
78
+ `)}
79
+ </div>
80
+ </body>
81
+ </html>`}exports.FIB_STOPS=Te;exports.GoldenBox=Je;exports.GoldenGrid=wt;exports.GridProvider=Rt;exports.generateGoldenGridLayout=Se;exports.generateGridHTML=Tt;exports.getGridRange=Ce;exports.useGrid=Ve;
@@ -0,0 +1,926 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".golden-grid{margin:0;padding:0;position:relative;width:100%;box-sizing:border-box}.golden-grid>.golden-grid__box{position:absolute}.golden-grid--outlined>.golden-grid__box{box-sizing:border-box}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
2
+ import ge, { createContext as bt, useState as xt, useContext as _t } from "react";
3
+ var we = { exports: {} }, ce = {};
4
+ /**
5
+ * @license React
6
+ * react-jsx-runtime.production.min.js
7
+ *
8
+ * Copyright (c) Facebook, Inc. and its affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+ var Ne;
14
+ function Et() {
15
+ if (Ne)
16
+ return ce;
17
+ Ne = 1;
18
+ var n = ge, i = Symbol.for("react.element"), s = Symbol.for("react.fragment"), x = Object.prototype.hasOwnProperty, h = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, c = { key: !0, ref: !0, __self: !0, __source: !0 };
19
+ function l(u, g, R) {
20
+ var _, $ = {}, M = null, U = null;
21
+ R !== void 0 && (M = "" + R), g.key !== void 0 && (M = "" + g.key), g.ref !== void 0 && (U = g.ref);
22
+ for (_ in g)
23
+ x.call(g, _) && !c.hasOwnProperty(_) && ($[_] = g[_]);
24
+ if (u && u.defaultProps)
25
+ for (_ in g = u.defaultProps, g)
26
+ $[_] === void 0 && ($[_] = g[_]);
27
+ return { $$typeof: i, type: u, key: M, ref: U, props: $, _owner: h.current };
28
+ }
29
+ return ce.Fragment = s, ce.jsx = l, ce.jsxs = l, ce;
30
+ }
31
+ var ue = {};
32
+ /**
33
+ * @license React
34
+ * react-jsx-runtime.development.js
35
+ *
36
+ * Copyright (c) Facebook, Inc. and its affiliates.
37
+ *
38
+ * This source code is licensed under the MIT license found in the
39
+ * LICENSE file in the root directory of this source tree.
40
+ */
41
+ var ze;
42
+ function Rt() {
43
+ return ze || (ze = 1, process.env.NODE_ENV !== "production" && function() {
44
+ var n = ge, i = Symbol.for("react.element"), s = Symbol.for("react.portal"), x = Symbol.for("react.fragment"), h = Symbol.for("react.strict_mode"), c = Symbol.for("react.profiler"), l = Symbol.for("react.provider"), u = Symbol.for("react.context"), g = Symbol.for("react.forward_ref"), R = Symbol.for("react.suspense"), _ = Symbol.for("react.suspense_list"), $ = Symbol.for("react.memo"), M = Symbol.for("react.lazy"), U = Symbol.for("react.offscreen"), I = Symbol.iterator, a = "@@iterator";
45
+ function j(e) {
46
+ if (e === null || typeof e != "object")
47
+ return null;
48
+ var t = I && e[I] || e[a];
49
+ return typeof t == "function" ? t : null;
50
+ }
51
+ var w = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
52
+ function p(e) {
53
+ {
54
+ for (var t = arguments.length, r = new Array(t > 1 ? t - 1 : 0), o = 1; o < t; o++)
55
+ r[o - 1] = arguments[o];
56
+ z("error", e, r);
57
+ }
58
+ }
59
+ function z(e, t, r) {
60
+ {
61
+ var o = w.ReactDebugCurrentFrame, v = o.getStackAddendum();
62
+ v !== "" && (t += "%s", r = r.concat([v]));
63
+ var m = r.map(function(d) {
64
+ return String(d);
65
+ });
66
+ m.unshift("Warning: " + t), Function.prototype.apply.call(console[e], console, m);
67
+ }
68
+ }
69
+ var H = !1, ee = !1, ie = !1, J = !1, C = !1, Z;
70
+ Z = Symbol.for("react.module.reference");
71
+ function te(e) {
72
+ return !!(typeof e == "string" || typeof e == "function" || e === x || e === c || C || e === h || e === R || e === _ || J || e === U || H || ee || ie || typeof e == "object" && e !== null && (e.$$typeof === M || e.$$typeof === $ || e.$$typeof === l || e.$$typeof === u || e.$$typeof === g || // This needs to include all possible module reference object
73
+ // types supported by any Flight configuration anywhere since
74
+ // we don't know which Flight build this will end up being used
75
+ // with.
76
+ e.$$typeof === Z || e.getModuleId !== void 0));
77
+ }
78
+ function Q(e, t, r) {
79
+ var o = e.displayName;
80
+ if (o)
81
+ return o;
82
+ var v = t.displayName || t.name || "";
83
+ return v !== "" ? r + "(" + v + ")" : r;
84
+ }
85
+ function E(e) {
86
+ return e.displayName || "Context";
87
+ }
88
+ function S(e) {
89
+ if (e == null)
90
+ return null;
91
+ if (typeof e.tag == "number" && p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
92
+ return e.displayName || e.name || null;
93
+ if (typeof e == "string")
94
+ return e;
95
+ switch (e) {
96
+ case x:
97
+ return "Fragment";
98
+ case s:
99
+ return "Portal";
100
+ case c:
101
+ return "Profiler";
102
+ case h:
103
+ return "StrictMode";
104
+ case R:
105
+ return "Suspense";
106
+ case _:
107
+ return "SuspenseList";
108
+ }
109
+ if (typeof e == "object")
110
+ switch (e.$$typeof) {
111
+ case u:
112
+ var t = e;
113
+ return E(t) + ".Consumer";
114
+ case l:
115
+ var r = e;
116
+ return E(r._context) + ".Provider";
117
+ case g:
118
+ return Q(e, e.render, "ForwardRef");
119
+ case $:
120
+ var o = e.displayName || null;
121
+ return o !== null ? o : S(e.type) || "Memo";
122
+ case M: {
123
+ var v = e, m = v._payload, d = v._init;
124
+ try {
125
+ return S(d(m));
126
+ } catch {
127
+ return null;
128
+ }
129
+ }
130
+ }
131
+ return null;
132
+ }
133
+ var W = Object.assign, G = 0, O, F, L, A, q, b, k;
134
+ function D() {
135
+ }
136
+ D.__reactDisabledLog = !0;
137
+ function V() {
138
+ {
139
+ if (G === 0) {
140
+ O = console.log, F = console.info, L = console.warn, A = console.error, q = console.group, b = console.groupCollapsed, k = console.groupEnd;
141
+ var e = {
142
+ configurable: !0,
143
+ enumerable: !0,
144
+ value: D,
145
+ writable: !0
146
+ };
147
+ Object.defineProperties(console, {
148
+ info: e,
149
+ log: e,
150
+ warn: e,
151
+ error: e,
152
+ group: e,
153
+ groupCollapsed: e,
154
+ groupEnd: e
155
+ });
156
+ }
157
+ G++;
158
+ }
159
+ }
160
+ function K() {
161
+ {
162
+ if (G--, G === 0) {
163
+ var e = {
164
+ configurable: !0,
165
+ enumerable: !0,
166
+ writable: !0
167
+ };
168
+ Object.defineProperties(console, {
169
+ log: W({}, e, {
170
+ value: O
171
+ }),
172
+ info: W({}, e, {
173
+ value: F
174
+ }),
175
+ warn: W({}, e, {
176
+ value: L
177
+ }),
178
+ error: W({}, e, {
179
+ value: A
180
+ }),
181
+ group: W({}, e, {
182
+ value: q
183
+ }),
184
+ groupCollapsed: W({}, e, {
185
+ value: b
186
+ }),
187
+ groupEnd: W({}, e, {
188
+ value: k
189
+ })
190
+ });
191
+ }
192
+ G < 0 && p("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
193
+ }
194
+ }
195
+ var re = w.ReactCurrentDispatcher, y;
196
+ function fe(e, t, r) {
197
+ {
198
+ if (y === void 0)
199
+ try {
200
+ throw Error();
201
+ } catch (v) {
202
+ var o = v.stack.trim().match(/\n( *(at )?)/);
203
+ y = o && o[1] || "";
204
+ }
205
+ return `
206
+ ` + y + e;
207
+ }
208
+ }
209
+ var ye = !1, de;
210
+ {
211
+ var He = typeof WeakMap == "function" ? WeakMap : Map;
212
+ de = new He();
213
+ }
214
+ function Ce(e, t) {
215
+ if (!e || ye)
216
+ return "";
217
+ {
218
+ var r = de.get(e);
219
+ if (r !== void 0)
220
+ return r;
221
+ }
222
+ var o;
223
+ ye = !0;
224
+ var v = Error.prepareStackTrace;
225
+ Error.prepareStackTrace = void 0;
226
+ var m;
227
+ m = re.current, re.current = null, V();
228
+ try {
229
+ if (t) {
230
+ var d = function() {
231
+ throw Error();
232
+ };
233
+ if (Object.defineProperty(d.prototype, "props", {
234
+ set: function() {
235
+ throw Error();
236
+ }
237
+ }), typeof Reflect == "object" && Reflect.construct) {
238
+ try {
239
+ Reflect.construct(d, []);
240
+ } catch (N) {
241
+ o = N;
242
+ }
243
+ Reflect.construct(e, [], d);
244
+ } else {
245
+ try {
246
+ d.call();
247
+ } catch (N) {
248
+ o = N;
249
+ }
250
+ e.call(d.prototype);
251
+ }
252
+ } else {
253
+ try {
254
+ throw Error();
255
+ } catch (N) {
256
+ o = N;
257
+ }
258
+ e();
259
+ }
260
+ } catch (N) {
261
+ if (N && o && typeof N.stack == "string") {
262
+ for (var f = N.stack.split(`
263
+ `), Y = o.stack.split(`
264
+ `), T = f.length - 1, P = Y.length - 1; T >= 1 && P >= 0 && f[T] !== Y[P]; )
265
+ P--;
266
+ for (; T >= 1 && P >= 0; T--, P--)
267
+ if (f[T] !== Y[P]) {
268
+ if (T !== 1 || P !== 1)
269
+ do
270
+ if (T--, P--, P < 0 || f[T] !== Y[P]) {
271
+ var B = `
272
+ ` + f[T].replace(" at new ", " at ");
273
+ return e.displayName && B.includes("<anonymous>") && (B = B.replace("<anonymous>", e.displayName)), typeof e == "function" && de.set(e, B), B;
274
+ }
275
+ while (T >= 1 && P >= 0);
276
+ break;
277
+ }
278
+ }
279
+ } finally {
280
+ ye = !1, re.current = m, K(), Error.prepareStackTrace = v;
281
+ }
282
+ var ae = e ? e.displayName || e.name : "", ne = ae ? fe(ae) : "";
283
+ return typeof e == "function" && de.set(e, ne), ne;
284
+ }
285
+ function Je(e, t, r) {
286
+ return Ce(e, !1);
287
+ }
288
+ function Ke(e) {
289
+ var t = e.prototype;
290
+ return !!(t && t.isReactComponent);
291
+ }
292
+ function he(e, t, r) {
293
+ if (e == null)
294
+ return "";
295
+ if (typeof e == "function")
296
+ return Ce(e, Ke(e));
297
+ if (typeof e == "string")
298
+ return fe(e);
299
+ switch (e) {
300
+ case R:
301
+ return fe("Suspense");
302
+ case _:
303
+ return fe("SuspenseList");
304
+ }
305
+ if (typeof e == "object")
306
+ switch (e.$$typeof) {
307
+ case g:
308
+ return Je(e.render);
309
+ case $:
310
+ return he(e.type, t, r);
311
+ case M: {
312
+ var o = e, v = o._payload, m = o._init;
313
+ try {
314
+ return he(m(v), t, r);
315
+ } catch {
316
+ }
317
+ }
318
+ }
319
+ return "";
320
+ }
321
+ var se = Object.prototype.hasOwnProperty, Te = {}, Se = w.ReactDebugCurrentFrame;
322
+ function ve(e) {
323
+ if (e) {
324
+ var t = e._owner, r = he(e.type, e._source, t ? t.type : null);
325
+ Se.setExtraStackFrame(r);
326
+ } else
327
+ Se.setExtraStackFrame(null);
328
+ }
329
+ function Ze(e, t, r, o, v) {
330
+ {
331
+ var m = Function.call.bind(se);
332
+ for (var d in e)
333
+ if (m(e, d)) {
334
+ var f = void 0;
335
+ try {
336
+ if (typeof e[d] != "function") {
337
+ var Y = Error((o || "React class") + ": " + r + " type `" + d + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[d] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
338
+ throw Y.name = "Invariant Violation", Y;
339
+ }
340
+ f = e[d](t, d, o, r, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
341
+ } catch (T) {
342
+ f = T;
343
+ }
344
+ f && !(f instanceof Error) && (ve(v), p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", o || "React class", r, d, typeof f), ve(null)), f instanceof Error && !(f.message in Te) && (Te[f.message] = !0, ve(v), p("Failed %s type: %s", r, f.message), ve(null));
345
+ }
346
+ }
347
+ }
348
+ var Qe = Array.isArray;
349
+ function me(e) {
350
+ return Qe(e);
351
+ }
352
+ function qe(e) {
353
+ {
354
+ var t = typeof Symbol == "function" && Symbol.toStringTag, r = t && e[Symbol.toStringTag] || e.constructor.name || "Object";
355
+ return r;
356
+ }
357
+ }
358
+ function et(e) {
359
+ try {
360
+ return Pe(e), !1;
361
+ } catch {
362
+ return !0;
363
+ }
364
+ }
365
+ function Pe(e) {
366
+ return "" + e;
367
+ }
368
+ function $e(e) {
369
+ if (et(e))
370
+ return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", qe(e)), Pe(e);
371
+ }
372
+ var le = w.ReactCurrentOwner, tt = {
373
+ key: !0,
374
+ ref: !0,
375
+ __self: !0,
376
+ __source: !0
377
+ }, Oe, je, be;
378
+ be = {};
379
+ function rt(e) {
380
+ if (se.call(e, "ref")) {
381
+ var t = Object.getOwnPropertyDescriptor(e, "ref").get;
382
+ if (t && t.isReactWarning)
383
+ return !1;
384
+ }
385
+ return e.ref !== void 0;
386
+ }
387
+ function nt(e) {
388
+ if (se.call(e, "key")) {
389
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
390
+ if (t && t.isReactWarning)
391
+ return !1;
392
+ }
393
+ return e.key !== void 0;
394
+ }
395
+ function it(e, t) {
396
+ if (typeof e.ref == "string" && le.current && t && le.current.stateNode !== t) {
397
+ var r = S(le.current.type);
398
+ be[r] || (p('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', S(le.current.type), e.ref), be[r] = !0);
399
+ }
400
+ }
401
+ function ot(e, t) {
402
+ {
403
+ var r = function() {
404
+ Oe || (Oe = !0, p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", t));
405
+ };
406
+ r.isReactWarning = !0, Object.defineProperty(e, "key", {
407
+ get: r,
408
+ configurable: !0
409
+ });
410
+ }
411
+ }
412
+ function at(e, t) {
413
+ {
414
+ var r = function() {
415
+ je || (je = !0, p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", t));
416
+ };
417
+ r.isReactWarning = !0, Object.defineProperty(e, "ref", {
418
+ get: r,
419
+ configurable: !0
420
+ });
421
+ }
422
+ }
423
+ var st = function(e, t, r, o, v, m, d) {
424
+ var f = {
425
+ // This tag allows us to uniquely identify this as a React Element
426
+ $$typeof: i,
427
+ // Built-in properties that belong on the element
428
+ type: e,
429
+ key: t,
430
+ ref: r,
431
+ props: d,
432
+ // Record the component responsible for creating this element.
433
+ _owner: m
434
+ };
435
+ return f._store = {}, Object.defineProperty(f._store, "validated", {
436
+ configurable: !1,
437
+ enumerable: !1,
438
+ writable: !0,
439
+ value: !1
440
+ }), Object.defineProperty(f, "_self", {
441
+ configurable: !1,
442
+ enumerable: !1,
443
+ writable: !1,
444
+ value: o
445
+ }), Object.defineProperty(f, "_source", {
446
+ configurable: !1,
447
+ enumerable: !1,
448
+ writable: !1,
449
+ value: v
450
+ }), Object.freeze && (Object.freeze(f.props), Object.freeze(f)), f;
451
+ };
452
+ function lt(e, t, r, o, v) {
453
+ {
454
+ var m, d = {}, f = null, Y = null;
455
+ r !== void 0 && ($e(r), f = "" + r), nt(t) && ($e(t.key), f = "" + t.key), rt(t) && (Y = t.ref, it(t, v));
456
+ for (m in t)
457
+ se.call(t, m) && !tt.hasOwnProperty(m) && (d[m] = t[m]);
458
+ if (e && e.defaultProps) {
459
+ var T = e.defaultProps;
460
+ for (m in T)
461
+ d[m] === void 0 && (d[m] = T[m]);
462
+ }
463
+ if (f || Y) {
464
+ var P = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
465
+ f && ot(d, P), Y && at(d, P);
466
+ }
467
+ return st(e, f, Y, v, o, le.current, d);
468
+ }
469
+ }
470
+ var xe = w.ReactCurrentOwner, ke = w.ReactDebugCurrentFrame;
471
+ function oe(e) {
472
+ if (e) {
473
+ var t = e._owner, r = he(e.type, e._source, t ? t.type : null);
474
+ ke.setExtraStackFrame(r);
475
+ } else
476
+ ke.setExtraStackFrame(null);
477
+ }
478
+ var _e;
479
+ _e = !1;
480
+ function Ee(e) {
481
+ return typeof e == "object" && e !== null && e.$$typeof === i;
482
+ }
483
+ function Ie() {
484
+ {
485
+ if (xe.current) {
486
+ var e = S(xe.current.type);
487
+ if (e)
488
+ return `
489
+
490
+ Check the render method of \`` + e + "`.";
491
+ }
492
+ return "";
493
+ }
494
+ }
495
+ function ct(e) {
496
+ {
497
+ if (e !== void 0) {
498
+ var t = e.fileName.replace(/^.*[\\\/]/, ""), r = e.lineNumber;
499
+ return `
500
+
501
+ Check your code at ` + t + ":" + r + ".";
502
+ }
503
+ return "";
504
+ }
505
+ }
506
+ var De = {};
507
+ function ut(e) {
508
+ {
509
+ var t = Ie();
510
+ if (!t) {
511
+ var r = typeof e == "string" ? e : e.displayName || e.name;
512
+ r && (t = `
513
+
514
+ Check the top-level render call using <` + r + ">.");
515
+ }
516
+ return t;
517
+ }
518
+ }
519
+ function Me(e, t) {
520
+ {
521
+ if (!e._store || e._store.validated || e.key != null)
522
+ return;
523
+ e._store.validated = !0;
524
+ var r = ut(t);
525
+ if (De[r])
526
+ return;
527
+ De[r] = !0;
528
+ var o = "";
529
+ e && e._owner && e._owner !== xe.current && (o = " It was passed a child from " + S(e._owner.type) + "."), oe(e), p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', r, o), oe(null);
530
+ }
531
+ }
532
+ function Fe(e, t) {
533
+ {
534
+ if (typeof e != "object")
535
+ return;
536
+ if (me(e))
537
+ for (var r = 0; r < e.length; r++) {
538
+ var o = e[r];
539
+ Ee(o) && Me(o, t);
540
+ }
541
+ else if (Ee(e))
542
+ e._store && (e._store.validated = !0);
543
+ else if (e) {
544
+ var v = j(e);
545
+ if (typeof v == "function" && v !== e.entries)
546
+ for (var m = v.call(e), d; !(d = m.next()).done; )
547
+ Ee(d.value) && Me(d.value, t);
548
+ }
549
+ }
550
+ }
551
+ function ft(e) {
552
+ {
553
+ var t = e.type;
554
+ if (t == null || typeof t == "string")
555
+ return;
556
+ var r;
557
+ if (typeof t == "function")
558
+ r = t.propTypes;
559
+ else if (typeof t == "object" && (t.$$typeof === g || // Note: Memo only checks outer props here.
560
+ // Inner props are checked in the reconciler.
561
+ t.$$typeof === $))
562
+ r = t.propTypes;
563
+ else
564
+ return;
565
+ if (r) {
566
+ var o = S(t);
567
+ Ze(r, e.props, "prop", o, e);
568
+ } else if (t.PropTypes !== void 0 && !_e) {
569
+ _e = !0;
570
+ var v = S(t);
571
+ p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", v || "Unknown");
572
+ }
573
+ typeof t.getDefaultProps == "function" && !t.getDefaultProps.isReactClassApproved && p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
574
+ }
575
+ }
576
+ function dt(e) {
577
+ {
578
+ for (var t = Object.keys(e.props), r = 0; r < t.length; r++) {
579
+ var o = t[r];
580
+ if (o !== "children" && o !== "key") {
581
+ oe(e), p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", o), oe(null);
582
+ break;
583
+ }
584
+ }
585
+ e.ref !== null && (oe(e), p("Invalid attribute `ref` supplied to `React.Fragment`."), oe(null));
586
+ }
587
+ }
588
+ var Ae = {};
589
+ function Ye(e, t, r, o, v, m) {
590
+ {
591
+ var d = te(e);
592
+ if (!d) {
593
+ var f = "";
594
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (f += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
595
+ var Y = ct(v);
596
+ Y ? f += Y : f += Ie();
597
+ var T;
598
+ e === null ? T = "null" : me(e) ? T = "array" : e !== void 0 && e.$$typeof === i ? (T = "<" + (S(e.type) || "Unknown") + " />", f = " Did you accidentally export a JSX literal instead of a component?") : T = typeof e, p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", T, f);
599
+ }
600
+ var P = lt(e, t, r, v, m);
601
+ if (P == null)
602
+ return P;
603
+ if (d) {
604
+ var B = t.children;
605
+ if (B !== void 0)
606
+ if (o)
607
+ if (me(B)) {
608
+ for (var ae = 0; ae < B.length; ae++)
609
+ Fe(B[ae], e);
610
+ Object.freeze && Object.freeze(B);
611
+ } else
612
+ p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
613
+ else
614
+ Fe(B, e);
615
+ }
616
+ if (se.call(t, "key")) {
617
+ var ne = S(e), N = Object.keys(t).filter(function(mt) {
618
+ return mt !== "key";
619
+ }), Re = N.length > 0 ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}";
620
+ if (!Ae[ne + Re]) {
621
+ var yt = N.length > 0 ? "{" + N.join(": ..., ") + ": ...}" : "{}";
622
+ p(`A props object containing a "key" prop is being spread into JSX:
623
+ let props = %s;
624
+ <%s {...props} />
625
+ React keys must be passed directly to JSX without using spread:
626
+ let props = %s;
627
+ <%s key={someKey} {...props} />`, Re, ne, yt, ne), Ae[ne + Re] = !0;
628
+ }
629
+ }
630
+ return e === x ? dt(P) : ft(P), P;
631
+ }
632
+ }
633
+ function ht(e, t, r) {
634
+ return Ye(e, t, r, !0);
635
+ }
636
+ function vt(e, t, r) {
637
+ return Ye(e, t, r, !1);
638
+ }
639
+ var gt = vt, pt = ht;
640
+ ue.Fragment = x, ue.jsx = gt, ue.jsxs = pt;
641
+ }()), ue;
642
+ }
643
+ process.env.NODE_ENV === "production" ? we.exports = Et() : we.exports = Rt();
644
+ var X = we.exports;
645
+ const We = (() => {
646
+ const n = [0];
647
+ let i = 1, s = 1;
648
+ for (; i <= Number.MAX_SAFE_INTEGER; )
649
+ n.push(i), [i, s] = [s, i + s];
650
+ return n;
651
+ })();
652
+ function Ge(n) {
653
+ const i = [1, 1];
654
+ for (; i[i.length - 1] < n; )
655
+ i.push(i[i.length - 1] + i[i.length - 2]);
656
+ return i.filter((s) => s <= n);
657
+ }
658
+ function Le(n, i) {
659
+ let s = Math.min(n, i), x = Math.max(n, i);
660
+ if (x === 0)
661
+ return null;
662
+ s === 0 && (s = 1);
663
+ const h = s - 1, c = x - 1, l = [1, 1];
664
+ for (; l.length <= c; )
665
+ l.push(l[l.length - 1] + l[l.length - 2]);
666
+ return {
667
+ userSequence: l.slice(h, c + 1),
668
+ startIdx: h,
669
+ endIdx: c
670
+ };
671
+ }
672
+ const Be = bt({
673
+ inputControl: {
674
+ from: 1,
675
+ to: 1,
676
+ color: "#7f7ec7",
677
+ clockwise: !0,
678
+ placement: "right"
679
+ },
680
+ setInputControl: () => {
681
+ }
682
+ }), St = ({ children: n, initialConfig: i }) => {
683
+ if (!n)
684
+ return /* @__PURE__ */ X.jsx(X.Fragment, {});
685
+ const [s, x] = xt({
686
+ from: 1,
687
+ to: 4,
688
+ color: "#7f7ec7",
689
+ clockwise: !0,
690
+ placement: "right",
691
+ ...i
692
+ }), h = (c) => {
693
+ const { from: l, to: u } = c;
694
+ l < 0 || l >= We.length || u < 0 || u >= We.length || !Number.isInteger(l) || !Number.isInteger(u) || x(c);
695
+ };
696
+ return /* @__PURE__ */ X.jsx(Be.Provider, { value: { inputControl: s, setInputControl: h }, children: n });
697
+ }, wt = () => {
698
+ const n = _t(Be);
699
+ if (!n)
700
+ throw new Error("useGrid must be used within a GridProvider");
701
+ return n;
702
+ };
703
+ function Ue(n, i, s) {
704
+ const h = { right: 0, bottom: 90, left: 180, top: 270 }[n];
705
+ if (s < 2)
706
+ return (h + 360) % 360;
707
+ const u = (i ? [90, 180, 270, 0] : [270, 180, 90, 0])[(s - 2) % 4];
708
+ return (h - u + 360) % 360;
709
+ }
710
+ function Ve(n, i = !0, s = 0) {
711
+ if (n.length < 2)
712
+ throw new Error("Need at least two numbers in the sequence.");
713
+ if (![0, 90, 180, 270].includes(s))
714
+ throw new Error(`Invalid rotation value: ${s}. Only 0, 90, 180, and 270 are allowed.`);
715
+ const h = [];
716
+ let c = 1 / 0, l = -1 / 0, u = 1 / 0, g = -1 / 0;
717
+ function R(a) {
718
+ a.x < c && (c = a.x), a.x + a.size - 1 > l && (l = a.x + a.size - 1), a.y < u && (u = a.y), a.y + a.size - 1 > g && (g = a.y + a.size - 1);
719
+ }
720
+ function _() {
721
+ c = 1 / 0, l = -1 / 0, u = 1 / 0, g = -1 / 0;
722
+ for (const a of h)
723
+ R(a);
724
+ }
725
+ h.push({ size: n[0], x: 0, y: 0 }), h.push({ size: n[1], x: n[0], y: 0 }), R(h[0]), R(h[1]);
726
+ const $ = i ? [{ dx: 0, dy: 1 }, { dx: -1, dy: 0 }, { dx: 0, dy: -1 }, { dx: 1, dy: 0 }] : [{ dx: 0, dy: -1 }, { dx: -1, dy: 0 }, { dx: 0, dy: 1 }, { dx: 1, dy: 0 }];
727
+ let M = 0;
728
+ for (let a = 2; a < n.length; a++) {
729
+ const j = n[a], w = $[M];
730
+ let p, z;
731
+ w.dx === 0 && w.dy === 1 ? (p = c, z = g + 1) : w.dx === -1 && w.dy === 0 ? (p = c - j, z = g - j + 1) : w.dx === 0 && w.dy === -1 ? (p = l - j + 1, z = u - j) : (p = l + 1, z = u);
732
+ const H = { size: j, x: p, y: z };
733
+ h.push(H), R(H), M = (M + 1) % $.length;
734
+ }
735
+ s && (h.forEach((a) => {
736
+ const j = a.x, w = a.y;
737
+ s === 90 ? (a.x = -w - a.size + 1, a.y = j) : s === 180 ? (a.x = -j - a.size + 1, a.y = -w - a.size + 1) : s === 270 && (a.x = w, a.y = -j - a.size + 1);
738
+ }), _());
739
+ const U = l - c + 1, I = g - u + 1;
740
+ return { squares: h, width: U, height: I, minX: c, minY: u };
741
+ }
742
+ function Xe(n) {
743
+ n = n.replace(/^#/, "");
744
+ let i = parseInt(n.substring(0, 2), 16) / 255, s = parseInt(n.substring(2, 4), 16) / 255, x = parseInt(n.substring(4, 6), 16) / 255, h = Math.max(i, s, x), c = Math.min(i, s, x), l = 0, u = 0, g = (h + c) / 2;
745
+ if (h !== c) {
746
+ let R = h - c;
747
+ switch (u = g > 0.5 ? R / (2 - h - c) : R / (h + c), h) {
748
+ case i:
749
+ l = (s - x) / R + (s < x ? 6 : 0);
750
+ break;
751
+ case s:
752
+ l = (x - i) / R + 2;
753
+ break;
754
+ case x:
755
+ l = (i - s) / R + 4;
756
+ break;
757
+ }
758
+ l = l / 6;
759
+ }
760
+ return [l * 360, u * 100, g * 100];
761
+ }
762
+ function pe(n, i, s) {
763
+ return `hsl(${n}, ${i}%, ${s}%)`;
764
+ }
765
+ const Ct = ({ children: n, className: i, style: s }) => /* @__PURE__ */ X.jsx(
766
+ "div",
767
+ {
768
+ className: i,
769
+ style: { width: "100%", height: "100%", position: "relative", ...s },
770
+ children: n
771
+ }
772
+ );
773
+ const Pt = (n) => {
774
+ const { inputControl: i } = wt(), s = n.from ?? i.from, x = n.to ?? i.to, h = "color" in n ? n.color : i.color, c = n.clockwise ?? i.clockwise, l = n.placement ?? i.placement, u = "outline" in n ? n.outline : void 0, g = !!u, R = u ? { borderTop: u, borderLeft: u } : {}, _ = u ? { borderRight: u, borderBottom: u } : {}, $ = ge.Children.toArray(n.children).filter(
775
+ (b) => ge.isValidElement(b) && b.type === Ct
776
+ ), M = $.find((b) => b.props.placeholder) ?? null, U = $.filter((b) => !b.props.placeholder);
777
+ let I = s, a = x;
778
+ I > a && ([I, a] = [a, I]);
779
+ const j = Le(I, a);
780
+ if (!j)
781
+ return /* @__PURE__ */ X.jsx("div", { className: "golden-grid" });
782
+ const { userSequence: w, startIdx: p, endIdx: z } = j, H = Ue(l, c, p), ee = Math.max(...w), ie = Ge(ee), J = h || void 0, [C, Z, te] = J ? Xe(J) : [0, 0, 50], Q = `golden-grid${g ? " golden-grid--outlined" : ""}`;
783
+ if (p === 0 && z === 0) {
784
+ const b = J ? pe(C, Z, te) : void 0;
785
+ return /* @__PURE__ */ X.jsx("div", { className: Q, style: { aspectRatio: "1 / 1", ...R }, children: /* @__PURE__ */ X.jsx("div", { className: "golden-grid__box", style: { left: 0, top: 0, width: "100%", height: "100%", background: b, ..._ }, children: U[0] ?? null }) });
786
+ }
787
+ const E = Ve(ie, c, H), S = E.squares.slice(p, z + 1), W = E.squares.slice(0, p), G = W.length > 0;
788
+ let O = null;
789
+ if (G) {
790
+ let b = 1 / 0, k = -1 / 0, D = 1 / 0, V = -1 / 0;
791
+ for (const y of W)
792
+ y.x < b && (b = y.x), y.x + y.size - 1 > k && (k = y.x + y.size - 1), y.y < D && (D = y.y), y.y + y.size - 1 > V && (V = y.y + y.size - 1);
793
+ const K = k - b + 1, re = V - D + 1;
794
+ O = {
795
+ left: `${(b - E.minX) / E.width * 100}%`,
796
+ top: `${(D - E.minY) / E.height * 100}%`,
797
+ width: `${K / E.width * 100}%`,
798
+ height: `${re / E.height * 100}%`,
799
+ background: J ?? void 0,
800
+ ..._
801
+ };
802
+ }
803
+ const F = S.length, L = Math.min(330, 180 + Math.max(0, F - 4) * 15), A = Math.min(50, F * 3), q = S.map((b, k) => {
804
+ if (!J)
805
+ return;
806
+ let D = 0;
807
+ F > 1 ? D = G ? (k + 1) / (F + 1) : k / (F - 1) : G && (D = 0.5);
808
+ const V = (C + L * D) % 360, K = Math.max(10, Math.min(90, te + A / 2 - D * A));
809
+ return pe(V, Z, K);
810
+ });
811
+ return /* @__PURE__ */ X.jsxs("div", { className: Q, style: { aspectRatio: `${E.width} / ${E.height}`, ...R }, children: [
812
+ G && O && /* @__PURE__ */ X.jsx(
813
+ "div",
814
+ {
815
+ className: "golden-grid__box golden-grid__box--placeholder",
816
+ style: O,
817
+ children: M
818
+ }
819
+ ),
820
+ S.map((b, k) => /* @__PURE__ */ X.jsx(
821
+ "div",
822
+ {
823
+ className: "golden-grid__box",
824
+ style: {
825
+ left: `${(b.x - E.minX) / E.width * 100}%`,
826
+ top: `${(b.y - E.minY) / E.height * 100}%`,
827
+ width: `${b.size / E.width * 100}%`,
828
+ height: `${b.size / E.height * 100}%`,
829
+ background: q[k],
830
+ ..._
831
+ },
832
+ children: U[k] ?? null
833
+ },
834
+ k
835
+ ))
836
+ ] });
837
+ };
838
+ function $t(n, i, s, x, h, c) {
839
+ let l = n, u = i;
840
+ l > u && ([l, u] = [u, l]);
841
+ const g = Le(l, u);
842
+ if (!g)
843
+ return "<!-- No grid to render -->";
844
+ const { userSequence: R, startIdx: _, endIdx: $ } = g, M = Math.max(...R), U = Ge(M), I = s || void 0, [a, j, w] = I ? Xe(I) : [0, 0, 50], p = !!c, z = `golden-grid${p ? " golden-grid--outlined" : ""}`, H = c ? ` style="border-top: ${c}; border-left: ${c};"` : "", ee = c ? ` border-right: ${c}; border-bottom: ${c};` : "", ie = p ? `
845
+ .golden-grid--outlined > .golden-grid__box { box-sizing: border-box; }` : "";
846
+ if (_ === 0 && $ === 0) {
847
+ const O = I ? ` background: ${pe(a, j, w)};` : "";
848
+ return `<!DOCTYPE html>
849
+ <html lang="en">
850
+ <head>
851
+ <meta charset="UTF-8">
852
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
853
+ <title>Golden Grid</title>
854
+ <style>
855
+ body { margin: 0; padding: 0; }
856
+ .golden-grid {
857
+ margin: 0; padding: 0;
858
+ position: relative; width: 100%; aspect-ratio: 1 / 1;
859
+ }
860
+ .golden-grid > .golden-grid__box { position: absolute; }${ie}
861
+ </style>
862
+ </head>
863
+ <body>
864
+ <div class="${z}"${H}>
865
+ <div class="golden-grid__box" style="left: 0; top: 0; width: 100%; height: 100%;${O}${ee}"></div>
866
+ </div>
867
+ </body>
868
+ </html>`;
869
+ }
870
+ const J = Ue(h, x, _), C = Ve(U, x, J), Z = C.squares.slice(_, $ + 1), te = C.squares.slice(0, _), Q = te.length > 0, E = [];
871
+ if (Q) {
872
+ let O = 1 / 0, F = -1 / 0, L = 1 / 0, A = -1 / 0;
873
+ for (const y of te)
874
+ y.x < O && (O = y.x), y.x + y.size - 1 > F && (F = y.x + y.size - 1), y.y < L && (L = y.y), y.y + y.size - 1 > A && (A = y.y + y.size - 1);
875
+ const q = F - O + 1, b = A - L + 1, k = (O - C.minX) / C.width * 100, D = (L - C.minY) / C.height * 100, V = q / C.width * 100, K = b / C.height * 100, re = I ? ` background: ${I};` : "";
876
+ E.push(
877
+ ` <div class="golden-grid__box golden-grid__box--placeholder" style="left: ${k}%; top: ${D}%; width: ${V}%; height: ${K}%;${re}${ee}"></div>`
878
+ );
879
+ }
880
+ const S = Z.length, W = Math.min(330, 180 + Math.max(0, S - 4) * 15), G = Math.min(50, S * 3);
881
+ return Z.forEach((O, F) => {
882
+ let L = a, A = 0;
883
+ S > 1 ? (Q ? A = (F + 1) / (S + 1) : A = F / (S - 1), L = (a + W * A) % 360) : Q && (A = 0.5, L = (a + W * 0.5) % 360);
884
+ const q = Math.max(10, Math.min(90, w + G / 2 - A * G)), b = (O.x - C.minX) / C.width * 100, k = (O.y - C.minY) / C.height * 100, D = O.size / C.width * 100, V = O.size / C.height * 100, K = I ? ` background: ${pe(L, j, q)};` : "";
885
+ E.push(
886
+ ` <div class="golden-grid__box" style="left: ${b}%; top: ${k}%; width: ${D}%; height: ${V}%;${K}${ee}"></div>`
887
+ );
888
+ }), `<!DOCTYPE html>
889
+ <html lang="en">
890
+ <head>
891
+ <meta charset="UTF-8">
892
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
893
+ <title>Golden Grid</title>
894
+ <style>
895
+ body { margin: 0; padding: 0; }
896
+ .golden-grid {
897
+ margin: 0;
898
+ padding: 0;
899
+ position: relative;
900
+ width: 100%;
901
+ box-sizing: border-box;
902
+ aspect-ratio: ${C.width} / ${C.height};
903
+ }
904
+ .golden-grid > .golden-grid__box {
905
+ position: absolute;
906
+ }${ie}
907
+ </style>
908
+ </head>
909
+ <body>
910
+ <div class="${z}"${H}>
911
+ ${E.join(`
912
+ `)}
913
+ </div>
914
+ </body>
915
+ </html>`;
916
+ }
917
+ export {
918
+ We as FIB_STOPS,
919
+ Ct as GoldenBox,
920
+ Pt as GoldenGrid,
921
+ St as GridProvider,
922
+ Ve as generateGoldenGridLayout,
923
+ $t as generateGridHTML,
924
+ Le as getGridRange,
925
+ wt as useGrid
926
+ };
@@ -0,0 +1,83 @@
1
+ import { default as default_2 } from 'react';
2
+ import * as React_2 from 'react';
3
+
4
+ export declare const FIB_STOPS: number[];
5
+
6
+ /**
7
+ * Generate the golden spiral layout using bounding-box placement.
8
+ * Each new square is placed flush against the overall grid edge,
9
+ * producing a tight Fibonacci spiral.
10
+ */
11
+ export declare function generateGoldenGridLayout(fibSequence: number[], clockwise?: boolean, rotate?: number): GridLayout;
12
+
13
+ export declare function generateGridHTML(from: number, to: number, color: string | undefined, clockwise: boolean, placement: "right" | "bottom" | "left" | "top", outline?: string): string;
14
+
15
+ /**
16
+ * Get the grid range from FIB_STOPS indices.
17
+ * fromIdx/toIdx are positions in FIB_STOPS (0 = value 0, 1 = first 1, 2 = second 1, 3 = 2, ...).
18
+ * Returns userSequence as Fibonacci values, and startIdx/endIdx into the fullFib array.
19
+ */
20
+ export declare function getGridRange(fromIdx: number, toIdx: number): {
21
+ userSequence: number[];
22
+ startIdx: number;
23
+ endIdx: number;
24
+ } | null;
25
+
26
+ export declare const GoldenBox: default_2.FC<GoldenBoxProps>;
27
+
28
+ export declare interface GoldenBoxProps {
29
+ children?: default_2.ReactNode;
30
+ placeholder?: boolean;
31
+ className?: string;
32
+ style?: default_2.CSSProperties;
33
+ }
34
+
35
+ export declare const GoldenGrid: default_2.FC<GoldenGridProps>;
36
+
37
+ export declare interface GoldenGridProps {
38
+ from?: number;
39
+ to?: number;
40
+ color?: string;
41
+ clockwise?: boolean;
42
+ placement?: "right" | "bottom" | "left" | "top";
43
+ outline?: string;
44
+ children?: default_2.ReactNode;
45
+ }
46
+
47
+ declare interface GridContextProps {
48
+ inputControl: InputControlType;
49
+ setInputControl: (control: InputControlType) => void;
50
+ }
51
+
52
+ export declare interface GridLayout {
53
+ squares: Square[];
54
+ width: number;
55
+ height: number;
56
+ minX: number;
57
+ minY: number;
58
+ }
59
+
60
+ export declare const GridProvider: React_2.FC<{
61
+ children?: React_2.ReactNode;
62
+ initialConfig?: Partial<InputControlType>;
63
+ }>;
64
+
65
+ export declare interface InputControlType {
66
+ from: number;
67
+ to: number;
68
+ color: string;
69
+ clockwise: boolean;
70
+ placement: PlacementValue;
71
+ }
72
+
73
+ export declare type PlacementValue = "right" | "bottom" | "left" | "top";
74
+
75
+ export declare interface Square {
76
+ x: number;
77
+ y: number;
78
+ size: number;
79
+ }
80
+
81
+ export declare const useGrid: () => GridContextProps;
82
+
83
+ export { }
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Golden Grids</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/index.tsx"></script>
11
+ </body>
12
+ </html>
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "@gifcommit/golden-grids",
3
+ "version": "1.0.0",
4
+ "description": "A React library for generating golden ratio grid layouts.",
5
+ "main": "dist/golden-grids.cjs.js",
6
+ "module": "dist/golden-grids.es.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/golden-grids.es.js",
11
+ "require": "./dist/golden-grids.cjs.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "vite build",
17
+ "dev": "vite",
18
+ "start": "vite",
19
+ "serve": "vite preview",
20
+ "build:demo": "VITE_BUILD_DEMO=1 vite build",
21
+ "test": "jest",
22
+ "prepack": "npm run build",
23
+ "prepublishOnly": "npm test",
24
+ "setup": "husky install"
25
+ },
26
+ "devDependencies": {
27
+ "@rollup/plugin-commonjs": "^28.0.2",
28
+ "@rollup/plugin-node-resolve": "^16.0.0",
29
+ "@rollup/plugin-typescript": "^12.1.2",
30
+ "@semantic-release/changelog": "^6.0.3",
31
+ "@semantic-release/commit-analyzer": "^13.0.1",
32
+ "@semantic-release/git": "^10.0.1",
33
+ "@semantic-release/github": "^12.0.6",
34
+ "@semantic-release/npm": "^13.1.4",
35
+ "@semantic-release/release-notes-generator": "^14.1.0",
36
+ "@types/jest": "^27.5.2",
37
+ "@types/react": "^19.0.8",
38
+ "@types/react-dom": "^19.0.3",
39
+ "@vitejs/plugin-react": "^4.7.0",
40
+ "husky": "^8.0.0",
41
+ "jest": "^27.4.3",
42
+ "react": "^18.3.1",
43
+ "react-dom": "^18.3.1",
44
+ "rollup": "^4.32.1",
45
+ "rollup-plugin-dts": "^6.1.1",
46
+ "rollup-plugin-peer-deps-external": "^2.2.4",
47
+ "rollup-plugin-postcss": "^4.0.2",
48
+ "semantic-release": "^25.0.3",
49
+ "ts-jest": "^27.1.0",
50
+ "tslib": "^2.8.1",
51
+ "typescript": "^4.9.5",
52
+ "vite": "^4.0.0",
53
+ "vite-plugin-css-injected-by-js": "^3.5.2",
54
+ "vite-plugin-dts": "^4.5.4"
55
+ },
56
+ "peerDependencies": {
57
+ "react": "^18.0.0",
58
+ "react-dom": "^18.0.0"
59
+ },
60
+ "files": [
61
+ "dist"
62
+ ],
63
+ "publishConfig": {
64
+ "access": "public"
65
+ },
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "https://github.com/gregoryedgerton/golden-grids"
69
+ },
70
+ "keywords": [
71
+ "react",
72
+ "golden ratio",
73
+ "grid",
74
+ "layout"
75
+ ],
76
+ "author": "Gregory Edgerton",
77
+ "license": "MIT",
78
+ "jest": {
79
+ "preset": "ts-jest",
80
+ "testEnvironment": "node",
81
+ "globals": {
82
+ "ts-jest": {
83
+ "tsconfig": "./tsconfig.test.json"
84
+ }
85
+ }
86
+ }
87
+ }